Merge pull request #246 from R3DDY97/master

diaplay hostnames
This commit is contained in:
Nikolaos Kamarinakis 2018-02-03 18:56:51 +02:00 committed by GitHub
commit 0099733382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -79,28 +79,28 @@ def runDebug():
try: try:
print("Current defaultGatewayMac: " + defaultGatewayMac) print("Current defaultGatewayMac: " + defaultGatewayMac)
except: except:
print ("Failed to print defaultGatewayMac...") print("Failed to print defaultGatewayMac...")
try: try:
print ("Reloading mac getter function...") print("Reloading mac getter function...")
regenOnlineIPs() regenOnlineIPs()
print("Reloaded defaultGatewayMac: " + defaultGatewayMac) print("Reloaded defaultGatewayMac: " + defaultGatewayMac)
except: except:
print ("Failed to reload mac getter function / to print defaultGatewayMac...") print("Failed to reload mac getter function / to print defaultGatewayMac...")
try: try:
print ("Known gateway IP: " + defaultGatewayIP) print("Known gateway IP: " + defaultGatewayIP)
except: except:
print ("Failed to print defaultGatewayIP...") print("Failed to print defaultGatewayIP...")
try: try:
print ("Current hostslist array: ") print("Current hostslist array: ")
print hostsList print(hostsList)
except: except:
print ("Failed to print hostsList array...") print("Failed to print hostsList array...")
try: try:
print ("Crash trace: ") print("Crash trace: ")
print(traceback.format_exc()) print(traceback.format_exc())
except: except:
print ("Failed to print crash trace...") print("Failed to print crash trace...")
print ("DEBUG FINISHED.\nShutting down...") print("DEBUG FINISHED.\nShutting down...")
print("{0}").format(END) print("{0}").format(END)
raise SystemExit raise SystemExit
@ -145,12 +145,20 @@ def scanNetwork():
raise SystemExit raise SystemExit
regenOnlineIPs() regenOnlineIPs()
def get_hostname(ip):
try:
hostname = utils.socket.gethostbyaddr(ip)[0]
except:
pass
if ip == utils.socket.getfqdn(ip):
hostname = 'N/A'
return hostname
# kick one device # kick one device
def kickoneoff(): def kickoneoff():
os.system("clear||cls") os.system("clear||cls")
print("\n{0}kickONEOff{1} selected...{2}\n").format(RED, GREEN, END) print("\n{0}kickONEOff{1} selected...{2}\n").format(RED, GREEN, END)
sys.stdout.write("{0}Hang on...{1}\r".format(GREEN, END)) sys.stdout.write("{0}Hang on...{1}\r".format(GREEN, END))
sys.stdout.flush() sys.stdout.flush()
@ -164,7 +172,8 @@ def kickoneoff():
if host[0] == onlineIPs[i]: if host[0] == onlineIPs[i]:
mac = host[1] mac = host[1]
vendor = resolveMac(mac) vendor = resolveMac(mac)
print(" [{0}" + str(i) + "{1}] {2}" + str(onlineIPs[i]) + "{3}\t" + mac + "{4}\t" + vendor + "{5}").format(YELLOW, WHITE, RED, BLUE, GREEN, END) hostname = get_hostname(onlineIPs[i])
print(" [{0}" + str(i) + "{1}] {2}" + str(onlineIPs[i]) + "{3}\t" + mac + "{4}\t" + vendor + "(" + hostname + ")" + "{5}").format(YELLOW, WHITE, RED, BLUE, GREEN, END)
canBreak = False canBreak = False
while not canBreak: while not canBreak:
@ -215,7 +224,6 @@ def kickoneoff():
# kick multiple devices # kick multiple devices
def kicksomeoff(): def kicksomeoff():
os.system("clear||cls") os.system("clear||cls")
print("\n{0}kickSOMEOff{1} selected...{2}\n").format(RED, GREEN, END) print("\n{0}kickSOMEOff{1} selected...{2}\n").format(RED, GREEN, END)
sys.stdout.write("{0}Hang on...{1}\r".format(GREEN, END)) sys.stdout.write("{0}Hang on...{1}\r".format(GREEN, END))
sys.stdout.flush() sys.stdout.flush()
@ -228,7 +236,8 @@ def kicksomeoff():
if host[0] == onlineIPs[i]: if host[0] == onlineIPs[i]:
mac = host[1] mac = host[1]
vendor = resolveMac(mac) vendor = resolveMac(mac)
print(" [{0}" + str(i) + "{1}] {2}" + str(onlineIPs[i]) + "{3}\t" + vendor + "{4}").format(YELLOW, WHITE, RED, GREEN, END) hostname = get_hostname(onlineIPs[i])
print(" [{0}" + str(i) + "{1}] {2}" + str(onlineIPs[i]) + "{3}\t" + vendor + "(" + hostname + ")" + "{4}" ).format(YELLOW, WHITE, RED, GREEN, END)
canBreak = False canBreak = False
while not canBreak: while not canBreak:
@ -290,7 +299,6 @@ def kicksomeoff():
# kick all devices # kick all devices
def kickalloff(): def kickalloff():
os.system("clear||cls") os.system("clear||cls")
print("\n{0}kickALLOff{1} selected...{2}\n").format(RED, GREEN, END) print("\n{0}kickALLOff{1} selected...{2}\n").format(RED, GREEN, END)
sys.stdout.write("{0}Hang on...{1}\r".format(GREEN, END)) sys.stdout.write("{0}Hang on...{1}\r".format(GREEN, END))
sys.stdout.flush() sys.stdout.flush()
@ -303,7 +311,8 @@ def kickalloff():
if host[0] == onlineIPs[i]: if host[0] == onlineIPs[i]:
mac = host[1] mac = host[1]
vendor = resolveMac(mac) vendor = resolveMac(mac)
print(str(" {0}"+ str(onlineIPs[i]) + "{1}\t" + vendor + "{2}").format(RED, GREEN, END)) hostname = get_hostname(onlineIPs[i])
print(str(" {0}"+ str(onlineIPs[i]) + "{1}\t" + vendor + "(" + hostname + ")" + "{2}").format(RED, GREEN, END))
print("\n{0}Spoofing started... {1}").format(GREEN, END) print("\n{0}Spoofing started... {1}").format(GREEN, END)
try: try:
@ -424,7 +433,7 @@ def main():
print( print(
"\n{0}Using interface '{1}" + defaultInterface + "{2}' with mac address '{3}" + defaultInterfaceMac + "{4}'.\nGateway IP: '{5}" "\n{0}Using interface '{1}" + defaultInterface + "{2}' with mac address '{3}" + defaultInterfaceMac + "{4}'.\nGateway IP: '{5}"
+ defaultGatewayIP + "{6}' --> {7}" + str(len(hostsList)) + "{8} hosts are up.{9}").format(GREEN, RED, GREEN, RED, GREEN, + defaultGatewayIP + "{6}' --> {7}" + str(len(hostsList)) + "{8} hosts are up.{9}").format(GREEN, RED, GREEN, RED, GREEN,
RED, GREEN, RED, GREEN, END) RED, GREEN, RED, GREEN, END)
# display warning in case of no active hosts # display warning in case of no active hosts
if len(hostsList) == 0 or len(hostsList) == 1: if len(hostsList) == 0 or len(hostsList) == 1:
@ -471,6 +480,7 @@ def main():
'\nCatch ya later!{1}').format(GREEN, END) '\nCatch ya later!{1}').format(GREEN, END)
if __name__ == '__main__': if __name__ == '__main__':
os.system("clear||cls")
# configure appropriate network info # configure appropriate network info
sys.stdout.write("{0}Scanning your network, hang on...{1}\r".format(GREEN, END)) sys.stdout.write("{0}Scanning your network, hang on...{1}\r".format(GREEN, END))
@ -483,5 +493,4 @@ if __name__ == '__main__':
# commence scanning process # commence scanning process
scanNetwork() scanNetwork()
main() main()