corrected log formatting

This commit is contained in:
anoduck 2023-10-21 16:28:51 -04:00
parent 32e30ea308
commit 4abfa99f06

View file

@ -249,10 +249,10 @@ class NetDev:
try:
os.system(f'ip link set {self.interface} up')
os.system(f'iw dev {self.interface} interface add {self.mon_crtd} type monitor')
log.debug('Created ${0}'.format(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 ${0}'.format(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')
@ -260,7 +260,7 @@ class NetDev:
log.info('Device is fully configured and up')
return True
except os.error as e:
log.debug('Failed to create ${0}'.format(self.interface), e)
log.debug('Failed to create {0}'.format(self.interface), e)
sys.exit(1)
def switch_if(self, interface, macaddress) -> bool:
@ -270,15 +270,15 @@ class NetDev:
os.system(f'ip link set {self.interface} down')
log.debug('Set device down')
os.system(f'ip link set {self.interface} address {self.macaddr}')
log.debug('Set device address to ${0}'.format(self.macaddr))
log.debug('Set device address to {0}'.format(self.macaddr))
# (below) setting registry is known to cause issues.
os.system('iw set reg US')
log.debug('Set device registry to US')
os.system(f'iw dev {self.interface} set type monitor')
log.debug('${0} switched to monitor'.format(self.interface))
log.debug('{0} switched to monitor'.format(self.interface))
os.system(f'ip link set {self.interface} up')
scapyconfig.iface = self.interface
log.info('Set scapy config self.name to: ${0}'.format(self.interface))
log.info('Set scapy config self.name to: {0}'.format(self.interface))
log.info('Device is fully configured and up')
return True
except os.error as e:
@ -301,8 +301,8 @@ class NetDev:
"""
macaddr = fake.mac_address()
self.macaddr = macaddr
log.debug('mac_address: ${0}'.format(self.macaddr))
log.debug('Monitor Type: ${0}'.format(self.mon_type))
log.debug('mac_address: {0}'.format(self.macaddr))
log.debug('Monitor Type: {0}'.format(self.mon_type))
log.info('Starting monitor interface')
self.interface = interface
self.mon_type = mon_type
@ -327,10 +327,10 @@ class NetDev:
self.mon_if = mon_if
self.channels = channels
log.info('Channel Runner NG started.')
log.info('Preliminary channel list: ${0}'.format(self.channels))
log.info('Preliminary channel list: {0}'.format(self.channels))
chanlist = self.channels.split(',')
chlist = list(set(chanlist))
log.info('Channel list: ${0}'.format(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}')
@ -345,7 +345,7 @@ def signal_handler(signal, frame) -> None:
print('You pressed Ctrl+C!')
log.info('Shutting down')
scan_df.to_csv('ct_purge.csv')
log.info('Saved results to: ${0}'.format('ct_purge.csv'))
log.info('Saved results to: {0}'.format('ct_purge.csv'))
log.info('Going Down!!')
sys.exit(0)
@ -381,7 +381,7 @@ class Purge(object):
# return self.channels
# def get_type(self):
# log.debug('Monitor Type: ${0}'.format(self.mon_type))
# log.debug('Monitor Type: {0}'.format(self.mon_type))
# return self.mon_type
# def get_name(self):
@ -399,20 +399,21 @@ class Purge(object):
ndev = NetDev(interface=self.interface, mon_type=self.mon_type)
mon_if = ndev.start_monitor(interface=self.interface,
mon_type=self.mon_type)
log.info('interface ${0} is up and running.'.format(mon_if))
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(ndev.channel_runner(mon_if, self.channels)) # type: ignore
chopper = asyncio.create_task(chop)
log.info('Channel runner started.')
await asyncio.sleep(0)
# await asyncio.sleep(0)
while True:
log.info('starting sniffer')
asniff = AsyncSniffer(iface=mon_if,
prn=strainer,
store=False, monitor=True)
asniff.start()
log.info('asniffer started')
if asniff.running:
log.info('asniffer started')
forever_wait = threading.Event()
forever_wait.wait()
@ -670,7 +671,7 @@ def process_args(args: argparse.Namespace) -> None:
log.info('Beginning Mac Purge')
#mon_dev, mon_type, valid_file, channels
#mon_dev, mon_type, valid_file, channels
log.debug('args: ${0}'.format(args))
log.debug('args: {0}'.format(args))
pge = Purge(interface=args.name,
mon_type=args.mon_type,
valid_file=args.valid_file,