Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

SIMPLE HTTP PROXY SERVER CHECKER (Completed)

Shell Programming and Scripting


Tags
bash, proxy checker, proxy server

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 05-30-2012
654321 654321 is offline
Registered User
 
Join Date: Mar 2012
Last Activity: 23 May 2014, 7:14 AM EDT
Posts: 7
Thanks: 0
Thanked 4 Times in 3 Posts
SIMPLE HTTP PROXY SERVER CHECKER (Completed)

Simple Http Proxy Server Checker Script with curl
mirror https://github.com/Anoncheg1/proxies...b/master/proxc
output in terminal
HTTP, HTTP Connect (HTTPS not supported)

Code:
command line:
proxc filename

where filename is file like
119.110.69.185:8080
119.235.16.41:8080
154.182.broadband15.iol.cz:8080
119.252.165.170:8080

requirements:
  1. curl
  2. your own site with php support
  3. you must change "sitedns" and "siteip" variable in script.

Code:
#! /bin/bash
trap bashtrap INT
bashtrap()
{
    echo
    echo "CTRL+C Detected"
    kill 0
    exit
}

sitedns="yoursite.dns"
siteip="1.1.1.1" #not required for browser check

varagent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
TIMEOUT=4

cookie_header="Cookie: __atuvc=19%7C23; NIXSESSID=3f5d178f0ce66213c512e512b65269008c365038;" #random cookie

phpsiteprase="any fucking text"

function ping_http {
# <p>$phpsiteprase</p>/nArray
#    [Accept] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
#    [Accept-Charset] => ISO-8859-1,utf-8;q=0.7,*;q=0.7
#    [Accept-Encoding] => gzip,deflate
#    [Accept-Language] => en-us,en;q=0.5
#    [Connection] => close
#    [Host] => yoursitedns.com
#    [User-Agent] => Mozilla/5.0 (Android; Tablet; rv:12.0) Gecko/12.0 Firefox/12.0
#    [Via] => 1.1 89.28.122.140 (Mikrotik HttpProxy)
#    [X-Forwarded-For] => 1.1.1.1
#    [X-Proxy-Id] => 1773250874
#    [X-Real-Ip] => 89.28.122.140
    local proxyip=$1

    local http_check_var=`curl -s -A "$varagent" -x "$proxyip" --connect-timeout $TIMEOUT \
    --url "http://""$sitedns""/tmp/" -m 5`                   #Proxies for browser
#    --header "Host: "$sitedns"" --url "http://"$siteip"/tmp/" -L -m 5`
    local check1_phrase=`echo "$http_check_var" | grep -o "$phpsiteprase"`
    local check2_forwarded=`echo "$http_check_var" | grep -o "Forwarded"`
    local check3_clientip=`echo "$http_check_var" | grep -o "Client-Ip"`
    local check4_proxy=`echo "$http_check_var" | grep -o "Proxy"`
    local check5_via=`echo "$http_check_var" | grep -o "Via"`
    if [[ -n "$check1_phrase" ]]; then    #-n not zero # working
#        local http_check_var_connect=`curl -s -A "$varagent" -p -x "$proxyip" --connect-timeout $TIMEOUT \
#        --header "Host: "$sitedns"" --url "http://"$siteip"/tmp/" -m 5 | grep -o "$phpsiteprase"`  #Http Connect check
        if [[ -z "$check2_forwarded" && -z "$check3_clientip" ]]; then  #  -z - if null #Elite without cookie
            local http_check_var=`curl -s -A "$varagent" -x "$proxyip" --connect-timeout $TIMEOUT --header "$cookie_header" --header "Cache-Control: no-cache"\
            --url "http://""$sitedns""/tmp/" -m 5` #second check with cookie now
            local check1_phrase=`echo "$http_check_var" | grep -o "$phpsiteprase"`
            local check2_forwarded=`echo "$http_check_var" | grep -o "Forwarded"`
            local check3_clientip=`echo "$http_check_var" | grep -o "Client-Ip"`
            local check44_proxy_2=`echo "$http_check_var" | grep -o "Proxy"`
            local check55_via_2=`echo "$http_check_var" | grep -o "Via"`
            if [[ -n "$check1_phrase" && -z "$check2_forwarded" && -z "$check3_clientip" ]]; then #Elite with cookie
                local check6_vk=`curl -s -A "$varagent" -x "$proxyip" --url vk.com -m 1 | grep -o "vklogin"` #check for speed

                # I check country for elite. Move it where u want.
                local prip=$(echo "$line" | sed 's/:.*//')
                local whoisvar=$(whois "$prip" )
                local countryvar=$(echo "$whoisvar" | grep "country:" | sed 's/country: \{1,\}//' | head -n 1)
                [[ -z "$countryvar" ]] && local countryvar=$(echo "$whoisvar" | grep "Country-Code" | sed 's/.*:\{1,\}//' | head -n 1)
                [[ -z "$countryvar" ]] && local countryvar=$(echo "$whoisvar" | grep "Nameserver" | sed 's/.*\.\{1,\}//' | head -n 1)
                    #case $countryvar in
                    #"RU" | "UA" | "BY" | "KZ" | "KG")
                        #echo...
                        #;;
                    #esac
                #if [[ "$countryvar" != "CN" && "$countryvar" != "cn" ]]; then
                    echo -ne "\t\t\t\tElite\r"
                    echo -ne "\t\t\t\t\t\t"${countryvar:0:13}"\r"
                    if [[ -z "$check4_proxy" && -z "$check5_via" && -z "$check44_proxy_2" && -z "$check55_via_2" ]]; then
                        echo -ne "\t\t\t\t\tSuperEl\r"
                    fi
                    [[ -n "$check6_vk" ]] && echo -ne "\t\t\t\t\t\t\t\t\tSpeedVK \r"

                    echo "$proxyip""      "
                #fi
            fi
        fi
        #if [[ -n "$http_check_var_connect" ]]; then    #-n not zero  #HTTP Connect
            #echo -ne "\t\t\t\t\t\t\t\tConn \r"
        #fi
    fi
    echo -ne "process $count finished    \r"
}

function check_alive_http {
    ##### check loop #####
    local count=1
    for line in $( cat $1 )
    do    
        ping_http "$line" &
        sleep 0.2

    let count++
    done
    wait
    echo 
}

### MAIN ####
TOTAL_HTTP=`cat $1 | wc -l`
[ "$TOTAL_HTTP" == 0 ] && { echo "Found 0 proxies"; exit; }
echo "Checking "$TOTAL_HTTP" HTTP proxies"
check_alive_http $1

#            # DNS to IP
#            local ipold=$(echo "$proxyip" | sed 's/:.*//')
#            local ip=$(dig +short "$ipold")
#            if [[ "$ip" != "" ]]; then
#                local proxyip=$ip:$(echo "$proxyip" | sed 's/.*://')
#            fi
#            #

your PHP site with adderess http://"your.site.com"/tmp/index.php:
PHP Code:

<html>
 <head>
  <title>proxc</title>
 </head>
 <body>

 <?php echo '<p>any fucking text</p>/n';
if(!
function_exists('apache_request_headers')) {
    function 
apache_request_headers() {
        
$headers = array();
        foreach(
$_SERVER as $key => $value) {
            if(
substr($key05) == 'HTTP_') {
                
$headers[str_replace(' ''-'ucwords(str_replace('_'' 'strtolower(substr($key5)))))] = $value;
            }
        }
        return 
$headers;
    }
}


print_rapache_request_headers() );

?>
</body>
</html>
All proxies still may be unsafe. To redice risk use My HTTP headers with double loading.


If you wanna use proxies not for browser only, replace:

Code:
--url "http://""$sitedns""/"

with

Code:
--header "Host: "$sitedns"" --url "http://"$siteip"/"

If you wanna add your check in script you should do all curl request before echo commands

Socks and grabber scripts: https://github.com/Anoncheg1/proxies-scripts/

Last edited by 654321; 05-23-2014 at 07:14 AM.. Reason: script upgrades
The Following User Says Thank You to 654321 For This Useful Post:
ijustneeda (09-23-2012)
Sponsored Links
    #2  
Old Unix and Linux 05-31-2012
654321 654321 is offline
Registered User
 
Join Date: Mar 2012
Last Activity: 23 May 2014, 7:14 AM EDT
Posts: 7
Thanks: 0
Thanked 4 Times in 3 Posts
I dont wanna include this for keeping it simple

Code:
            # DNS to IP
            local ipold=$(echo $proxyip | sed 's/:.*//')
            local ip=$(dig +short $ipold)
            if [[ $ip != "" ]]; then
                local proxyip=$ip:$(echo $proxyip | sed 's/.*://')
            fi
            #

can be used inside function ping_http

Last edited by 654321; 06-05-2012 at 04:08 AM..
Sponsored Links
    #3  
Old Unix and Linux 06-05-2012
654321 654321 is offline
Registered User
 
Join Date: Mar 2012
Last Activity: 23 May 2014, 7:14 AM EDT
Posts: 7
Thanks: 0
Thanked 4 Times in 3 Posts
MySQL

I found that some proxies work different with cookies
That is why I added second check for Elite proxy servers.

... Now I found that some proxies work different with header "Cache-Control: no-cache" . That is why I added such header in second check.

Last edited by 654321; 11-15-2012 at 02:56 AM..
The Following 2 Users Say Thank You to 654321 For This Useful Post:
jethro10 (10-16-2012), vbe (06-05-2012)
    #4  
Old Unix and Linux 09-23-2012
ijustneeda ijustneeda is offline
Banned
 
Join Date: Feb 2012
Last Activity: 27 April 2014, 7:28 AM EDT
Posts: 14
Thanks: 2
Thanked 1 Time in 1 Post
Thank you very much for your script, this is exactly what I was looking for!

However, I have a few problems with it:

To get it to run, I first had to save the PHP file in your post as index.php in the /tmp directory of my webserver. I had to read the source code to know that, it would be nice to have it in the documentation.

I tested it with several proxylists from today, combined about 4500 unique proxyLinuxort combinations. In my access logfiles of the webserver I saw that more than 1200 of them successfully retrieved the /tmp/index.php testscript. But the proxyc script just terminates after the last process finished, without printing any results on the screen. Where do I get the results?
Sponsored Links
    #5  
Old Unix and Linux 09-23-2012
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 28 April 2017, 12:18 PM EDT
Location: Saskatchewan
Posts: 22,099
Thanks: 1,075
Thanked 4,159 Times in 3,849 Posts
Ever wondered where those huge lists of mostly-broken public proxies come from? I don't, anymore. I saw a server become compromised by a rootkit, and appear in one of those lists. A badly thought-out apache configuration also made a different server of mine appear in one of those lists, and even after I fixed it, I was getting 403's for months from people trying to use it as a proxy.

Those lists are full of computers that are, or were, compromised. My advice? Get your own.

Last edited by Corona688; 09-23-2012 at 02:40 PM..
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Completed: Domain name tools. Generator & Checker Files Shell Programming and Scripting 0 12-26-2012 11:09 PM
Sending and Receiving data between Client, HTTP Proxy, and Remote Server shubham92 Programming 0 05-13-2012 11:36 PM
Simple HTTP server in GAWK ripat Shell Programming and Scripting 0 12-06-2009 08:43 AM



All times are GMT -4. The time now is 05:02 AM.