diff --git a/Makefile b/Makefile index 3dd08b2..b3c37d2 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ sh: cp -f sh/vol $(DESTDIR)$(PREFIX)/bin cp -f sh/josm_launch $(DESTDIR)$(PREFIX)/bin cp -f sh/start $(DESTDIR)$(PREFIX)/bin + cp -f sh/proxtest $(DESTDIR)$(PREFIX)/bin mkc: cc c/scream.c -o c/scream @@ -30,6 +31,7 @@ mkc: cc c/boid.c -o c/boid -lm -lX11 cc c/anaconda.c -o c/anaconda -lm -lX11 cc c/simplestatus.c -o c/simplestatus + c: cp -f c/scream $(DESTDIR)$(PREFIX)/bin cp -f c/timer $(DESTDIR)$(PREFIX)/bin diff --git a/sh/proxtest b/sh/proxtest new file mode 100755 index 0000000..6769690 --- /dev/null +++ b/sh/proxtest @@ -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