Switch back to original Scapy (closes #409)

This commit is contained in:
k4m4 2019-10-06 16:35:23 -04:00
parent 9238b1bd88
commit de7d3e8ab5
3 changed files with 12 additions and 12 deletions

View File

@ -25,11 +25,11 @@ def shutdown():
'\nCatch ya later!{}'.format(GREEN, END)) '\nCatch ya later!{}'.format(GREEN, END))
os._exit(0) os._exit(0)
logging.getLogger("kamene.runtime").setLevel(logging.ERROR) # Shut up kamene! logging.getLogger("scapy.runtime").setLevel(logging.ERROR) # Shut up scapy!
try: try:
from kamene.config import conf from scapy.config import conf
conf.ipv6_enabled = False conf.ipv6_enabled = False
from kamene.all import * from scapy.all import *
import scan, spoof, nmap import scan, spoof, nmap
from urllib.request import urlopen, Request from urllib.request import urlopen, Request
from urllib.error import URLError from urllib.error import URLError
@ -143,15 +143,15 @@ def getDefaultInterface(returnNet=False):
raise ValueError("illegal netmask value", hex(arg)) raise ValueError("illegal netmask value", hex(arg))
return 32 - int(round(math.log(0xFFFFFFFF - arg, 2))) return 32 - int(round(math.log(0xFFFFFFFF - arg, 2)))
def to_CIDR_notation(bytes_network, bytes_netmask): def to_CIDR_notation(bytes_network, bytes_netmask):
network = kamene.utils.ltoa(bytes_network) network = scapy.utils.ltoa(bytes_network)
netmask = long2net(bytes_netmask) netmask = long2net(bytes_netmask)
net = "%s/%s" % (network, netmask) net = "%s/%s" % (network, netmask)
if netmask < 16: if netmask < 16:
return None return None
return net return net
iface_routes = [route for route in kamene.config.conf.route.routes if route[3] == kamene.config.conf.iface and route[1] != 0xFFFFFFFF] iface_routes = [route for route in scapy.config.conf.route.routes if route[3] == scapy.config.conf.iface and route[1] != 0xFFFFFFFF]
network, netmask, _, interface, address = max(iface_routes, key=lambda item:item[1]) network, netmask, _, interface, address, _ = max(iface_routes, key=lambda item:item[1])
net = to_CIDR_notation(network, netmask) net = to_CIDR_notation(network, netmask)
if net: if net:
if returnNet: if returnNet:
@ -174,7 +174,7 @@ def getDefaultInterfaceMAC():
else: else:
return defaultInterfaceMac return defaultInterfaceMac
except: except:
# request interface MAC address (after failed detection by kamene) # request interface MAC address (after failed detection by scapy)
print("\n{}ERROR: Default Interface MAC Address could not be obtained. Please enter MAC manually.{}\n".format(RED, END)) print("\n{}ERROR: Default Interface MAC Address could not be obtained. Please enter MAC manually.{}\n".format(RED, END))
header = ('{}kickthemout{}> {}Enter MAC Address {}(MM:MM:MM:SS:SS:SS): '.format(BLUE, WHITE, RED, END)) header = ('{}kickthemout{}> {}Enter MAC Address {}(MM:MM:MM:SS:SS:SS): '.format(BLUE, WHITE, RED, END))
return (input(header)) return (input(header))
@ -188,7 +188,7 @@ def getGatewayIP():
getGateway = sr1(IP(dst="github.com", ttl=0) / ICMP() / "XXXXXXXXXXX", verbose=False) getGateway = sr1(IP(dst="github.com", ttl=0) / ICMP() / "XXXXXXXXXXX", verbose=False)
return getGateway.src return getGateway.src
except: except:
# request gateway IP address (after failed detection by kamene) # request gateway IP address (after failed detection by scapy)
stopAnimation = True stopAnimation = True
print("\n{}ERROR: Gateway IP could not be obtained. Please enter IP manually.{}\n".format(RED, END)) print("\n{}ERROR: Gateway IP could not be obtained. Please enter IP manually.{}\n".format(RED, END))
header = ('{}kickthemout{}> {}Enter Gateway IP {}(e.g. 192.168.1.1): '.format(BLUE, WHITE, RED, END)) header = ('{}kickthemout{}> {}Enter Gateway IP {}(e.g. 192.168.1.1): '.format(BLUE, WHITE, RED, END))
@ -242,7 +242,7 @@ def regenOnlineIPs():
defaultGatewayMac = host[1] defaultGatewayMac = host[1]
if not defaultGatewayMacSet and defaultGatewayMac == "": if not defaultGatewayMacSet and defaultGatewayMac == "":
# request gateway MAC address (after failed detection by kamene) # request gateway MAC address (after failed detection by scapy)
print("\n{}ERROR: Default Gateway MAC Address could not be obtained. Please enter MAC manually.{}\n".format(RED, END)) print("\n{}ERROR: Default Gateway MAC Address could not be obtained. Please enter MAC manually.{}\n".format(RED, END))
header = ("{}kickthemout{}> {}Enter your gateway's MAC Address {}(MM:MM:MM:SS:SS:SS): ".format(BLUE, WHITE, RED, END)) header = ("{}kickthemout{}> {}Enter your gateway's MAC Address {}(MM:MM:MM:SS:SS:SS): ".format(BLUE, WHITE, RED, END))
defaultGatewayMac = input(header) defaultGatewayMac = input(header)

View File

@ -1,3 +1,3 @@
kamene scapy
python-nmap python-nmap
netifaces netifaces

View File

@ -8,8 +8,8 @@ See License at nikolaskama.me (https://nikolaskama.me/kickthemoutproject)
""" """
import sys, logging import sys, logging
logging.getLogger("kamene.runtime").setLevel(logging.ERROR) logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from kamene.all import ( from scapy.all import (
get_if_hwaddr, get_if_hwaddr,
getmacbyip, getmacbyip,
ARP, ARP,