本文目录导读:

Windows 环境(Batch 脚本 .bat)
场景:一键启动网络排查、杀毒、事件查看器等工具。
@echo off应急工具启动器 color 0C echo ======================================== echo Windows 应急工具快速启动 echo ======================================== echo 1. 启动 命令提示符(管理员) echo 2. 启动 事件查看器 echo 3. 启动 任务管理器 echo 4. 启动 资源监视器 echo 5. 启动 网络连接 (ncpa.cpl) echo 6. 启动 PowerShell(管理员) echo 7. 启动 防火墙高级设置 echo 8. 启动 系统配置 (msconfig) echo 9. 启动 磁盘清理 echo 0. 退出 echo ======================================== set /p choice="请输入选择 (0-9): " if "%choice%"=="1" start powershell -Command "Start-Process cmd -Verb RunAs" if "%choice%"=="2" eventvwr.msc if "%choice%"=="3" taskmgr if "%choice%"=="4" resmon if "%choice%"=="5" ncpa.cpl if "%choice%"=="6" start powershell -Command "Start-Process powershell -Verb RunAs" if "%choice%"=="7" wf.msc if "%choice%"=="8" msconfig if "%choice%"=="9" cleanmgr if "%choice%"=="0" exit pause
使用方法:
- 保存为
应急启动.bat。 - 右键 → 以管理员身份运行(某些工具需要管理员权限)。
Linux 环境(Shell 脚本 .sh)
场景:快速执行系统信息收集、网络诊断、进程排查等。
#!/bin/bash # 应急工具快速启动 echo "==============================" echo " Linux 应急工具启动器" echo "==============================" echo "1) 查看网络连接 (ss -tulnp)" echo "2) 查看进程 (ps aux)" echo "3) 查看系统日志 (journalctl)" echo "4) 查看开放端口 (netstat)" echo "5) 检查磁盘使用 (df -h)" echo "6) 检查内存 (free -m)" echo "7) 运行网络诊断 (ping/traceroute)" echo "8) 启动 Wireshark (需安装)" echo "9) 启动 tcpdump" echo "0) 退出" read -p "请输入选择: " choice case $choice in 1) ss -tulnp ;; 2) ps aux ;; 3) journalctl -xe ;; 4) netstat -tulnp ;; 5) df -h ;; 6) free -m ;; 7) read -p "输入目标IP: " target; echo "--- ping ---"; ping -c 4 $target; echo "--- traceroute ---"; traceroute $target ;; 8) wireshark ;; 9) read -p "输入捕获网卡 (如 eth0): " iface; tcpdump -i $iface -nn ;; 0) exit ;; *) echo "无效选择" ;; esac
使用方法:
chmod +x 应急启动.sh sudo ./应急启动.sh
跨平台 Python 版本(需 Python3)
场景:统一脚本,支持 Windows/Linux/macOS。
#!/usr/bin/env python3
import os
import sys
import subprocess
def main():
print("="*40)
print(" 应急工具快速启动器")
print("="*40)
print("1. 查看网络连接")
print("2. 查看进程列表")
print("3. 查看磁盘空间")
print("4. 查看系统日志")
print("5. 启动命令行/终端")
print("6. 启动 Wireshark")
print("7. 启动 tcpdump")
print("0. 退出")
choice = input("请输入选择: ")
commands = {
"1": "ss -tulnp" if sys.platform != "win32" else "netstat -ano",
"2": "ps aux" if sys.platform != "win32" else "tasklist",
"3": "df -h" if sys.platform != "win32" else "wmic logicaldisk get size,freespace,caption",
"4": "journalctl -xe" if sys.platform != "win32" else "wevtutil qe System /c:10",
"5": "cmd" if sys.platform == "win32" else "x-terminal-emulator",
"6": "wireshark" if sys.platform != "win32" else "start wireshark",
"7": "tcpdump -i any"
}
if choice == "0":
sys.exit()
elif choice in commands:
cmd = commands[choice]
subprocess.run(cmd, shell=True)
else:
print("无效选择")
if __name__ == "__main__":
main()
高级用法:后台静默启动 + 日志记录
如果想在应急时一键启动多个工具并收集结果,可以写成:
#!/bin/bash # 快速取证采集脚本 LOGDIR="./应急日志_$(date +%Y%m%d_%H%M%S)" mkdir -p $LOGDIR # 收集系统信息 echo "正在收集系统信息..." uname -a > $LOGDIR/系统版本.txt lscpu > $LOGDIR/CPU信息.txt free -m > $LOGDIR/内存信息.txt df -h > $LOGDIR/磁盘信息.txt ss -tulnp > $LOGDIR/网络连接.txt ps aux > $LOGDIR/进程列表.txt last -10 > $LOGDIR/最近登录.txt echo "日志已保存至 $LOGDIR" # 打包压缩(可选) tar -czf $LOGDIR.tar.gz $LOGDIR
快速使用建议
- 贴到桌面 / 快捷栏:把脚本图标固定到任务栏或桌面。
- 快捷键绑定:
- Windows:创建快捷方式 → 属性 → 设置快捷键(
Ctrl+Alt+E)。 - Linux:在
.bashrc中加alias emtool='/path/to/应急启动.sh'。
- Windows:创建快捷方式 → 属性 → 设置快捷键(
- 预装工具:确保
tcpdump、wireshark、sysstat等已安装。 - 编写常用命令镜像:将常用应急命令整理到脚本的
case或if中。