a few hiccups
This commit is contained in:
parent
d4c31ce242
commit
9c5c1c0660
1 changed files with 23 additions and 23 deletions
46
ctiger.py
46
ctiger.py
|
@ -28,7 +28,7 @@ from getmac import get_mac_address
|
|||
# Import Faker.
|
||||
from faker import Faker
|
||||
# Import the WifiESSID class from Faker Wi-Fi ESSID.
|
||||
from faker_wifi_essid import WifiESSID
|
||||
# from faker_wifi_essid import WifiESSID
|
||||
# import scapy_ex
|
||||
# from scapy_ex import Dot11Elt
|
||||
from art.art import tprint
|
||||
|
@ -59,7 +59,7 @@ pc = Counter()
|
|||
# RadioTap, Dot11Deauth, Dot11FCS, EAPOL])
|
||||
|
||||
fake = Faker()
|
||||
fake.add_provider(WifiESSID)
|
||||
# fake.add_provider(WifiESSID)
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# ██████╗███████╗ ██████╗ ███████╗██████╗ ███████╗ ██████╗
|
||||
|
@ -235,7 +235,7 @@ def strainer(pkt) -> None:
|
|||
# ----------------------------------------------------------------
|
||||
class NetDev:
|
||||
def __init__(self) -> None:
|
||||
self.macaddr = fake.wifi_essid()
|
||||
self.macaddr = fake.mac_address()
|
||||
pge = Purge()
|
||||
self.name = pge.get_name()
|
||||
self.mon_crtd = str(self.name) + 'mon'
|
||||
|
@ -250,10 +250,10 @@ class NetDev:
|
|||
try:
|
||||
os.system(f'ip link set {self.name} up')
|
||||
os.system(f'iw dev {self.name} interface add {self.mon_crtd} type monitor')
|
||||
log.debug('Created ', self.mon_crtd)
|
||||
log.debug('Created ${0}'.format(self.mon_crtd))
|
||||
os.system(f'ip link set {self.mon_crtd} down')
|
||||
os.system(f'ip link set {self.mon_crtd} address {self.macaddr}')
|
||||
log.debug('Set device address to ', self.macaddr)
|
||||
log.debug('Set device address to ${0}'.format(self.macaddr))
|
||||
os.system(f'ip link set {self.mon_crtd} up')
|
||||
log.debug('Set device up')
|
||||
os.system('iw set reg US')
|
||||
|
@ -261,8 +261,7 @@ class NetDev:
|
|||
log.info('Device is fully configured and up')
|
||||
return True
|
||||
except os.error as e:
|
||||
log.debug('Failed to create ', self.mon_crtd, e)
|
||||
print('Creation of new monitor self.name failed:', e)
|
||||
log.debug('Failed to create '.format(self.name), e)
|
||||
sys.exit(1)
|
||||
|
||||
def switch_if(self) -> bool:
|
||||
|
@ -270,15 +269,15 @@ class NetDev:
|
|||
os.system(f'ip link set {self.name} down')
|
||||
log.debug('Set device down')
|
||||
os.system(f'ip link set {self.name} address {self.macaddr}')
|
||||
log.debug('Set device address to ', self.macaddr)
|
||||
log.debug('Set device address to ${0}'.format(self.macaddr))
|
||||
os.system(f'iw dev {self.name} set type monitor')
|
||||
log.debug(self.name, ' switched to monitor')
|
||||
log.debug('${0} switched to monitor'.format(self.name))
|
||||
os.system(f'ip link set {self.name} up')
|
||||
# (below) setting registry is known to cause issues.
|
||||
os.system('iw set reg US')
|
||||
log.debug('Set device registry to US')
|
||||
scapyconfig.iface = self.name
|
||||
log.info('Set scapy config self.name to: ', self.name)
|
||||
log.info('Set scapy config self.name to: ${0}'.format(self.name))
|
||||
log.info('Device is fully configured and up')
|
||||
return True
|
||||
except os.error as e:
|
||||
|
@ -298,8 +297,7 @@ class NetDev:
|
|||
Returns:
|
||||
str: The name of the created or switched monitor interface.
|
||||
"""
|
||||
log.debug('mac_address type: ', str(type(self.macaddr)))
|
||||
log.debug('mac_address: ', str(self.macaddr))
|
||||
log.debug('mac_address: ${0}'.format(self.macaddr))
|
||||
log.info('Starting monitor interface')
|
||||
if self.mon_type == 'create':
|
||||
self.create_if()
|
||||
|
@ -316,10 +314,10 @@ class NetDev:
|
|||
|
||||
def channel_runner(self, mon_if) -> None:
|
||||
log.info('Channel Runner NG started.')
|
||||
log.info('Preliminary channel list: ', str(self.channels))
|
||||
log.info('Preliminary channel list: ${0}'.format(self.channels))
|
||||
chanlist = self.channels.split(',')
|
||||
chlist = list(set(chanlist))
|
||||
log.info('Channel list: ', str(chlist))
|
||||
log.info('Channel list: ${0}'.format(chlist))
|
||||
chans = [int(chan) for chan in chlist]
|
||||
thread = threading.current_thread()
|
||||
print(f'name={thread.name}, daemon={thread.daemon}')
|
||||
|
@ -336,8 +334,7 @@ def signal_handler(signal, frame) -> None:
|
|||
log.info('Shutting down')
|
||||
df2w = Purge.get_df
|
||||
df2w.to_csv('ct_purge.csv')
|
||||
log.info('Saved results to: ',
|
||||
Purge.get_file)
|
||||
log.info('Saved results to: ${0}'.format('ct_purge.csv'))
|
||||
log.info('Going Down!!')
|
||||
sys.exit(0)
|
||||
|
||||
|
@ -355,7 +352,6 @@ class Purge:
|
|||
self.mon_type = kwargs.get('mon_type')
|
||||
self.valid_file = kwargs.get('valid_file')
|
||||
self.channels = kwargs.get('channels')
|
||||
log = get_log
|
||||
self.scan_df = DataFrame.get_df
|
||||
|
||||
def start_purge(self) -> None:
|
||||
|
@ -381,7 +377,7 @@ class Purge:
|
|||
print('Enter Ctrl+C TWICE to fully stop the script.')
|
||||
dev = NetDev()
|
||||
mon_if = dev.start_monitor()
|
||||
log.info('interface ', mon_if, ' is up and running.')
|
||||
log.info('interface ${0} is up and running.'.format(mon_if))
|
||||
# vfile = self.get_file()
|
||||
# log.info('We will be writing captured macs to ', str(self.valid_file))
|
||||
chop = asyncio.to_thread(dev.channel_runner(mon_if)) # type: ignore
|
||||
|
@ -629,15 +625,19 @@ class DataFrame:
|
|||
|
||||
def get_log():
|
||||
log_file = os.path.abspath('/var/log/ctiger.log')
|
||||
logging.basicConfig(filename=log_file, level=args.log_level,
|
||||
format='%(asctime)s %(levelname)s %(message)s')
|
||||
# logging.basicConfig(filename=log_file, level=args.log_level,
|
||||
# format='%(asctime)s %(levelname)s %(message)s')
|
||||
# create logger
|
||||
logging.getLogger("scapy.runtime").setLevel(logging.DEBUG)
|
||||
handler = logging.FileHandler(log_file, mode='a', encoding='utf-8')
|
||||
logging.getLogger("scapy.runtime").addHandler(handler)
|
||||
scapy_logger = logging.getLogger('scapy.runtime')
|
||||
global log
|
||||
log = logging.getLogger(__name__)
|
||||
scapy_logger.setLevel(logging.DEBUG)
|
||||
log.setLevel(logging.DEBUG)
|
||||
handler = logging.FileHandler(log_file, mode='a', encoding='utf-8')
|
||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
handler.setFormatter(formatter)
|
||||
scapy_logger.addHandler(handler)
|
||||
log.addHandler(handler)
|
||||
log.info('Started crouching tiger')
|
||||
log.info('Started logger...')
|
||||
return log
|
||||
|
|
Loading…
Reference in a new issue