fixed os.* bugs

This commit is contained in:
DanMcInerney 2013-12-31 03:47:26 -05:00
parent 120c8b033a
commit 9e8a969caa

17
LANs.py
View file

@ -41,7 +41,6 @@ conf.checkIPaddr=0
from sys import exit from sys import exit
from threading import Thread from threading import Thread
import argparse import argparse
from os import geteuid, devnull
import signal import signal
from base64 import b64decode from base64 import b64decode
from subprocess import * from subprocess import *
@ -89,7 +88,7 @@ GR = '\033[37m' # gray
T = '\033[93m' # tan T = '\033[93m' # tan
logger = open('LANspy.log.txt', 'w+') logger = open('LANspy.log.txt', 'w+')
DN = open(devnull, 'w') DN = open(os.devnull, 'w')
class Spoof(): class Spoof():
def originalMAC(self, ip): def originalMAC(self, ip):
@ -912,18 +911,18 @@ def pcap_handler(args):
bad_args = [args.dnsspoof, args.beef, args.code, args.nmap, args.nmapaggressive, args.driftnet, args.interface] bad_args = [args.dnsspoof, args.beef, args.code, args.nmap, args.nmapaggressive, args.driftnet, args.interface]
for x in bad_args: for x in bad_args:
if x: if x:
sys.exit('[-] When reading from pcap file you may only include the following arguments: -v, -u, -p, -pcap [pcap filename], and -ip [victim IP address]') exit('[-] When reading from pcap file you may only include the following arguments: -v, -u, -p, -pcap [pcap filename], and -ip [victim IP address]')
if args.pcap: if args.pcap:
if args.ipaddress: if args.ipaddress:
victimIP = args.ipaddress victimIP = args.ipaddress
pcap = rdpcap(args.pcap) pcap = rdpcap(args.pcap)
for payload in pcap: for payload in pcap:
Parser(args).start(payload) Parser(args).start(payload)
sys.exit('[-] Finished parsing pcap file') exit('[-] Finished parsing pcap file')
else: else:
sys.exit('[-] Please include the following arguement when reading from a pcap file: -ip [target\'s IP address]') exit('[-] Please include the following arguement when reading from a pcap file: -ip [target\'s IP address]')
else: else:
sys.exit('[-] When reading from pcap file you may only include the following arguments: -v, -u, -p, -pcap [pcap filename], and -ip [victim IP address]') exit('[-] When reading from pcap file you may only include the following arguments: -v, -u, -p, -pcap [pcap filename], and -ip [victim IP address]')
# Main loop # Main loop
def main(args): def main(args):
@ -931,10 +930,10 @@ def main(args):
if args.pcap: if args.pcap:
pcap_handler(args) pcap_handler(args)
sys.exit('[-] Finished parsing pcap file') exit('[-] Finished parsing pcap file')
#Check if root #Check if root
if not geteuid()==0: if not os.geteuid()==0:
exit("\nPlease run as root\n") exit("\nPlease run as root\n")
#Find the gateway and interface #Find the gateway and interface
@ -1020,7 +1019,7 @@ 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:
sys.exit("[-] [arp -n] failed to give accurate router MAC address") exit("[-] [arp -n] failed to give accurate router MAC address")
if args.victimmac: if args.victimmac:
victimMAC = args.victimmac victimMAC = args.victimmac