Upgrade scapy to kamene

This commit is contained in:
Nikolaos Kamarinakis 2018-11-07 08:49:57 +02:00
parent 36b7035be0
commit 0f32988be7
5 changed files with 12 additions and 12 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -21,7 +21,7 @@
- **OS name & version**: <!-- Replace with os name & version --> - **OS name & version**: <!-- Replace with os name & version -->
- **Python version**: <!-- Replace with python version --> - **Python version**: <!-- Replace with python version -->
- **Scapy version**: <!-- Replace with scapy version --> - **Kamene version**: <!-- Replace with kamene version -->
- **Nmap version**: <!-- Replace with nmap version --> - **Nmap version**: <!-- Replace with nmap version -->
- **Link of [Gist](https://gist.github.com/)**: <!-- Please create a Gist with the response of a `$ sudo python -vvv kickthemout.py` verbosity command & paste the link here --> - **Link of [Gist](https://gist.github.com/)**: <!-- Please create a Gist with the response of a `$ sudo python -vvv kickthemout.py` verbosity command & paste the link here -->

View File

@ -25,11 +25,11 @@ def shutdown():
'\nCatch ya later!{}'.format(GREEN, END)) '\nCatch ya later!{}'.format(GREEN, END))
os._exit(1) os._exit(1)
logging.getLogger("scapy.runtime").setLevel(logging.ERROR) # Shut up scapy! logging.getLogger("kamene.runtime").setLevel(logging.ERROR) # Shut up kamene!
try: try:
from scapy.config import conf from kamene.config import conf
conf.ipv6_enabled = False conf.ipv6_enabled = False
from scapy.all import * from kamene.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,14 +143,14 @@ 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 = scapy.utils.ltoa(bytes_network) network = kamene.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 scapy.config.conf.route.routes if route[3] == scapy.config.conf.iface and route[1] != 0xFFFFFFFF] iface_routes = [route for route in kamene.config.conf.route.routes if route[3] == kamene.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:
@ -174,7 +174,7 @@ def getDefaultInterfaceMAC():
else: else:
return defaultInterfaceMac return defaultInterfaceMac
except: except:
# request interface MAC address (after failed detection by scapy) # request interface MAC address (after failed detection by kamene)
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 scapy) # request gateway IP address (after failed detection by kamene)
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 scapy) # request gateway MAC address (after failed detection by kamene)
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 @@
scapy-python3 kamene
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("scapy.runtime").setLevel(logging.ERROR) logging.getLogger("kamene.runtime").setLevel(logging.ERROR)
from scapy.all import ( from kamene.all import (
get_if_hwaddr, get_if_hwaddr,
getmacbyip, getmacbyip,
ARP, ARP,