This repository has been archived by the owner on Jan 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjet-tools
212 lines (166 loc) · 8.05 KB
/
jet-tools
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
#!/bin/bash
#
# Jet-Tools by noam alum
#
## Functions
function get_user_input {
var_name=$1
var_type=$2
shift 2 # Shift the arguments to access the remaining ones
# Join the remaining arguments to form the complete prompt
prompt="$*"
read -p " - $prompt" $var_name < /dev/tty
while [ -z "${!var_name}" ]; do
read -p " - $prompt" $var_name < /dev/tty
done
if [ "$var_type" == "INT" ]; then
while ! [[ ${!var_name} =~ ^[0-9]+$ ]]; do
echo " - Insert an integer!"
read -p " - $prompt" $var_name < /dev/tty
done
elif [ "$var_type" == "STR" ]; then
while [[ -n "${!var_name}" && "${!var_name}" =~ ^[0-9]+$ ]]; do
echo " - Insert a string!"
read -p " - $prompt" $var_name < /dev/tty
done
fi
export $var_name
}
function get_input {
echo -e "$(for ((i = 0; i < ${#Tools[@]}; i++)); do echo "$(( $i + 1)).${Tools[$i]}" | tr -s " " "_" && [ $(( $i + 1 )) != ${#Tools[@]} ] && echo "|"; done | xargs)\n$1\n$1"
[ -z $1 ] && read -p "- Which tool do you want to use? : " tool_id < /dev/tty || tool_id="$1"
while [ -z "$tool_id" ]; do
get_input
done
while [ $tool_id -gt ${#Tools[@]} ] || [ $tool_id -lt 0 ] || ! [[ $tool_id =~ ^[0-9]+$ ]]; do
echo -e "\033[0;31mYou can't use $tool_id, it does not exist or is not a valid integer!\033[0m"
get_input
done
}
# 1 - imunify_malicious_list
function imunify_malicious_list {
[ -z "$1" ] && get_user_input iml_user STR "Which user where you scanning? : " || iml_user="$1"
[ -z "$2" ] && get_user_input iml_files INT "How manny infected files found? : " || iml_files="$2"
imunify360-agent malware malicious list --user $iml_user --limit $iml_files | awk '{print $8}' | tail -n +2 > /home/$iml_user/infected_files_$iml_user.txt
chown $iml_user.$iml_user /home/$iml_user/infected_files_$iml_user.txt
echo " - infected files list was created in /home/$iml_user/infected_files_$iml_user.txt"
}
# 2 - Alter tables
function Alter_tables {
[ -z "$1" ] && get_user_input at_DB_USER STR "What is the user associate with the DataBase in question? : " || at_DB_USER="$1"
[ -z "$2" ] && get_user_input at_DB_PASS STR "What is the users password? : " || at_DB_PASS="$2"
[ -z "$3" ] && get_user_input at_DB_NAME STR "What is the DataBase name? : " || at_DB_NAME="$3"
[ -z "$4" ] && get_user_input at_TYPE STR "Do you want to swap to InnoDB or MyISAM? : " || at_TYPE="$4"
while [ "$at_TYPE" != "InnoDB" ] && [ "$at_TYPE" != "MyISAM" ];do
echo -e " - \033[0;31mPlease use InnoDB or MyISAM !\033[0m (case sensitive)"
get_user_input at_TYPE STR "Do you want to swap to InnoDB or MyISAM? : "
done
curl -Ls alum.sh/codes/alter-table|bash -s $at_DB_USER $at_DB_PASS $at_DB_NAME $at_TYPE InnoDB/MyISAM
}
# 3 - WordPress related
function WordPress_related {
## WC functions
function WordPress_migration {
echo "- WordPress migration"
wget -q https://alum.sh/files/WPM_sZadN1_w.sh && chmod +x WPM_sZadN1_w.sh
echo " run: \"./WPM_sZadN1_w.sh\""
}
function Add_user {
echo "- Add user"
[ -z "$1" ] && get_user_input wc_user STR " What is the new users username? : " || wc_user="$1"
[ -z "$2" ] && get_user_input wc_mail STR " What is the new users mail? : " || wc_mail="$2"
wp user create $wc_user $wc_mail --role=administrator --allow-root --skip-plugins
}
function Change_password {
echo "- Change password"
[ -z "$1" ] && get_user_input wc_user STR " What is the users username? : " || wc_user="$1"
[ -z "$2" ] && get_user_input wc_pass STR " What is the new password? : " || wc_pass="$2"
wp user update $wc_user --user_pass="$wc_pass" --allow-root --skip-plugins
}
function Set_root_priv {
echo "- Set root priv"
[ -z "$1" ] && get_user_input wc_user STR " What is the users username? : " || wc_user="$1"
wp user update $wc_user --role=administrator --allow-root --skip-plugins
}
function wp_recovery {
echo "- wp recovery"
curl -Ls 'alum.sh/wp_recovery'|bash
}
## WC functions
## Define Commands
wc_Commands=("Add user" "Change password" "Set root priv" "WordPress migration" "wp_recovery")
function wc_get_input {
echo -e "$(for ((i = 0; i < ${#wc_Commands[@]}; i++)); do echo "$(( $i + 1)).${wc_Commands[$i]}" | tr -s " " "_" && [ $(( $i + 1 )) -ne ${#wc_Commands[@]} ] && echo "|"; done | xargs)\n"
[ -z "$1" ] && read -p "- Which tool do you want to use? : " wc_Command_id < /dev/tty || wc_Command_id="$1"
while [ -z "$wc_Command_id" ]; do
wc_get_input
done
while [ $wc_Command_id -gt ${#wc_Commands[@]} ] || [ $wc_Command_id -lt 0 ] || ! [[ $wc_Command_id =~ ^[0-9]+$ ]]; do
echo -e "\033[0;31mYou can't use $wc_Command_id, it does not exist or is not a valid integer!\033[0m"
wc_get_input
done
}
wc_get_input "$1"
wc_Command_id=$(( $wc_Command_id - 1 ))
## Define commands
## Call command
wc_command_function="$(echo "${wc_Commands[$wc_Command_id]}" | tr -s " " "_"})"
shift 1
$wc_command_function "$1" "$2" "$3" "$4"
## Call command
}
# 4 - Running proc
function Running_proc {
[ -z "$1" ] && get_user_input rp_user STR "What is the user you want to check? : " || rp_user="$1"
watch -t "ps -u $rp_user | tail -n +2 | cat -n"
}
# 5 - litespeed data domains
function litespeed_data_domains {
[ -z "$1" ] && get_user_input dom_name STR "What domain would you like to search for? : " || dom_name="$1"
VH_users=($(grep -rlo $dom_name /usr/local/lsws/conf/ | grep -v '.bak\|httpd_config' | awk -F '/usr/local/lsws/conf/' {'print $2'} | awk -F '.xml' {'print $1'}))
for ((i=0; i<${#VH_users[@]}; i++))
do
VH_roots+=($(cat /usr/local/lsws/conf/httpd_config.xml | sed -n "/<name>${VH_users[$i]}<\/name>/,/<\/vhRoot>/ s/.*<vhRoot>\([^<]*\)<\/vhRoot>.*/\1/p" | sed "s/\$VH_NAME\//${VH_users[$i]}/g"))
DOC_roots+=($(awk -F'<docRoot>\\$VH_ROOT|</docRoot>' 'NF>1{print $2}' /usr/local/lsws/conf/${VH_users[$i]}.xml))
echo -e "\n$(( 1 + $i)). User: ${VH_users[$i]}\n Root directory: ${VH_roots[$i]}${DOC_roots[$i]}\n Domains: \n$(sed -n "/<vhost>${VH_users[$i]}<\/vhost>/,/<domain>/s/.*<domain>\(.*\)<\/domain>.*/\1/p" /usr/local/lsws/conf/httpd_config.xml | sort -u | xargs -n 1 | cat -n)\n"
done
}
# 6 - download data
function download_data {
[ -z "$1" ] && get_user_input download_url STR "What is the download url? : " || download_url="$1"
[ -z "$2" ] && get_user_input file_name STR "What would you like to name your file? : " || file_name="$2"
# check status code
status_code="$(curl -s -I -o /dev/null -w "%{http_code}" "$download_url")"
if [ "$(echo "$status_code" | cut -c 1)" -eq "3" ] || [ "$(echo "$status_code" | cut -c 1)" -eq "2" ]; then
wget -O "$file_name" --no-check-certificate --quiet "$download_url"
if [ "$?" -eq 0 ]; then
echo -e " - File downloaded at: $(pwd)/$file_name"
file_type="$(file $file_name | awk -F ':|,' '{print $2}')"
file_extension="$(echo $file_name | awk -F '.' '{print $2}')"
detected_file_extension="$(file --extension $file_name | awk {'print $2'})"
if [ "$file_extension" != "$detected_file_extension" ] && [ "???" != "$detected_file_extension" ];then
echo -e " - File extension mismatch:\n + detected extension: $detected_file_extension\n + inputted extension: $file_extension\n + File type detected: $file_type"
elif [ "???" == "$detected_file_extension" ]; then
echo -e " - File extension could not be detected:\n + detected extension: $detected_file_extension\n + inputted extension: $file_extension\n + File type detected: $file_type"
fi
else
echo " - There was an error while downloading $file_name"
fi
else
echo " - URL is invalid (status code: $status_code), exiting."
exit 1
fi
}
## Functions
## Define tools
echo "Jet-Tools:"
Tools=("imunify malicious list" "Alter tables" "WordPress related" "Running proc" "litespeed data domains" "download data")
get_input $1
tool_id=$(( $tool_id - 1 ))
## Define tools
## Call tool
tool_function=$(echo "${Tools[$tool_id]}" | tr -s " " "_"})
echo -e "\n----\n$tool_function :"
shift 1
$tool_function "$1" "$2" "$3" "$4"
## Call tool