refactor(Structure): 🎨 More modularization

Continued work converting the script over to modules
This commit is contained in:
anoduck 2024-02-11 07:30:02 -05:00
parent b3570de4b0
commit ee344fb768
3 changed files with 23 additions and 18 deletions

View file

@ -8,6 +8,8 @@ import argparse
from art.art import tprint
from configobj import ConfigObj, validate
from .logging import Log
from .mac_purge import Purge
from .attack import Attack
config_file = os.path.abspath("/etc/ctiger/config.ini")
@ -47,7 +49,7 @@ class ProcArgs:
def __init__(self, args):
self.args = args
def process_args(self, args: argparse.Namespace) -> None:
def process_args(self, args: argparse.Namespace, ap) -> None:
"""
Processes the command line arguments.
@ -57,17 +59,18 @@ class ProcArgs:
Returns:
None
"""
self.log = Log(args.log_file)
self.log.info('Started crouching tiger')
self.log.info('Started logger...')
alog = Log()
log = alog.get_log(args.log_file)
log.info('Started crouching tiger')
log.info('Started logger...')
match args.module:
case "att":
log.info('Starting attack formation...')
proc_attack(interface=args.interface,
scan_file=args.scan_file,
mon_type=args.mon_type,
net_file=args.net_file,
log=log)
att = Attack()
att.attack(mondev=args.interface,
scan_file=args.scan_file,
net_file=args.net_file,
log=log)
case "mac":
log.info('Beginning Mac Purge')
#mon_dev, mon_type, valid_file, channels
@ -75,11 +78,12 @@ class ProcArgs:
log.debug('args: {0}'.format(args))
global valid_file
valid_file = args.valid_file
start_purge(interface=args.name,
mon_type=args.mon_type,
valid_file=args.valid_file,
channels=args.channels,
log=log)
purge = Purge()
purge.purge.mac_revealer(interface=args.name,
mon_type=args.mon_type,
valid_file=args.valid_file,
channels=args.channels,
log=log)
case _:
ap.print_help()
@ -201,11 +205,11 @@ class ProcArgs:
mac_parse.add_argument('-c', '--channels', dest='channels',
default=config['MAC_PURGE']['channel_list'],
help='A single or comma seperated list of channels.')
mac_parse.set_defaults(fun=start_purge)
mac_parse.set_defaults(fun=mac_revealer)
##################
# parse the args #
##################
ap.set_defaults(fun=process_args)
args = ap.parse_args(args=None if sys.argv[1:] else ['--help'])
self.process_args(args)
self.process_args(args, ap)

View file

@ -16,7 +16,7 @@ import os
import threading
class attack:
class Attack:
def sniff_stop(self, pkt):
global hndshk_frag

View file

@ -8,7 +8,8 @@ import os
class Log:
def __init__(self, log_file,):
def get_log(self, log_file,):
self.log_file = log_file
lev = 'debug'
rot = True