-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathannihilator.sh
executable file
·162 lines (130 loc) · 4.3 KB
/
annihilator.sh
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
#!/bin/bash
set -e
. utils.sh
# import tools
for tool in $(ls tools/)
do
eval '. tools/$tool'
done
exit_msg()
{
printf '\nending annihator..\n'
exit
}
prompt()
{
# https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
RED='\033[0;31m'
GR='\033[0;32m'
NC='\033[0m'
printf "${RED}annihilator${GR}$1${NC}»$2"
}
declare -A net_conf
network_config()
{
printf 'Current network configuration is -\n'
i=1
while true; do
interface=$(echo $interfaces | cut -d ' ' -f $i)
ip=$(echo $ips | cut -d $' ' -f $i)
if [ -z $interface ];
then
break
else
net_conf[$interface]=$ip
fi
((i++))
done
table="Interface, IP\n$(for i in "${!net_conf[@]}"; do printf "%s,%s\n" $i ${net_conf[$i]}; done)"
printTable ',' "$table"
}
declare -A help
help['scan']="Scans the victim machine in a given interface."
help['list_ports']='Lists open ports of victim machine. (Victim ip - vip must be set (see set) for this to work.)'
help['set']='Sets the environment variables. Eg. usage - set vip 192.168.1.2'
help['var_config']='Displays the current variables set for annihilation.'
help['net_conf']='Displays systems ip on different interfaces.'
help['help']='Displays this help message.'
help['exit']='Exits Annihilator.'
trap exit_msg INT
#--------------------------------------------------------------------------------------------------#
declare -A global_vars
global_vars[vip]=''
global_vars[port]='80'
#--------------------------------------------------------------------------------------------------#
interfaces=$(ifconfig | awk '$1=="inet" {print f} {f=$1}' | sed 's/://g')
ips=$(ifconfig | awk '/inet /{print substr($2,1)}')
printWelcome
printf "Type 'help' to get a list of commands.\n"
network_config
#------------------------------------------Project-------------------------------------------------#
printf "Type 'list' to get list of existing projects or type a new project name.\n"
mkdir -p projects/
while true; do
current_subshell="(Enter project name.)"
prompt "$current_subshell"
read cmd
if [ -z "$cmd" ]; then
continue
elif [ "$cmd" = 'list' ]; then
printf "Existing projects are -\n"
for project in $(ls projects/)
do
printf "%s\n" $project
done
else
if [ -d "projects/$cmd" ]; then
printf "Using existing project %s\n" $cmd
else
mkdir -p projects/$cmd
printf "Created new project %s\n" projects/$cmd
fi
break
fi
done
current_subshell=''
#--------------------------------------------------------------------------------------------------#
while true ; do
prompt $current_subshell
read cmd
if [ -z "$cmd" ]; then
# continue, on receiving an empty command
continue
elif [ "$cmd" = 'var_config' ]; then
printf "Current variable configuratin.\n"
printTable ',' "$(for i in "${!global_vars[@]}"; do printf "%s,%s\n" $i ${global_vars[$i]}; done)"
elif [ "$cmd" = 'net_conf' ]; then
network_config
elif [ "$cmd" = 'list_ports' ]; then
if [ -z ${global_vars[vip]} ]; then
printf 'Victim IP (vip) not set.\n'
else
nmap -p- ${global_vars[vip]}
fi
elif [ $(echo $cmd | cut -d ' ' -f 1) = 'set' ]; then
# _set global_vars $cmd
var=$(echo $cmd | cut -d ' ' -f 2)
val=$(echo $cmd | cut -d ' ' -f 3)
if [ -z $var ] || [ -z $val ]; then
echo 'Invalid usage of set. See help'
else
global_vars[$var]=$val
fi
elif [ "$cmd" = 'help' ]; then
printf "These are the available commands.\n"
table="Command, Description\n""$(for i in "${!help[@]}";do echo "$i,${help[$i]}";done)"
printTable "," "$table"
elif [ "$cmd" = 'exit' ]; then
exit_msg
# test if _$cmd is not part of tools.
#elif [ ${cmd:0:1} != '_' ] ; then #&&
elif ! type $(echo "${cmd:1:${#cmd}}" | cut -d ' ' -f 1) >/dev/null 2>&1 ; then
echo $(echo "${cmd:1:${#cmd}}" | cut -d ' ' -f 1)
printf 'Unrecognised command. Type "help" for list of commands.\n'
#elif
else
#if i
${cmd:1:${#cmd}}
fi
done
exit_msg