Add bash file with functions to enable and disable monitor mode using either...
This commit is contained in:
55
code/kydcap/scripts/wifi_ctl.sh
Normal file
55
code/kydcap/scripts/wifi_ctl.sh
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
# Note, this is not my original work. Source: https://linuxtldr.com/changing-interface-mode/
|
||||
|
||||
function list_nic_info () {
|
||||
ip addr show
|
||||
}
|
||||
|
||||
function enable_monm_iw () {
|
||||
interface=$1
|
||||
sudo ip link set "$interface" down
|
||||
sudo iw "$interface" set monitor control
|
||||
sudo ip link set "$interface" up
|
||||
}
|
||||
|
||||
function disable_monm_iw () {
|
||||
interface=$1
|
||||
sudo ip link set "$interface" down
|
||||
sudo iw "$interface" set type managed
|
||||
sudo ip link set "$interface" up
|
||||
}
|
||||
|
||||
function enable_monm_iwconfig () {
|
||||
interface=$1
|
||||
sudo ifconfig "$interface" down
|
||||
sudo iwconfig "$interface" mode monitor
|
||||
sudo ifconfig "$interface" up
|
||||
}
|
||||
|
||||
function disable_monm_iwconfig () {
|
||||
interface=$1
|
||||
sudo ifconfig "$interface" down
|
||||
sudo iwconfig "$interface" mode managed
|
||||
sudo ifconfig "$interface" up
|
||||
}
|
||||
|
||||
function enable_monm_acng () {
|
||||
interface=$1
|
||||
sudo airmon-ng check
|
||||
sudo airmon-ng check kill
|
||||
sudo airmon-ng start "$interface"
|
||||
}
|
||||
|
||||
function disable_monm_acng () {
|
||||
interface="${1}mon"
|
||||
sudo airmon-ng stop "$interface"
|
||||
sudo systemctl restart NetworkManager
|
||||
}
|
||||
|
||||
if declare -f "$1" > /dev/null
|
||||
then
|
||||
"$@"
|
||||
else
|
||||
echo "Unknown function '$1'" >&2
|
||||
exit 1
|
||||
fi
|
||||
@@ -69,7 +69,7 @@ def handle_sniff(args):
|
||||
if not cwd_is_device_root_dir():
|
||||
handle_metadata()
|
||||
else:
|
||||
cmd = ['sudo tcpdump', '-i', args.capture_interface]
|
||||
cmd = ['sudo', 'tcpdump', '-i', args.capture_interface]
|
||||
if args.monitor_mode:
|
||||
cmd.append('-I')
|
||||
if args.no_name_resolution:
|
||||
@@ -83,8 +83,10 @@ def handle_sniff(args):
|
||||
cmd.append(str(args.count))
|
||||
elif args.mins:
|
||||
pass
|
||||
print('Executing: ' + ' '.join(cmd))
|
||||
print('Complete command:' + ' '.join(cmd))
|
||||
# TODO maybe dump this into file -> put into device metadata
|
||||
# TODO generate pcap filename
|
||||
# TODO construct capture metadata file
|
||||
try:
|
||||
start_time = datetime.now().strftime('%H:%M:%S')
|
||||
subprocess.run(cmd)
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
DEPENDENCIES =
|
||||
|
||||
def check_installed() -> bool:
|
||||
def check_installed(tool) -> bool:
|
||||
"""Check if tcpdump is installed and available on the system path."""
|
||||
return shutil.which('tcpdump') is not None
|
||||
return shutil.which(f'{tool}') is not None
|
||||
|
||||
|
||||
def ensure_installed():
|
||||
def ensure_installed(tool):
|
||||
"""Ensure that tcpdump is installed, raise an error if not."""
|
||||
if not check_installed():
|
||||
if not check_installed(tool):
|
||||
raise RuntimeError("tcpdump is not installed. Please install it to continue.")
|
||||
|
||||
|
||||
10
code/kydcap/utils/wifi_ctrl_utils.py
Normal file
10
code/kydcap/utils/wifi_ctrl_utils.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import subprocess
|
||||
|
||||
def enable_monitor_mode(interface):
|
||||
pass
|
||||
|
||||
def disable_monitor_mode(interface):
|
||||
pass
|
||||
|
||||
def get_ap_channel(interface):
|
||||
pass
|
||||
Reference in New Issue
Block a user