banner
lca

lca

真正的不自由,是在自己的心中设下牢笼。

如何快速信息收集

整理一些平常常用的信息收集小脚本

nmap 結合 mascan 識別存活主機#

nmap 用來識別存活,然後將輸出給 masscan,masscan 對存活 ip 的端口進行掃描,掃描完後通過對掃描結果過濾,輸出 ip的形式,然後通過 httpx 去進一步識別存活。

#nmap掃描存活
nmap -sn 172.29.130.0/24 > nmap-ip.txt
#獲取nmap掃描存活的ip
cat nmap-ip.txt | grep "repo" | cut -d " " -f6 | cut -d "(" -f2 | cut -d ")" -f1 > ip.txt
#masscan掃描端口
sudo masscan -iL ip.txt --rate 10000 -p1-65535 --only-open
#獲取masscan掃描結果中的ip
cat masscan-ip.txt | grep "tcp" | cut -d " " -f 4,6 | awk '{print $2,$1}'| tr " " ":" | cut -d "/" -f1 | cut -d ":" -f1 | sort -t "." -k4n | uniq > ip.txt
#獲取masscan掃描結果中的端口
cat masscan-ip.txt | grep "tcp" | cut -d " " -f 4,6 | awk '{print $2,$1}'| tr " " ":" | cut -d "/" -f1 | cut -d ":" -f2 | sort -n | uniq > port.txt
#即要端口,又要ip的話
cat m.txt | grep "tcp" | cut -d " " -f 4,6 | awk '{print $2,$1}'| tr " " ":" | cut -d "/" -f1 | cut -d ":" -f1,2 | sort -t "." -k4n | uniq

整理出 ip格式(192.168.1.1:8080)後可以使用其他工具掃描系統是否存活,通過 httpx 查看系統是否存活

格式大概這樣,就可以獲取完整的 url 了。

image.png

windows 下批量識別存活主機#

# windows下批量ping C段,識別存活
for /L %i IN (1,1,254) DO ping -w 2 -n 1 192.168.1.%i

ip 範圍生成#

# 192.168.1.1-192.168.1.254
# usage: 1 254 192.168.1.
for i in {$1..$2};do echo "$3"$i;done

向文本中批量追加特定內容#

如有一個文本,每行都有一個 ip,需要在每個 ip 前面加上 http 協議,變成http://ip,就需要批量在每行前面追加內容,用到的命令是 sed 命令,替換字符分別是 `$` 和 `^` 號,`$` 代表每行末尾,`^` 代表每行開頭。

# bash下,向文件的每行末尾添加特定的內容,此處是ip,例如:192.168.1.x,轉換後為192.168.1.0/24
cat ip.txt | sed 's/$/.0\/24/'
 
# bash下,向文件的每行開頭添加特定的內容,此處是ip,例如:192.168.1.5,轉換後為http://192.168.1.5
cat ip.txt | sed 's/^/http:\/\//'

獲取內網段所有網關 ip#

獲取內網段所有網關 ip,用來判斷 C 段是否存活

#A段
for i in {1..255};do for b in {1..255};do echo "10".$i.$b."1";done;done
 
#B段
for i in {16..31};do for b in {1..255};do echo "172".$i.$b."1";done;done
 
#C段
for i in {1.255};do echo "192.168".$i."1";done

從文件中提取 ip#

grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" file.txt

從文本中提取 url#

grep -E -o "https?://[a-zA-Z0-9./?=_-]*" file.txt

#從js文件中提取url
curl https://abc.com/file.js | grep -Eo "(http|https)://[a-zA-Z0-9/?=_=]*"*

從 apk 中提取 url#

參考:GitHub - ndelphit/apkurlgrep: Extract endpoints from APK files

apkurlgrep -a path/to/file.apk

子域名收集#

curl -s "https://rapiddns.io/subdomain/jxuspt.com?full=1#result" | grep "<td><a" | cut -d "/" -f3 | cut -d '"' -f1 | xargs -l2 | sed 's/#result//g' curl -s "https://rapiddns.io/subdomain/$1?full=1" | grep '<td>[a-z]' | cut -d "<" -f2 | cut -d ">" -f2 | grep -v http | sort

ssh key 搜索#

for key in ~/.ssh/*; do ssh-keygen -l -f "${key}"; done | uniq

查看 wifi 密碼#

netsh wlan show profile name ="WIFI_5G" 
netsh wlan show profile name ="WIFI_5G" key=clear

指紋識別小脚本#

根據前面的一些內容,可以寫一些 bash 脚本,方便一鍵查詢,下面的脚本目的是進行 masscan 掃描,然後 httpx 探測存活,kscan 和 observer_ward 掃描系統指紋。

結合.bash_profile 文件,只要輸入 mscan 11.11.11.11 即可開始掃描

image.png

#!/bin/bash

# masscan port scan 
#
#
echo -e "\033[31m 開始masscan端口掃描... \033[0m"
sudo masscan -p1-65535 $1 --rate 1000 > ./mport.txt
echo -e "\033[31m 開始httpx存活探測... \033[0m"
cat mport.txt | grep "tcp" | cut -d " " -f 4,6 | awk '{print $2,$1}'| tr " " ":" | cut -d "/" -f1 | cut -d ":" -f1,2  | httpx > mresult.txt
rm -rf ./mport.txt

echo -e "\033[31m kscan掃描中... \033[0m"
if [ -f "mresult.txt" ]; then
	kscan -t mresult.txt -o kscanresult.txt
fi

echo -e "\033[31m 指紋識別中... \033[0m"
if [ -f "kscanresult.txt" ]; then
	cat kscanresult.txt | grep -E "http:|https" | awk 'BEGIN {FS="  " } ; { print $1 }' | observer_ward --stdin
fi
rm -rf kscanresult.txt

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。