Socat Proxifier

Publicado por Perfil removido (última atualização em 23/04/2021)

[ Hits: 1.330 ]

Download socatp.sh




Apenas um script simples que usa socat e processos nativos do sistema para checar conexões de proxies e conectar a qualquer máquina em qualquer serviço "anonimamente", escrito da forma mais "portável" possível (aceito sugestões de adaptação btw. (:)

  



Esconder código-fonte

#!/bin/bash
# dummy script, thats all (:

#trap 'killall' INT
#killall() {
#   kill -TERM 0
#}
proxy_random() {
   proxycount=$(ls ~/.socatp/|grep proxy|wc -l)
   #while IFS= read -r proxycount || [[ -n "$proxycount" ]];do
   for((c=1;c<=$proxycount;c++));do
   
   ip_handler=$(cat ~/.socatp/proxy*|shuf|sed 's/[:]/ /g'|awk '{print $1}' >~/.socatp//ip)
   port_handler=$(cat ~/.socatp/proxy*|shuf|sed 's/[:]/ /g'|awk '{print $2}' >~/.socatp/port)
   
   ip=$(cat ~/.socatp/ip|head -n1)
   port=$(cat ~/.socatp/port|head -n1)
   
   printf "\e[32m$ip:$port\e[0m\n"
   socat STDIO PROXY:$ip:$b:$P,proxyport=$port
   printf "\n"
   done
}
help_msg() {
   printf "Use $0 -h for help.\n"
   exit 1
}
error() {
   printf "Something went wrong $(id -un).\n"
   exit 1
}
help() {
   printf "\t[OPTIONS]\n\
   -h/-v/-p/-b/-P <value>\n\
   -h: \t\t\t this.\n\
   -v: \t\t\t version.\n\
   -p[1-4]/-pR/-pC: \t a proxy choice, \"-pR\" implies on using a random proxy, \"-pC\" is a massive proxy connection checker (you must use \"-pC <file>\" before the random option).\n\
   -b <ip>: \t\t a target ip to connect to under proxy chosen.\n\
   -P <port>: \t\t a port for target service.\n
   [EXAMPLE]\n\
   $0 -p1 -b192.168.0.2 -P1337\n\
   $0 -b192.168.0.2 -P1337 -p1\n\
   $0 -P1337 -p1 -b192.168.0.2\n\
   $0 -pR -b192.168.0.2 -P1337 (random proxy)\n\
   $0 -b192.168.0.2 -P1337  \t  (not specifying \"-p (or -p*)\" will use a random proxy as well.
   $0 -pC proxylist.txt \t  (will be saved on \"~/.socatp/\" working proxies, at connection time it will automatically randomize proxies if needed.\n\n"

   exit 0
}   
version() {
   socat_v=$($socat -V|grep version|head -n1)
   printf "socatp (socat proxifier) version 1.2.4\n$socat: $socat_v\n\n"
   }
   
socat=$(which socat)


if [[ -z "$socat" ]];then
printf "Install socat first!\n"
exit 1
fi

while getopts ":p:b:P:hv" opt;do
    case "${opt}" in
    p)
    p=${OPTARG}
    ;;
    b)
    b=${OPTARG}
    ;;
    P)
    P=${OPTARG}
    ;;
    h)
    h=${OPTARG}
    help
    ;;
    v)
    v=${OPTARG}
    version
    ;;
    *)
    error
    ;;
    esac
done
shift $((OPTIND-1))

if [[ ! -z "$h" ]];then
help 
fi

if [[ "$p" == "C" && -z "$b" && -z "$P" ]];then
rp=(200)
proxycount=$(cat $1|wc -l)
socatp_dir="~/.socatp"

if [[ ! -d "$socatp_dir" ]];then 
printf "Checking socatp config dir...\n"
mkdir -p ~/.socatp/
fi

printf "Checking proxys...\n"
for((c=1;c<=$proxycount;c++));do
proxylist=$(cat $1|shuf|awk '{if(NR=='$c') print $0}')
request=$(curl -m2 -six $proxylist ifconfig.me|head -n1|grep -o 200)

if [[ "$request" -eq 200 ]];then
printf "$proxylist \t \e[32mON\e[0m \t [$c] \t\t ($socatp_dir/proxy$c)\n"
echo $proxylist >~/.socatp/proxy$c 
fi   

if [[ "$request" -ne 200 ]];then
printf "$proxylist \t \e[31mOFF\e[0m \t [$c]\n"
fi
done
exit 0
fi

if [[ -z "$b" || -z "$P" ]];then
help_msg
exit 1
fi 

if [[ -z "$p" || "$p" == "R" ]];then
version
proxy_random
exit 0
fi

if [[ "$p" == 1 && "$b" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ && ! -z "$P"  ]];then
proxy1=18.141.177.23
proxy1_p=80
#proxy1_auth="pro1:pro1"
#printf "proxy: $proxy1\ntarget: $b\nport: $P\n"
exec $socat STDIO PROXY:$proxy1:$b:$P,proxyport=$proxy1_p
fi

if [[ "$p" == 2 && "$b" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ && ! -z "$P"  ]];then
proxy2=120.24.145.9
proxy2_p=3128
exec $socat STDIO PROXY:$proxy2:$b:$P,proxyport=$proxy2_p
fi

if [[ "$p" == 3 && "$b" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ && ! -z "$P"  ]];then
proxy3=156.54.219.103
proxy3_p=80
exec $socat STDIO PROXY:$proxy3:$b:$P,proxyport=$proxy3_p
fi

if [[ "$p" == 4 && "$b" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ && ! -z "$P"  ]];then
proxy4=156.54.219.109
proxy4_p=80
exec $socat STDIO PROXY:$proxy4:$b:$P,proxyport=$proxy4_p
fi
else
error
fi
done << EOF

Scripts recomendados

Juros compostos usando bc

Localizando tentativas de invasão

SonyEricson-MD300 funciona

Gerar backup do MySQL ou Postgres

Prompt Interativo para o Legendary


  

Comentários
[1] Comentário enviado por maurixnovatrento em 24/04/2021 - 11:48h


Está bem elaborado.

___________________________________________________________
[code]Conhecimento não se Leva para o Túmulo.
https://github.com/MauricioFerrari-NovaTrento [/code]


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts