Skip to content

Instantly share code, notes, and snippets.

@affandhia
Created August 19, 2018 22:42
Show Gist options
  • Save affandhia/39fa6ed1fce416b1abfb7df452f678dd to your computer and use it in GitHub Desktop.
Save affandhia/39fa6ed1fce416b1abfb7df452f678dd to your computer and use it in GitHub Desktop.
import requests
import re
import sys
import hashlib
LOGIN_URL = 'http://harun.net/login'
sess = requests.Session()
def isLoggedIn():
getPage = sess.get(LOGIN_URL)
return 'You are logged in' in getPage.text
def getPasswordSalt(htmlPage):
for line in htmlPage.split('\n'):
if "hexMD5" in line:
m = re.findall('\((.+)\)', line)[0].split(' + ')
# remove quote
for i, mac in enumerate(m):
m[i] = mac[1:-1]
return [m[0], m[-1]]
return []
def encodeStr(str):
return str.encode('utf-8')
def getHtml(mockOn=False):
if(mockOn):
return open('harundotnet.html', 'r', encoding='utf-8').read()
return sess.get(LOGIN_URL).text
def getParsedPassword(password):
pageHtml = getHtml()
[saltFirst, saltSecond] = getPasswordSalt(pageHtml)
combineStr = eval('u\'' + "{}{}{}".format(saltFirst, password, saltSecond) + '\'')
eCSTR = combineStr.encode('latin1')
m = hashlib.new('md5')
m.update(eCSTR)
return m.hexdigest()
def postLogin(username, password):
payload = {}
payload['username'] = username
payload['password'] = password
response = sess.post(LOGIN_URL, data=payload)
print(response.text)
return response
def main():
# line = "document.sendin.password.value = hexMD5('\117' + document.login.password.value + '\151\167\120\133\215\266\351\041\263\072\272\256\235\033\235\024');"
# if(not isLoggedIn()):
print(isLoggedIn())
parsePassword = getParsedPassword(sys.argv[2])
postLogin(sys.argv[1], parsePassword)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment