From 5a5c20fa609dbd4b25cf70038161cdad3a514d00 Mon Sep 17 00:00:00 2001 From: vasemkin <57621898+vasemkin@users.noreply.github.com> Date: Wed, 4 Aug 2021 17:03:25 +0300 Subject: [PATCH 1/4] added proxy authentication support for CheckSingleProxy basic authentication with CURLOPT_PROXYAUTH --- checker.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/checker.php b/checker.php index 654a355..5e9ea2b 100644 --- a/checker.php +++ b/checker.php @@ -63,7 +63,7 @@ } else if(isset($_GET['ip']) && isset($_GET['port'])) { - CheckSingleProxy($_GET['ip'], $_GET['port'], $_GET['timeout'], true, $socksOnly, $proxy_type); + CheckSingleProxy($_GET['ip'], $_GET['port'], $_GET['timeout'], $_GET['login'], $_GET['password'], true, $socksOnly, $proxy_type); } else { @@ -94,11 +94,10 @@ function CheckMultiProxy($proxies, $timeout, $proxy_type) - function CheckSingleProxy($ip, $port, $timeout, $echoResults=true, $socksOnly=false, $proxy_type="http(s)") + function CheckSingleProxy($ip, $port, $timeout, $login=null, $password=null, $echoResults=true, $socksOnly=false, $proxy_type="http(s)") { $passByIPPort= $ip . ":" . $port; - - + // You can use virtually any website here, but in case you need to implement other proxy settings (show annonimity level) // I'll leave you with whatismyipaddress.com, because it shows a lot of info. $url = "http://whatismyipaddress.com/"; @@ -110,6 +109,13 @@ function CheckSingleProxy($ip, $port, $timeout, $echoResults=true, $socksOnly=fa curl_setopt($theHeader, CURLOPT_RETURNTRANSFER, 1); curl_setopt($theHeader, CURLOPT_TIMEOUT, $timeout); curl_setopt($theHeader, CURLOPT_PROXY, $passByIPPort); + + //Basic proxy authentication support by @vasemkin + if($login && $password) { + $proxyAuth = $login . ":" . $password; + curl_setopt($theHeader, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); + curl_setopt($theHeader, CURLOPT_PROXYUSERPWD, $proxyAuth); + } //If only socks proxy checking is enabled, use this below. if($socksOnly) @@ -132,7 +138,7 @@ function CheckSingleProxy($ip, $port, $timeout, $echoResults=true, $socksOnly=fa //Just as a safety net though, I'm still aborting if $socksOnly is true (i.e. we were initially checking for a socks-specific proxy) if(curl_errno($theHeader) == 56 && !$socksOnly) { - CheckSingleProxy($ip, $port, $timeout, $echoResults, true, "socks"); + CheckSingleProxy($ip, $port, $timeout, $login, $password, $echoResults, true, "socks"); return; } From 0c028c20c9a4f485e712851fd3ffe8661d0900c1 Mon Sep 17 00:00:00 2001 From: vasemkin <57621898+vasemkin@users.noreply.github.com> Date: Wed, 4 Aug 2021 17:08:49 +0300 Subject: [PATCH 2/4] updated the README --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 3782f8d..acc39f8 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,15 @@ And in the case of faliure you will get the reason why it failed (curl_error dir } ``` +### Checking Proxies with authentication +My fork supports Proxy authentication. +To check a proxy that requires authentication you need to pass the login and password to the request. +This works on both SOCKS and HTTP proxies. Example: +``` +checker.php?ip=137.116.76.252&port=3128&timeout=20&login=foo&password=bar +``` +Currently only supported for CheckSingleProxy + #### Checking SOCKS Proxies If you are using version 1.2 you will also be able to check SOCKS4/5 proxies. In version 1.2 the proxy is checked for SOCKS by default after it has partially failed a check for HTTP (Connection reset error), however knowing for sure whether it is a SOCKS proxy you are about to check or no can minimise the time it will take to process. From d15e88a4df4639c2d0459e90e708a40281cdd30f Mon Sep 17 00:00:00 2001 From: vasemkin <57621898+vasemkin@users.noreply.github.com> Date: Wed, 4 Aug 2021 17:47:38 +0300 Subject: [PATCH 3/4] added multichecking with a POST request --- checker.php | 106 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 61 insertions(+), 45 deletions(-) diff --git a/checker.php b/checker.php index 5e9ea2b..6a830aa 100644 --- a/checker.php +++ b/checker.php @@ -22,64 +22,80 @@ //To determine whether we are being supplied an ip-port or a filename, we'll take a look at the get params - //Step 1 - Check whether the user specified a timeout - if(!isset($_GET['timeout'])) - { - die("You must specify a timeout in seconds in your request (checker.php?...&timeout=20)"); - } - - //Step 2 - Little extras go here - //Default is 'false' not to confuse the IF-logic later on - $socksOnly = false; - if(isset($_GET['proxy_type'])) - { - if($_GET['proxy_type'] == "socks") - { - $socksOnly = true; - $proxy_type = "socks"; - } - else - { - $proxy_type = "http(s)"; - } - } - else - { - $proxy_type = "http(s)"; - } + if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $json = file_get_contents('php://input'); + $data = json_decode($json); + $timeout = $data->timeout; + $proxy_type = $data->proxy_type; + $authentication = $data->authentication; + $proxies = $data->proxies; + CheckMultiProxy($proxies, $timeout, $proxy_type, $authentication); + } else { - //Step 3 - Go through a loop to determine what the user wants us to do - if(isset($_GET['file'])) - { - //If we can't find the file, complain - if(!file_exists($_GET['file'])) + //Step 1 - Check whether the user specified a timeout + if(!isset($_GET['timeout'])) { - die("Could not find file '" . $_GET['file'] . "'"); + die("You must specify a timeout in seconds in your request (checker.php?...&timeout=20)"); } - //Convert the file to a list of proxies - $array = file($_GET['file']); - CheckMultiProxy($array, $_GET['timeout'], $proxy_type); - } - else if(isset($_GET['ip']) && isset($_GET['port'])) - { - CheckSingleProxy($_GET['ip'], $_GET['port'], $_GET['timeout'], $_GET['login'], $_GET['password'], true, $socksOnly, $proxy_type); - } - else - { - die("