PHP anonymity checker script

PHP class : socks 4, socks 5 and proxy lists validation (based on curl lib).

Anonymity is one of my favourites’ interests. This simple PHP 5 class validates Socks4 , Socks5 and Proxy lists.

Version: 0.2

  1. <?php// PHP anonymity checker
  2. //
  3. //   (c) Involutive 2008 http://www.involutive.com
  4. //   author: Paolo Ardoino < paolo@involutive.com >
  5. //
  6. //      Usage:
  7. //              $anons = array(
  8. //                      array("ip" => "1.2.3.4", "port" => 8080, "type" => "socks4"),
  9. //                      array("ip" => "1.2.3.5", "port" => 8080, "type" => "socks5"),
  10. //                      array("ip" => "1.2.3.6", "port" => 8080, "type" => "proxy")
  11. //              );
  12. //
  13. //              $pa = new phpanon(array("anons" => $anons));
  14. //              $pa->check();
  15. //              $pa->done();
  16. //
  17. //              $anons is an array of triples ("ip" => ip, "port" => port, "type" => type)
  18. //                      ip: ip address of the socks / proxy
  19. //                      port: port of the socks / proxy
  20. //                      type: socks5 (for socks5), socks4 (for socks4), proxy (for proxy)
  21. //
  22. //              Other options:
  23. //                      "url" => "http://www.example.com" : connection test page
  24. //                      "needle" => "someword" : some word contained in the page set by "url"
  25. //                      "user_agent" => "Mozilla Firefox" : set an alternative user_agent
  26. //                      "url_referer" => "http://www.mypage.com" : set a referer urlclass phpanon {
  27. public $anons = array();
  28. public $opts = array("user_agent" => "", "url_referer" => "", "url" => "http://www.google.com", "needle" => "groups");function __construct($opts) {
  29.  
  30. if(sizeof($opts["anons"]) > 0) {
  31. $this->anons = $opts["anons"];
  32. }
  33.  
  34. if($opts["user_agent"] != "") {
  35. $this->opts["user_agent"] = $opts["user_agent"];
  36. }
  37.  
  38. if($opts["url_referer"] != "") {
  39. $this->opts["url_referer"] = $opts["url_referer"];
  40. }
  41.  
  42. }
  43.  
  44. function check() {
  45. echo "PHP anonymity checker v0.2\n\t(c) 2007 Involutive http://www.involutive.com\n";
  46. echo "\tAuthor: Paolo Ardoino < paolo@involutive.com >\n";
  47.  
  48. if(sizeof($this->anons) > 0) {
  49. for($i = 0, $cnt_good = 0, $cnt_gad = 0, $y = sizeof($this->anons); $i < $y; $i++) {
  50. $anon = &$this->anons[$i];
  51. if($anon["ip"] != "" && $anon["port"] != "" && $anon["type"]) {
  52. echo "Checking ".$anon["ip"].":".$anon["port"]." [ type ".$anon["type"]." ] … ";
  53. $ch = curl_init($this->opts["url"]);
  54.  
  55. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  56. curl_setopt($ch, CURLOPT_HEADER, 0);
  57. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
  58. curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  59. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  60.  
  61. if($this->opts["user_agent"] != "") {
  62. curl_setopt($ch, CURLOPT_USERAGENT, $this->opts["user_agent"]);
  63. }
  64. if($this->opts["url_referer"] != "") {
  65. curl_setopt($ch, CURLOPT_REFERER, $this->opts["url_referer"]);
  66. }
  67.  
  68. curl_setopt($ch, CURLOPT_PROXY, $anon["ip"].":".$anon["port"]);
  69. if($anon["type"] == "socks4") curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
  70. else if($anon["type"] == "socks5") curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
  71.  
  72. $html = curl_exec($ch);
  73. if(curl_errno($ch) || $html == "" || strpos($html, $this->opts["needle"]) === FALSE) {
  74. $anon["status"] = 0;
  75. $cnt_gad++;
  76. echo "not working\n";
  77. } else {
  78.  
  79. $anon["status"] = 1;
  80. $cnt_good++;
  81. echo "working\n";
  82. }
  83. curl_close ($ch);
  84. unset($ch);
  85. }
  86. unset($anon);
  87. }
  88. }
  89.  
  90. echo "Done.\n";
  91. }
  92. }
  93.  
  94. ?>

Tags: , , , ,


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5 out of 5)
Loading ... Loading ...

Leave a Reply

Random Articles