功能介紹
- SSH連接到遠程服務器:
- 用戶可以輸入目標服務器的IP地址、用戶名、密碼以及SSH端口(默認22)。
- 工具會嘗試連接到遠程服務器,并在連接失敗時顯示錯誤信息。
- 運行命令并返回輸出:
- 工具可以在遠程服務器上運行命令,并返回命令的輸出結果。
- 解析配置文件:
- 工具可以解析不同類型的配置文件,包括PHP、Java、Python、Ruby和ASP/.NET,提取數據庫配置信息。
4.?分析服務器信息:
- 工具可以獲取系統信息、用戶信息、網絡信息、進程信息和已安裝的軟件信息。
- 工具還可以獲取網站配置和數據庫配置信息。
5.?保存結果到文件:
- 用戶可以選擇保存路徑,工具會將分析結果保存為JSON文件。
SSH連接實現
import paramiko
from tkinter import messageboxdef ssh_connect(ip, username, password, port=22):try:client = paramiko.SSHClient()client.set_missing_host_key_policy(paramiko.AutoAddPolicy())client.connect(ip, username=username, password=password, port=port)return clientexcept Exception as e:messagebox.showerror("連接失敗", f"連接失敗: {e}")return None
運行命令并返回輸出
def run_command(client, command):stdin, stdout, stderr = client.exec_command(command)return stdout.read().decode()
服務器基本信息
def analyze_server(client):results = {}# 系統信息os_version = run_command(client, "cat /etc/os-release")kernel_version = run_command(client, "uname -r")hostname = run_command(client, "hostname")results['系統信息'] = {'os_version': os_version.strip().split('\n'),'kernel_version': kernel_version.strip(),'hostname': hostname.strip()}# 用戶信息users = run_command(client, "cat /etc/passwd")sudoers = run_command(client, "cat /etc/sudoers")results['用戶信息'] = {'users': users.strip().split('\n'),'sudoers': sudoers.strip().split('\n')}# 網絡信息interfaces = run_command(client, "ip addr")ifconfig = run_command(client, "ifconfig")listening_ports = run_command(client, "netstat -anp")active_connections = run_command(client, "ss -tunap")results['網絡信息'] = {'interfaces': interfaces.strip().split('\n'),'ifconfig': ifconfig.strip().split('\n'),'listening_ports': listening_ports.strip().split('\n'),'active_connections': active_connections.strip().split('\n')}# 進程信息processes = run_command(client, "ps aux")results['進程信息'] = processes.strip().split('\n')# 已安裝的軟件installed_software = run_command(client, "rpm -qa")results['安裝軟件信息'] = installed_software.strip().split('\n')return results
主界面效果
輸出內容