add proxtest, software for testing public proxy lists

This commit is contained in:
randomuser 2022-02-05 18:50:00 -06:00
parent 44a0d2a9d3
commit f21c709e4a
2 changed files with 81 additions and 0 deletions

View File

@ -23,6 +23,7 @@ sh:
cp -f sh/vol $(DESTDIR)$(PREFIX)/bin cp -f sh/vol $(DESTDIR)$(PREFIX)/bin
cp -f sh/josm_launch $(DESTDIR)$(PREFIX)/bin cp -f sh/josm_launch $(DESTDIR)$(PREFIX)/bin
cp -f sh/start $(DESTDIR)$(PREFIX)/bin cp -f sh/start $(DESTDIR)$(PREFIX)/bin
cp -f sh/proxtest $(DESTDIR)$(PREFIX)/bin
mkc: mkc:
cc c/scream.c -o c/scream cc c/scream.c -o c/scream
@ -30,6 +31,7 @@ mkc:
cc c/boid.c -o c/boid -lm -lX11 cc c/boid.c -o c/boid -lm -lX11
cc c/anaconda.c -o c/anaconda -lm -lX11 cc c/anaconda.c -o c/anaconda -lm -lX11
cc c/simplestatus.c -o c/simplestatus cc c/simplestatus.c -o c/simplestatus
c: c:
cp -f c/scream $(DESTDIR)$(PREFIX)/bin cp -f c/scream $(DESTDIR)$(PREFIX)/bin
cp -f c/timer $(DESTDIR)$(PREFIX)/bin cp -f c/timer $(DESTDIR)$(PREFIX)/bin

79
sh/proxtest Executable file
View File

@ -0,0 +1,79 @@
#!/bin/sh
output_as_proxychains=1
randomize=1
choose=0
outputted_proxies=""
temp_output=$(mktemp)
while getopts ":pt:rc:" options; do
case $options in
p)
output_as_proxychains=0
;;
t)
temp_output=$OPTARG
;;
r)
randomize=0
;;
c)
choose=$OPTARG
;;
:)
printf "specify argument\n"
exit
;;
*)
printf "what has happened\n"
exit
;;
esac
done
# get the tor port number using this lsof incantination
torport=$(\
sudo lsof -nP -iTCP -sTCP:LISTEN | \
grep tor | \
awk -F'[ :]+' 'NR = 1 {print $10}'
)
curl --silent --preproxy socks5://127.0.0.1:$torport https://raw.githubusercontent.com/hookzof/socks5_list/master/proxy.txt -o $temp_output
printf "estimated worsecase run time: %i seconds\n" $(wc -l $temp_output | awk -F' ' '{print $1}') 1>&2
looped=$(\
cat $temp_output | \
( [ $randomize -eq 0 ] && shuf || cat ) | \
( [ $choose -ne 0 ] && head -n $choose || cat ) | \
tr '\n' ' ' | \
tr -d '\r'
)
for i in $looped; do
ip=$(printf $i | awk -F':' '{print $1}')
port=$(printf $i | awk -F':' '{print $2}' | tr -d '\r')
# TODO: timeout is a non-posix gnu extension, remove/replace it
timeout 2s nc -zv -x 127.0.0.1:$torport $ip $port 2>/dev/null 1>&2 && \
outputted_proxies="$outputted_proxies $i" && \
printf "success! %s\n" $i 1>&2 || \
printf "failure! %s\n" $i 1>&2
done
if [ $output_as_proxychains -eq 0 ]; then
printf "# generated by proxtest.sh @ %s\n" "$(date)"
printf "random_chain\nproxy_dns\nchain_len = 5\n"
printf "tcp_read_time_out 15000\ntcp_connect_time_out 8000\n"
printf "[ProxyList]\n"
# assumes all socks5 proxies, change this in future
for i in $outputted_proxies; do
printf "socks5 %s\n" "$(printf %s $i | tr ':' ' ')"
done
printf "# finished!\n"
else
for i in $outputted_proxies; do
printf "%s\n" $i
done
fi