-
-
Save Justsoos/8c06f2df7b7c1b01749c19fe598e1e11 to your computer and use it in GitHub Desktop.
proxychains CLI wrapper (updated)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# proxychains wrapper | |
# Choose pre-supposed profile with -1,-2,-3 OR appoint by -n proxy(Node)_ip(hostname):port and -p proxy_protocol and -q as quiet mode | |
# Default profile | |
proxy_hostname=127.0.0.1 | |
proxy_port=1080 | |
protocol=socks5 | |
# profile 1 | |
proxy_hostname_1=127.0.0.1 | |
proxy_port_1=9999 | |
protocol_1=socks5 | |
# profile 2 | |
proxy_hostname_2=SomeProxySite.com | |
proxy_port_2=443 | |
protocol_2=https | |
# profile 3 | |
proxy_hostname_3=SomeProxySite.com | |
proxy_port_3=8080 | |
protocol_3=http | |
quiet="" | |
while getopts :n:p:q123 opt | |
do | |
case $opt in | |
1) | |
# profile 1 | |
proxy_hostname=$proxy_hostname_1 | |
proxy_port=$proxy_port_1 | |
protocol=$protocol_1 | |
;; | |
2) | |
# profile 2 | |
proxy_hostname=$proxy_hostname_2 | |
proxy_port=$proxy_port_2 | |
protocol=$protocol_2 | |
;; | |
3) | |
# profile 3 | |
proxy_hostname=$proxy_hostname_3 | |
proxy_port=$proxy_port_3 | |
protocol=$protocol_3 | |
;; | |
n) | |
# appointed proxy hostname & port | |
proxy_port=$(echo $OPTARG | awk -F ':' '{print $(NF)}') | |
# remove [] of IPv6 | |
proxy_hostname=$(echo $OPTARG | sed "s/:$proxy_port//g" | sed "s/\[//g" | sed "s/\]//g") | |
;; | |
p) | |
# appointed proxy protocol | |
protocol=$OPTARG | |
;; | |
q) | |
# quiet | |
quiet=" -q " | |
;; | |
:) | |
;; | |
esac | |
done | |
shift "$((OPTIND-1))" | |
# echo "$proxy_hostname $proxy_port $protocol" | |
proxy_ip=$(getent hosts $proxy_hostname | head -n1 | cut -d " " -f1) | |
[ -z $proxy_ip ] && proxy_ip=$proxy_hostname | |
# echo "$proxy_ip" | |
# echo "$@" | |
# echo "$OPTIND" | |
# echo "$quiet" | |
# echo $$ | |
conf=/tmp/proxychains4.conf.$UID.$$ | |
cat << EOF > $conf | |
strict_chain | |
proxy_dns | |
remote_dns_subnet 224 | |
tcp_read_time_out 15000 | |
tcp_connect_time_out 8000 | |
[ProxyList] | |
EOF | |
echo "$protocol $proxy_ip $proxy_port" >> $conf | |
trap "rm -f $conf" INT TERM | |
para=${quiet}" -f "${conf}" "${@} | |
# echo $para | |
proxychains4 $para | |
ec="$?" | |
rm -f "$conf" | |
exit "$ec" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-q
option getting quiet modesuggest setting system alias like:
alias p='/home/your_path/p.sh'
and then you could run proxychains with ease like:
$p curl ipinfo.io
or
$p -1 curl ipinfo.io
or
$p -n 1.1.1.1:1080 -p socks5 curl ipinfo.io
or
$p -q curl ipinfo.io
from rofl0r/proxychains-ng#246 (comment)