diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..f3c0f4e Binary files /dev/null and b/.DS_Store differ diff --git a/kickthemout.py b/kickthemout.py index a0c21d1..1880698 100644 --- a/kickthemout.py +++ b/kickthemout.py @@ -10,6 +10,11 @@ See License at nikolaskama.me (https://nikolaskama.me/kickthemoutproject) import os, sys, logging, math, traceback, optparse, threading from time import sleep BLUE, RED, WHITE, YELLOW, MAGENTA, GREEN, END = '\33[94m', '\033[91m', '\33[97m', '\33[93m', '\033[1;35m', '\033[1;32m', '\033[0m' +NETFLAG=0 + +#NETFLAG=0 User have no access to internet +#NETFLAG=1 User have access to internet +#NETFLAG=2 User have no access to internet and choose to skip checkInternetConnection try: # check whether user is root @@ -125,13 +130,16 @@ def runDebug(): # try skip checkInternetConnection def trySkipCheckInternetConnection(): + global NETFLAG try: print("\n{}ERROR: It seems you have no access to internet, skip checking connection ?{}\n".format(RED, END)) header = ('{}kickthemout{}> {}(y/n): '.format(BLUE, WHITE, RED, END)) ans=input(header) if ans == "y": + NETFLAG=2 return True elif ans == "n": + NETFLAG=0 return False else: print("\n{}Invalid input.{}".format(RED, END)) @@ -143,8 +151,10 @@ def trySkipCheckInternetConnection(): # make sure there is an internet connection def checkInternetConnection(): + global NETFLAG try: urlopen('https://github.com', timeout=3) + NETFLAG=1 return True except URLError as err: trySkipCheckInternetConnection() @@ -228,19 +238,23 @@ def retrieveMACAddress(host): # resolve mac address of each vendor def resolveMac(mac): - try: - # send request to macvendors.co - url = "http://macvendors.co/api/vendorname/" - request = Request(url + mac, headers={'User-Agent': "API Browser"}) - response = urlopen(request) - vendor = response.read() - vendor = vendor.decode("utf-8") - vendor = vendor[:25] - return vendor - except KeyboardInterrupt: - shutdown() - except: - return "N/A" + global NETFLAG + if NETFLAG == 1: + try: + # send request to macvendors.co + url = "http://macvendors.co/api/vendorname/" + request = Request(url + mac, headers={'User-Agent': "API Browser"}) + response = urlopen(request) + vendor = response.read() + vendor = vendor.decode("utf-8") + vendor = vendor[:25] + return vendor + except KeyboardInterrupt: + shutdown() + except: + return "N/A" + elif NETFLAG == 2: + return "N/A"