Socat Proxifier
Publicado por Perfil removido (última atualização em 23/04/2021)
[ Hits: 3.083 ]
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. (:)
#!/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
Instalar temas GTK no /usr/share/themes ou no diretório pessoal
Detectar sistemas operacionais dos dispositivos na rede via TTL
Automatizador de instalação para Arch Linux
Avisar quando partição estiver 90% ocupada
Gentoo: detectando impressoras de rede e como fixar uma impressora por IP
Como o GNOME conseguiu o feito de ser preterido por outras interfaces gráficas
Gentoo binário em 2026: UEFI, LUKS, Btrfs e Systemd
Trabalhando Nativamente com Logs no Linux
Jogando Daikatana (Steam) com Patch 1.3 via Luxtorpeda no Linux
Por que sua empresa precisa de uma PKI (e como automatizar EMISSÕES de certificados via Web API)
Instalando NoMachine no Gentoo com Systemd (acesso Remoto em LAN)
Gentoo: Trocando wpa_supplicant pelo iwd no NetworkManager (Systemd)
O que houve com slackware ??? (12)
Alterar conteúdo de dica [RESOLVIDO] (3)
Vou destruir sua infância:) (5)









