在Ubuntu 22.04上安裝Autorecon

Ubuntu 22.04 Autorecon Install

前言

AutoRecon 是由 Tib3rius 開發的多執行緒網路偵察工具,專為滲透測試的資訊收集階段設計。它能夠自動化執行多種掃描工具,大幅提升滲透測試初期偵察的效率。

AutoRecon 的特色

  • 自動化偵察流程:整合多種掃描工具,根據發現的服務自動執行對應的深度掃描
  • 多執行緒設計:同時對多個目標進行掃描,節省大量時間
  • 智慧化掃描:根據 Nmap 發現的開放端口,自動選擇適當的後續掃描工具
  • 結構化輸出:將所有掃描結果組織成清晰的目錄結構,方便後續分析
  • 高度可自訂:支援自訂掃描設定檔,可根據需求調整掃描行為

適用場景

  • CTF 競賽的初期偵察
  • 滲透測試的資訊收集階段
  • 紅隊演練的目標探測
  • 漏洞賞金計畫的自動化掃描

相依套件說明

在安裝 AutoRecon 之前,需要安裝多個相依套件,以下說明各套件的用途:

套件用途說明
nmap網路探索與安全掃描的核心工具,用於端口掃描與服務識別
gobuster目錄與檔案暴力破解工具,用於 Web 應用程式偵察
feroxbuster高效能目錄掃描工具,Rust 語言開發,速度極快
niktoWeb 伺服器漏洞掃描器,檢測已知漏洞與配置問題
whatwebWeb 技術識別工具,辨識網站使用的技術堆疊
sslscanSSL/TLS 設定分析工具,檢測加密配置問題
enum4linuxSMB/Samba 列舉工具,收集 Windows/Samba 系統資訊
smbclientSMB 協定客戶端,用於存取 Windows 共享資源
smbmapSMB 共享資源列舉工具,檢視可存取的共享目錄
nbtscanNetBIOS 名稱掃描工具,探測區域網路內的 Windows 主機
snmpSNMP 協定工具集,用於收集網路設備資訊
onesixtyone快速 SNMP 掃描工具,用於暴力破解 community string
dnsreconDNS 偵察工具,執行區域傳送、子網域列舉等
sipviciousVoIP/SIP 安全測試工具套件
oscannerOracle 資料庫掃描工具
tnscmd10gOracle TNS 服務探測工具
redis-toolsRedis 資料庫操作工具
wkhtmltopdfHTML 轉 PDF 工具,用於產生報告
SecLists常用字典檔集合,包含密碼、目錄、子網域等清單
impacketPython 網路協定工具集,支援多種 Windows 協定

安裝步驟

步驟一:安裝基礎套件

1
2
3
# 安裝 Git 與 Python 環境
sudo apt update
sudo apt install git python3 python3-pip python3-venv -y

步驟二:安裝 Feroxbuster

1
2
# 使用 Snap 安裝高效能目錄掃描工具
sudo snap install feroxbuster

步驟三:安裝 SecLists 字典檔

1
2
3
4
5
6
# 下載並安裝滲透測試常用字典檔
cd ~
wget -c https://github.com/danielmiessler/SecLists/archive/master.zip -O SecList.zip
unzip SecList.zip
rm -f SecList.zip
sudo mv ./SecLists-master/ /usr/share/seclists/

步驟四:安裝 enum4linux

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 下載 enum4linux
cd /usr/share/
sudo git clone https://github.com/CiscoCXSecurity/enum4linux.git

# 建立執行腳本
sudo tee /usr/bin/enum4linux > /dev/null << 'EOF'
#!/bin/bash
cd /usr/share/enum4linux/ && ./enum4linux.pl "$@"
EOF

# 設定執行權限
sudo chmod +x /usr/bin/enum4linux

步驟五:安裝 Impacket

1
sudo apt install python3-impacket -y

步驟六:安裝 Oracle Scanner

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# 下載 oscanner
cd /usr/share/
sudo git clone https://gitlab.com/kalilinux/packages/oscanner.git

# 建立執行腳本
sudo tee /usr/bin/oscanner > /dev/null << 'EOF'
#!/bin/bash
cd /usr/share/oscanner/ && ./oscanner.sh "$@"
EOF

# 設定執行權限
sudo chmod +x /usr/bin/oscanner

# 安裝 Java 運行環境(oscanner 需要)
sudo apt-get install default-jre -y

步驟七:安裝 tnscmd10g

1
2
sudo wget http://www.red-database-security.com/scripts/tnscmd10g.pl.txt -O /usr/bin/tnscmd10g
sudo chmod +x /usr/bin/tnscmd10g

步驟八:安裝其他掃描工具

1
2
sudo apt install curl dnsrecon gobuster nbtscan nikto nmap onesixtyone \
    redis-tools smbclient smbmap snmp sslscan sipvicious whatweb wkhtmltopdf -y

步驟九:使用 pipx 安裝 AutoRecon

1
2
3
4
5
6
7
8
9
# 安裝 pipx(Python 應用程式管理工具)
python3 -m pip install --user pipx
python3 -m pipx ensurepath

# 重新載入環境變數
source ~/.bashrc

# 透過 pipx 安裝 AutoRecon
pipx install git+https://github.com/Tib3rius/AutoRecon.git

使用方式

基本用法

1
2
3
4
5
6
7
8
# 掃描單一目標
sudo $(which autorecon) 192.168.1.100

# 掃描多個目標
sudo $(which autorecon) 192.168.1.100 192.168.1.101 192.168.1.102

# 從檔案讀取目標清單
sudo $(which autorecon) -t targets.txt

常用參數

參數說明
-t, --target-file指定包含目標 IP/網域的檔案
-o, --output指定輸出目錄(預設為 results
-ct, --concurrent-targets同時掃描的目標數量(預設為 5)
-cs, --concurrent-scans每個目標同時執行的掃描數量(預設為 10)
--ports指定要掃描的端口(如 --ports 80,443,8080
--heartbeat定期顯示掃描進度(秒)
-v, --verbose顯示詳細輸出
--nmap傳遞額外參數給 Nmap
--nmap-append附加參數到預設 Nmap 指令
--only-scans-dir只建立 scans 目錄,不建立其他目錄
--single-target不建立目標子目錄

進階使用範例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# 限制同時掃描 3 個目標,每個目標最多 5 個並行掃描
sudo $(which autorecon) -ct 3 -cs 5 192.168.1.0/24

# 只掃描特定端口
sudo $(which autorecon) --ports 22,80,443,8080 192.168.1.100

# 指定輸出目錄並顯示詳細資訊
sudo $(which autorecon) -o /tmp/scan_results -v 192.168.1.100

# 每 60 秒顯示一次掃描進度
sudo $(which autorecon) --heartbeat 60 192.168.1.100

# 傳遞額外的 Nmap 參數(如使用特定腳本)
sudo $(which autorecon) --nmap-append="--script vuln" 192.168.1.100

輸出結果說明

AutoRecon 會在輸出目錄中建立結構化的目錄結構:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
results/
└── 192.168.1.100/
    ├── exploit/          # 可能的漏洞利用相關資訊
    ├── loot/             # 收集到的敏感資料(密碼、金鑰等)
    ├── report/           # 掃描報告
    │   ├── local.txt     # 本地資訊彙整
    │   ├── notes.txt     # 手動筆記
    │   └── proof.txt     # 滲透成功證據
    └── scans/            # 所有掃描結果
        ├── _commands.log         # 執行的指令記錄
        ├── _manual_commands.txt  # 建議手動執行的指令
        ├── xml/                  # Nmap XML 輸出
        ├── tcp80/                # HTTP 服務掃描結果
        │   ├── tcp_80_http_gobuster.txt
        │   ├── tcp_80_http_nikto.txt
        │   └── tcp_80_http_whatweb.txt
        ├── tcp443/               # HTTPS 服務掃描結果
        └── ...                   # 其他服務掃描結果

重要檔案說明

  • _commands.log:記錄所有自動執行的掃描指令,方便追蹤與重現
  • _manual_commands.txt:AutoRecon 建議的手動執行指令,通常是需要互動或較耗時的操作
  • xml/:包含 Nmap 的 XML 格式輸出,可匯入其他工具進行分析

自訂掃描設定

AutoRecon 支援透過 TOML 格式的設定檔自訂掃描行為。

設定檔位置

1
2
3
4
5
# 預設設定檔位置
~/.config/AutoRecon/config.toml

# 服務掃描設定
~/.config/AutoRecon/service-scans/

建立自訂設定

1
2
3
# 複製預設設定檔
mkdir -p ~/.config/AutoRecon
autorecon --copy-configs ~/.config/AutoRecon/

自訂服務掃描範例

建立 ~/.config/AutoRecon/service-scans/custom-http.toml

1
2
3
4
5
6
[custom-http]
service-names = ['http', 'https', 'ssl/http', 'ssl/https']

    [[custom-http.scan]]
    name = 'custom-dirb'
    command = 'dirb {scheme}://{address}:{port}/ /usr/share/seclists/Discovery/Web-Content/common.txt -o {scandir}/{protocol}_{port}_dirb.txt'

修改 Nmap 掃描設定

編輯 ~/.config/AutoRecon/port-scans/default.toml 可調整 Nmap 掃描參數:

1
2
3
4
[default]
    [[default.scan]]
    name = 'nmap-top-20-tcp'
    command = 'nmap -vv --reason -Pn -sV -sC --top-ports 20 {address}'

效能優化建議

1. 調整並行數量

根據系統資源調整並行參數,避免資源耗盡:

1
2
3
4
5
# 低配置系統(2 核心 / 4GB RAM)
sudo $(which autorecon) -ct 2 -cs 5 target

# 高配置系統(8 核心 / 16GB RAM)
sudo $(which autorecon) -ct 10 -cs 20 target

2. 限制掃描範圍

針對已知目標進行精確掃描:

1
2
# 只掃描常見 Web 端口
sudo $(which autorecon) --ports 80,443,8080,8443 target

3. 使用 SSD 儲存

將輸出目錄設定在 SSD 上,可大幅提升檔案寫入效能:

1
sudo $(which autorecon) -o /mnt/ssd/scan_results target

4. 排除不需要的掃描

透過設定檔停用不需要的掃描工具,減少執行時間:

1
2
3
# 在設定檔中設定
[options]
exclude-scans = ['feroxbuster', 'gobuster-medium']

5. 網路頻寬考量

在頻寬受限的環境中,降低並行數量以避免網路壅塞:

1
sudo $(which autorecon) -ct 1 -cs 3 --nmap-append="-T3" target

常見問題排除

問題一:autorecon 指令找不到

症狀:執行 autorecon 時顯示 command not found

解決方案

1
2
3
4
5
6
7
8
# 確認 pipx 路徑已加入 PATH
source ~/.bashrc

# 或直接指定完整路徑
~/.local/bin/autorecon

# 檢查安裝狀態
pipx list | grep autorecon

問題二:需要 root 權限

症狀:執行時顯示需要 root 權限進行 SYN 掃描

解決方案

1
2
3
4
5
# 方法一:保留 PATH 環境變數
sudo env "PATH=$PATH" autorecon target

# 方法二:使用 which 取得完整路徑
sudo $(which autorecon) target

問題三:某些工具未安裝

症狀:掃描過程中顯示某工具不存在

解決方案

1
2
3
4
5
# 檢查缺少的工具
which nikto gobuster nmap

# 安裝缺少的工具
sudo apt install <missing-tool>

問題四:掃描速度過慢

症狀:掃描大型網段時耗時過長

解決方案

1
2
3
4
5
6
7
8
# 使用快速掃描模式
sudo $(which autorecon) --nmap-append="-T4" target

# 限制端口範圍
sudo $(which autorecon) --ports top-100 target

# 增加並行數量(注意系統負載)
sudo $(which autorecon) -ct 10 -cs 20 target

問題五:記憶體不足

症狀:系統記憶體耗盡導致 OOM Killer 終止程序

解決方案

1
2
3
4
5
6
7
8
# 降低並行數量
sudo $(which autorecon) -ct 2 -cs 5 target

# 增加 swap 空間
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

問題六:SecLists 路徑錯誤

症狀:工具無法找到字典檔

解決方案

1
2
3
4
5
# 確認 SecLists 位置
ls /usr/share/seclists/

# 建立符號連結(如果位置不同)
sudo ln -s /path/to/SecLists /usr/share/seclists

安全注意事項

  1. 僅在授權範圍內使用:只對您有權限測試的目標執行掃描
  2. 了解法律責任:未經授權的掃描可能違反法律
  3. 控制掃描強度:在生產環境中使用較低的掃描強度,避免影響服務
  4. 保護掃描結果:掃描結果可能包含敏感資訊,妥善保管

後記:sudo 用法

由於 AutoRecon 透過 pipx 安裝在使用者目錄,使用 sudo 時需要特別處理:

方法一:保留 PATH 環境變數

1
sudo env "PATH=$PATH" autorecon target

方法二:使用 which 取得完整路徑

1
sudo $(which autorecon) target

方法三:建立全域符號連結

1
2
sudo ln -s ~/.local/bin/autorecon /usr/local/bin/autorecon
sudo autorecon target

參考資源

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy