-
Notifications
You must be signed in to change notification settings - Fork 199
Expand file tree
/
Copy pathkali-whoami
More file actions
245 lines (202 loc) · 7.7 KB
/
Copy pathkali-whoami
File metadata and controls
245 lines (202 loc) · 7.7 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#!/bin/bash
# Whoami | Coded by Ömer Doğan
#check source files
source /usr/share/kali-whoami/assets/sources/config 2> /dev/null || { clear;echo -e "\e[31m [-] FATAL ERROR: MAIN CONFIG COULD NOT BE SOURCED!\e[0m";exit 1;}
banner
# run with a root privilege
[ $UID != 0 ] && err "Whoami must be run as root. ${GREEN}'sudo $(basename ${0})'${RESET}"
src_check() {
check_status="1"
for i in $(seq 1 ${#}) ; do
if [ -f $SRCDIR/scripts/${@:i:1} ];then
source $SRCDIR/scripts/${@:i:1}
else
warn "The source file could not be found. Please re-install the tool. (Module: ${@:i:1})"
check_status="0"
fi
done
if [ "${check_status}" = "0" ] ; then
err "Please run this command:\n'${GREEN}git clone https://github.com/omer-dogan/kali-whoami && cd kali-whoami && sudo make reinstall${RESET}'"
fi
}
src_check fix log_killer ip_changer dns_changer mac_changer anti_cold_boot hostname_changer timezone_changer browser_anonymization
#check dependences function
dep_check() {
check_status="1"
for i in $(seq 1 ${#}) ; do
[ $(command -v ${@:i:1}) ] || { warn "${@:i:1}: could not be found." ; check_status="0" ; }
done
if [ "${check_status}" = "0" ] ; then
err "Please run this command: '${GREEN}sudo apt update && sudo apt install tar tor curl python3 python3-scapy network-manager${RESET}'"
fi
}
start(){
#check dependences
dep_check tar tor curl python3 scapy
#get a backup to fix it in case of a possible error
if [ ! -f $BACKUPDIR/whoami_fix_backups.tar.gz ]; then
get_backups
fi
options=("Anti Mitm" "Log killer" "Ip changer" "Dns changer" "Mac changer" "Timezone changer" "Hostname changer" "Browser anonymization" "Anti cold boot")
menu() {
info "Avaliable features:\n"
for opt in ${!options[@]}; do
printf "[%s] %s\n" $((opt+1)) "${options[opt]} ${choices[opt]}"
done
[[ "$stat" ]] && msg "$stat"; :
}
while banner && menu && input && read -r num && [[ "$num" ]]; do
[[ "$num" != *[![:digit:]]* ]] &&
(( num > 0 && num <= ${#options[@]} )) ||
{ stat="Invalid option: $num"; continue; }
((num--)); stat="${options[num]} was ${choices[num]:+un}checked"
[[ "${choices[num]}" ]] && choices[num]="" || choices[num]="✓"
done
banner
#detect selected features and run
for opt in ${!options[@]}; do
start_anti_mitm(){
python3 /usr/share/kali-whoami/assets/scripts/anti_mitm &
antimitmpid="$!"
sed -i 's/anti_mitm_pid="0"/anti_mitm_pid="'$antimitmpid'"/g;s/anti_mitm_status="Disable"/anti_mitm_status="Enable"/g' $SRCDIR/sources/config
info "Anti mitm successfully enabled"
}
for st in $(seq 0 $(( ${#options[@]} - 1 ))) ; do
if [[ "${choices[opt]}" ]] && [[ "${options[opt]}" == ${options[st]} ]]; then
$(echo start_${options[st]} | sed -e 's/ /_/g;s/\(.*\)/\L\1/;s/ı/i/g')
fi
done
done
}
stop(){
#detect enable features and stop
if $(cat $SRCDIR/sources/config | grep Enable &>/dev/null);then
options=("anti_mitm" "ip_changer" "dns_changer" "mac_changer" "timezone_changer" "hostname_changer" "browser_anonymization")
stop_anti_mitm(){
kill $anti_mitm_pid
sed -i 's/anti_mitm_pid="'$anti_mitm_pid'"/anti_mitm_pid="0"/g;s/anti_mitm_status="Enable"/anti_mitm_status="Disable"/g' $SRCDIR/sources/config
info "Anti mitm successfully disabled"
}
for st in $(seq 0 $(( ${#options[@]} - 1 ))) ; do
status="${options[st]}_status"
if [[ ${!status} == "Enable" ]] ; then
stop_${options[st]}
fi
done
else
err "No features are active. (Run to activate '${GREEN}sudo kali-whoami --start${RESET}')"
fi
}
# ---- runtime status helpers ----
is_active() { systemctl is-active --quiet "$1" 2>/dev/null; }
pid_alive() { [ -n "$1" ] && [ "$1" != "0" ] && kill -0 "$1" 2>/dev/null; }
file_exists() { [ -f "$1" ]; }
dir_exists() { [ -d "$1" ]; }
fmt() { printf "%-22s cfg:%-7s rt:%s\n" "$1" "$2" "$3"; }
status() {
msg "Kali Whoami status (configured + runtime checks)"
local ok="${GREEN}OK${RESET}"
local warn="${YELLOW}WARN${RESET}"
local rt tz
# Anti Mitm (checks PID is alive)
if [[ "$anti_mitm_status" == "Enable" ]]; then
pid_alive "$anti_mitm_pid" && rt="$ok" || rt="$warn (pid not running)"
else
pid_alive "$anti_mitm_pid" && rt="$warn (unexpected running)" || rt="$ok"
fi
fmt "Anti Mitm" "$anti_mitm_status" "$rt"
# IP changer (checks tor service + key backup)
if [[ "$ip_changer_status" == "Enable" ]]; then
is_active "tor.service" && rt="$ok" || rt="$warn (tor inactive)"
file_exists "$BACKUPDIR/iptables.rules.bak" || rt="$warn (missing backups)"
else
is_active "tor.service" && rt="$warn (tor active)" || rt="$ok"
fi
fmt "Ip changer" "$ip_changer_status" "$rt"
# DNS changer (backup file should exist while enabled)
if [[ "$dns_changer_status" == "Enable" ]]; then
file_exists "$BACKUPDIR/resolv.conf.bak" && rt="$ok" || rt="$warn (no resolv backup)"
else
file_exists "$BACKUPDIR/resolv.conf.bak" && rt="$warn (backup leftover)" || rt="$ok"
fi
fmt "Dns changer" "$dns_changer_status" "$rt"
# MAC changer (backup dir should exist while enabled)
if [[ "$mac_changer_status" == "Enable" ]]; then
dir_exists "$BACKUPDIR/mac_addresses" && rt="$ok" || rt="$warn (no mac backup dir)"
else
dir_exists "$BACKUPDIR/mac_addresses" && rt="$warn (backup leftover)" || rt="$ok"
fi
fmt "Mac changer" "$mac_changer_status" "$rt"
# Timezone changer (should be UTC + have backup)
if [[ "$timezone_changer_status" == "Enable" ]]; then
tz="$(timedatectl show -p Timezone --value 2>/dev/null)"
[[ "$tz" == "UTC" ]] && file_exists "$BACKUPDIR/timezone.bak" && rt="$ok" || rt="$warn (tz/backups mismatch)"
else
rt="$ok"
fi
fmt "Timezone changer" "$timezone_changer_status" "$rt"
# Hostname changer (backup file should exist while enabled)
if [[ "$hostname_changer_status" == "Enable" ]]; then
file_exists "$BACKUPDIR/hostname.bak" && rt="$ok" || rt="$warn (no hostname backup)"
else
rt="$ok"
fi
fmt "Hostname changer" "$hostname_changer_status" "$rt"
# Browser anonymization (checks whoami.js exists)
if [[ "$browser_anonymization_status" == "Enable" ]]; then
file_exists "/etc/firefox-esr/whoami.js" && rt="$ok" || rt="$warn (missing whoami.js)"
else
file_exists "/etc/firefox-esr/whoami.js" && rt="$warn (leftover whoami.js)" || rt="$ok"
fi
fmt "Browser anon" "$browser_anonymization_status" "$rt"
}
fix(){
#repair system with backups received for a possible bug
if [ -f $BACKUPDIR/whoami_fix_backups.tar.gz ]; then
restore_system
msg "System successfully repaired"
else
err "Whoami backup file not found"
fi
}
help() {
msg "Usage : sudo kali-whoami ${GREEN}[option]${RESET}
${GREEN}--start :${RESET} It will make backups and start the program.
${GREEN}--stop :${RESET} Closes the program using a backup.
${GREEN}--status :${RESET} Provides information about IP address and working status.
${GREEN}--fix :${RESET} Used to repair the system in case of a possible bug.
${GREEN}--help :${RESET} This shows the menu."
}
main() {
if [[ "$#" -eq 0 ]]; then
warn "Whoami: Argument required"
info "Run ${GREEN}'kali-whoami --help'${RESET} for more information."
exit 1
fi
case "$1" in
--[sS][tT][aA][rR][tT]|-[sS][tT])
start
;;
--[sS][tT][oO][pP]|-[sS][pP])
stop
;;
--[sS][tT][aA][tT][uU][sS]|-[sS][sS])
status
;;
--[fF][iI][xX]|-[fF])
fix
;;
--[hH][eE][lL][pP]|-[hH])
help
exit 1
;;
*)
warn "Whoami: Invalid option ${RED}'$1'${RESET}"
info "Run ${GREEN}'kali-whomai --help'${RESET} parameter for more information."
exit 1
;;
esac
}
# call main
main "${@}"
# EOF