From dc0efe389edbd8b32db5ae84acdb4bfb6c44b268 Mon Sep 17 00:00:00 2001 From: R3DDY97 Date: Tue, 21 Nov 2017 14:04:40 +0530 Subject: [PATCH 1/5] added uitls.socket for hostnames --- kickthemout.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kickthemout.py b/kickthemout.py index 5bb01cf..cdf7472 100644 --- a/kickthemout.py +++ b/kickthemout.py @@ -164,7 +164,9 @@ def kickoneoff(): if host[0] == onlineIPs[i]: mac = host[1] 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 = utils.socket.gethostbyaddr(onlineIPs[i])[0] + print(" [{0}" + str(i) + "{1}] {2}" + str(onlineIPs[i]) + "{3}\t" + vendor + " - " + hostname + "{4}" ).format(YELLOW, WHITE, RED, GREEN, END) + canBreak = False while not canBreak: @@ -228,7 +230,8 @@ def kicksomeoff(): if host[0] == onlineIPs[i]: mac = host[1] vendor = resolveMac(mac) - print(" [{0}" + str(i) + "{1}] {2}" + str(onlineIPs[i]) + "{3}\t" + vendor + "{4}").format(YELLOW, WHITE, RED, GREEN, END) + hostname = utils.socket.gethostbyaddr(onlineIPs[i])[0] + print(" [{0}" + str(i) + "{1}] {2}" + str(onlineIPs[i]) + "{3}\t" + vendor + " - " + hostname + "{4}" ).format(YELLOW, WHITE, RED, GREEN, END) canBreak = False while not canBreak: @@ -424,7 +427,7 @@ def main(): print( "\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) # display warning in case of no active hosts if len(hostsList) == 0 or len(hostsList) == 1: From 89fcd407339fb5288b5198b9d2604c802c55d493 Mon Sep 17 00:00:00 2001 From: R3DDY97 Date: Tue, 21 Nov 2017 14:12:20 +0530 Subject: [PATCH 2/5] added uitls.socket for hostnames --- kickthemout.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kickthemout.py b/kickthemout.py index cdf7472..ce9235c 100644 --- a/kickthemout.py +++ b/kickthemout.py @@ -165,8 +165,7 @@ def kickoneoff(): mac = host[1] vendor = resolveMac(mac) hostname = utils.socket.gethostbyaddr(onlineIPs[i])[0] - print(" [{0}" + str(i) + "{1}] {2}" + str(onlineIPs[i]) + "{3}\t" + vendor + " - " + hostname + "{4}" ).format(YELLOW, WHITE, RED, GREEN, END) - + 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 while not canBreak: From ecc77bba534b0ac7517bb556b4d2b277171e3462 Mon Sep 17 00:00:00 2001 From: R3DDY97 Date: Tue, 21 Nov 2017 14:14:24 +0530 Subject: [PATCH 3/5] fixed --- kickthemout.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kickthemout.py b/kickthemout.py index ce9235c..ff9edf8 100644 --- a/kickthemout.py +++ b/kickthemout.py @@ -165,7 +165,7 @@ def kickoneoff(): mac = host[1] vendor = resolveMac(mac) hostname = utils.socket.gethostbyaddr(onlineIPs[i])[0] - print(" [{0}" + str(i) + "{1}] {2}" + str(onlineIPs[i]) + "{3}\t" + mac + "{4}\t" + vendor + " - " + hostname "{5}").format(YELLOW, WHITE, RED, BLUE, GREEN, END) + 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 while not canBreak: From e0f72b9ba48c51dc0209c936889a5b17704d6643 Mon Sep 17 00:00:00 2001 From: R3DDY97 Date: Sat, 3 Feb 2018 18:00:24 +0530 Subject: [PATCH 4/5] hotname display --- kickthemout.py | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/kickthemout.py b/kickthemout.py index ff9edf8..4e2e07c 100644 --- a/kickthemout.py +++ b/kickthemout.py @@ -79,28 +79,28 @@ def runDebug(): try: print("Current defaultGatewayMac: " + defaultGatewayMac) except: - print ("Failed to print defaultGatewayMac...") + print("Failed to print defaultGatewayMac...") try: - print ("Reloading mac getter function...") + print("Reloading mac getter function...") regenOnlineIPs() print("Reloaded defaultGatewayMac: " + defaultGatewayMac) except: - print ("Failed to reload mac getter function / to print defaultGatewayMac...") + print("Failed to reload mac getter function / to print defaultGatewayMac...") try: - print ("Known gateway IP: " + defaultGatewayIP) + print("Known gateway IP: " + defaultGatewayIP) except: - print ("Failed to print defaultGatewayIP...") + print("Failed to print defaultGatewayIP...") try: - print ("Current hostslist array: ") - print hostsList + print("Current hostslist array: ") + print(hostsList) except: - print ("Failed to print hostsList array...") + print("Failed to print hostsList array...") try: - print ("Crash trace: ") + print("Crash trace: ") print(traceback.format_exc()) except: - print ("Failed to print crash trace...") - print ("DEBUG FINISHED.\nShutting down...") + print("Failed to print crash trace...") + print("DEBUG FINISHED.\nShutting down...") print("{0}").format(END) raise SystemExit @@ -145,12 +145,20 @@ def scanNetwork(): raise SystemExit 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 def kickoneoff(): os.system("clear||cls") - 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.flush() @@ -164,8 +172,8 @@ def kickoneoff(): if host[0] == onlineIPs[i]: mac = host[1] vendor = resolveMac(mac) - hostname = utils.socket.gethostbyaddr(onlineIPs[i])[0] - print(" [{0}" + str(i) + "{1}] {2}" + str(onlineIPs[i]) + "{3}\t" + mac + "{4}\t" + vendor + " - " + hostname + "{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 while not canBreak: @@ -216,7 +224,6 @@ def kickoneoff(): # kick multiple devices def kicksomeoff(): os.system("clear||cls") - 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.flush() @@ -229,8 +236,8 @@ def kicksomeoff(): if host[0] == onlineIPs[i]: mac = host[1] vendor = resolveMac(mac) - hostname = utils.socket.gethostbyaddr(onlineIPs[i])[0] - print(" [{0}" + str(i) + "{1}] {2}" + str(onlineIPs[i]) + "{3}\t" + vendor + " - " + hostname + "{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 while not canBreak: @@ -292,7 +299,6 @@ def kicksomeoff(): # kick all devices def kickalloff(): os.system("clear||cls") - 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.flush() @@ -305,7 +311,8 @@ def kickalloff(): if host[0] == onlineIPs[i]: mac = host[1] 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) try: @@ -473,6 +480,7 @@ def main(): '\nCatch ya later!{1}').format(GREEN, END) if __name__ == '__main__': + os.system("clear||cls") # configure appropriate network info sys.stdout.write("{0}Scanning your network, hang on...{1}\r".format(GREEN, END)) @@ -485,5 +493,4 @@ if __name__ == '__main__': # commence scanning process scanNetwork() - main() From 03e2b3055f345bd3ced7ea11f2929807891ae658 Mon Sep 17 00:00:00 2001 From: R3DDY97 Date: Sat, 3 Feb 2018 18:12:41 +0530 Subject: [PATCH 5/5] hotname display --- kickthemout.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kickthemout.py b/kickthemout.py index 4e2e07c..c83748c 100644 --- a/kickthemout.py +++ b/kickthemout.py @@ -151,7 +151,7 @@ def get_hostname(ip): except: pass if ip == utils.socket.getfqdn(ip): - hostname == 'N/A' + hostname = 'N/A' return hostname