|
| 1 | +import dshell |
| 2 | +import util |
| 3 | +from httpdecoder import HTTPDecoder |
| 4 | + |
| 5 | +class DshellDecoder(HTTPDecoder): |
| 6 | + ''' |
| 7 | + 15 April 2015 |
| 8 | +
|
| 9 | + Proof-of-concept code to detect attempts to enumerate MS15-034 vulnerable |
| 10 | + IIS servers and/or cause a denial of service. Each event will generate an |
| 11 | + alert that prints out the HTTP Request method and the range value contained |
| 12 | + with the HTTP stream. |
| 13 | +
|
| 14 | + Usage: |
| 15 | + decode -d ms15-034 -q *.pcap |
| 16 | + decode -d ms15-034 -i <interface> -q |
| 17 | +
|
| 18 | + References: |
| 19 | + https://technet.microsoft.com/library/security/ms15-034 |
| 20 | + https://ma.ttias.be/remote-code-execution-via-http-request-in-iis-on-windows/ |
| 21 | + ''' |
| 22 | + def __init__(self): |
| 23 | + HTTPDecoder.__init__(self, |
| 24 | + name='ms15-034', |
| 25 | + description='detect attempts to enumerate MS15-034 vulnerable IIS servers', |
| 26 | + longdescription=''' |
| 27 | +Proof-of-concept code to detect attempts to enumerate MS15-034 vulnerable |
| 28 | +IIS servers and/or cause a denial of service. Each event will generate an |
| 29 | +alert that prints out the HTTP Request method and the range value contained |
| 30 | +with the HTTP stream. |
| 31 | +
|
| 32 | +Usage: |
| 33 | +decode -d ms15-034 -q *.pcap |
| 34 | +decode -d ms15-034 -i <interface> -q |
| 35 | +''', |
| 36 | + filter='tcp and (port 80 or port 8080 or port 8000)', |
| 37 | + filterfn=lambda ((sip, sp), (dip, dp)): sp in ( |
| 38 | + 80, 8000, 8080) or dp in (80, 8000, 8080), |
| 39 | + author='bg', |
| 40 | + ) |
| 41 | + |
| 42 | + def HTTPHandler(self, conn, request, response, requesttime, responsetime): |
| 43 | + if response == None: # Denial of Service (no server response) |
| 44 | + try: |
| 45 | + rangestr = util.getHeader(request,'range') |
| 46 | + # check range value to reduce false positive rate |
| 47 | + if not rangestr.endswith('18446744073709551615'): return |
| 48 | + except: return |
| 49 | + self.alert('MS15-034 DoS [Request Method: "%s" URI: "%s" Range: "%s"]' % \ |
| 50 | + (request.method, request.uri, rangestr), conn.info()) |
| 51 | + |
| 52 | + else: # probing for vulnerable server |
| 53 | + try: |
| 54 | + rangestr = util.getHeader(request,'range') |
| 55 | + # check range value to reduce false positive rate |
| 56 | + if not rangestr.endswith('18446744073709551615'): return |
| 57 | + except: return |
| 58 | + |
| 59 | + # indication of vulnerable server |
| 60 | + if rangestr and (response.status == '416' or \ |
| 61 | + response.reason == 'Requested Range Not Satisfiable'): |
| 62 | + |
| 63 | + self.alert('MS15-034 Vulnerable Server [Request Method: "%s" Range: "%s"]' % |
| 64 | + (request.method,rangestr), conn.info()) |
| 65 | + |
| 66 | + if request.method != 'GET': # this could be interesting |
| 67 | + pass # waiting on more details |
| 68 | + |
| 69 | + |
| 70 | +if __name__ == '__main__': |
| 71 | + dObj = DshellDecoder() |
| 72 | + print dObj |
| 73 | +else: |
| 74 | + dObj = DshellDecoder() |
0 commit comments