{"id":154,"date":"2024-05-02T14:26:51","date_gmt":"2024-05-02T07:26:51","guid":{"rendered":"https:\/\/viet.im\/blog\/?p=154"},"modified":"2024-05-02T14:26:51","modified_gmt":"2024-05-02T07:26:51","slug":"proxy-verifier-in-bash-script","status":"publish","type":"post","link":"https:\/\/viet.im\/blog\/proxy-verifier-in-bash-script\/","title":{"rendered":"Proxy verifier in Bash script"},"content":{"rendered":"<p>I have a list of proxies and I need to verify if they are good to be used.<\/p>\n<p>I looked online and I found some options: Proprietary softwares that typically has a license fee; Web services that might store the information and use it elsewhere; Open-source tools that need a lot of effort just to install. I just want something cheap and fast so I thought, yeah, might be few lines of Bash script would do this just fine.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\">#!\/bin\/bash\r\n\r\nproxy_input=\".\/proxy_list.txt\"\r\nexport proxy_output=\".\/proxy_list_ok.txt\"\r\nexport timeout=10\r\nexport protocol=\"socks5\"\r\n\r\nproxy_verifier()\r\n{\r\n    read -r proxy &lt;&lt;&lt;\"${1\/\/[$'\\t\\r\\n']}\"\r\n    response=$(curl --insecure --connect-timeout ${timeout} --proxy \"${protocol}:\/\/\"${proxy} --silent --url \"http:\/\/azenv.net\")\r\n    if [ \"$?\" -eq 0 ]; then\r\n        if [[ ! $response =~ \"$2\" ]] &amp;&amp; [[ $response =~ \"PHP Proxy Judge\" ]]; then\r\n            echo $1 &gt;&gt; \"${proxy_output}\"\r\n        fi\r\n    fi\r\n}\r\n\r\npublic_ip=$(curl --silent --url \"http:\/\/ipinfo.io\/ip\")\r\n\r\nexport -f proxy_verifier\r\nparallel -j 32 --bar --progress --eta proxy_verifier :::: \"${proxy_input}\" ::: \"${public_ip}\"<\/pre>\n<p>The first is to put list of the proxies in a file named <code>proxy_list.txt<\/code>, one proxy per line:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">10.1.1.1:1080\r\n172.16.1.1:12345\r\n192.168.1.1:9999<\/pre>\n<p>Then the script will<\/p>\n<ol>\n<li>Get the public IP address of the machine running the script (this is to later verify if the proxy server leaks the IP address of the user)<\/li>\n<li>Use <code>parallel<\/code> to loop through file line by line and verify the proxies, with up to 32 jobs can be running in parallel at the same time for faster processing<\/li>\n<li>For each proxy, the script will use <code>curl<\/code> to connect to the proxy and make a request to a proxy judge website. If the proxy is good then it will be put into another file named <code>proxy_list_ok.txt<\/code><\/li>\n<\/ol>\n<p>The script can be modified for more advanced features such as automatic detection proxy protocol, retrieve geolocation information of the proxy or determine the speed. But for now it is all that I need.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a list of proxies and I need to verify if they are good to be used. I looked online and I found some options: Proprietary softwares that typically has a license fee; Web services that might store the information and use it elsewhere; Open-source tools that need a lot of effort just to install. I just want something&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"cybocfi_hide_featured_image":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","_wp_rev_ctl_limit":""},"categories":[1],"tags":[],"class_list":["post-154","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Proxy verifier in Bash script - Viet&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/viet.im\/blog\/proxy-verifier-in-bash-script\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Proxy verifier in Bash script - Viet&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"I have a list of proxies and I need to verify if they are good to be used. I looked online and I found some options: Proprietary softwares that typically has a license fee; Web services that might store the information and use it elsewhere; Open-source tools that need a lot of effort just to install. I just want something&#046;&#046;&#046;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/viet.im\/blog\/proxy-verifier-in-bash-script\/\" \/>\n<meta property=\"og:site_name\" content=\"Viet&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2024-05-02T07:26:51+00:00\" \/>\n<meta name=\"author\" content=\"Viet\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Viet\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/viet.im\/blog\/proxy-verifier-in-bash-script\/\",\"url\":\"https:\/\/viet.im\/blog\/proxy-verifier-in-bash-script\/\",\"name\":\"Proxy verifier in Bash script - Viet&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\/\/viet.im\/blog\/#website\"},\"datePublished\":\"2024-05-02T07:26:51+00:00\",\"dateModified\":\"2024-05-02T07:26:51+00:00\",\"author\":{\"@id\":\"https:\/\/viet.im\/blog\/#\/schema\/person\/0f7d8f880ca4892bf08c50b02c35809b\"},\"breadcrumb\":{\"@id\":\"https:\/\/viet.im\/blog\/proxy-verifier-in-bash-script\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/viet.im\/blog\/proxy-verifier-in-bash-script\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/viet.im\/blog\/proxy-verifier-in-bash-script\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/viet.im\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Proxy verifier in Bash script\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/viet.im\/blog\/#website\",\"url\":\"https:\/\/viet.im\/blog\/\",\"name\":\"Viet&#039;s Blog\",\"description\":\"-\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/viet.im\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/viet.im\/blog\/#\/schema\/person\/0f7d8f880ca4892bf08c50b02c35809b\",\"name\":\"Viet\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/viet.im\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/36c308454c1e52331326d520483707bdd317dca24a5b16686d04023eaeb1240d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/36c308454c1e52331326d520483707bdd317dca24a5b16686d04023eaeb1240d?s=96&d=mm&r=g\",\"caption\":\"Viet\"},\"sameAs\":[\"https:\/\/viet.im\/blog\"],\"url\":\"https:\/\/viet.im\/blog\/author\/viet\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Proxy verifier in Bash script - Viet&#039;s Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/viet.im\/blog\/proxy-verifier-in-bash-script\/","og_locale":"en_US","og_type":"article","og_title":"Proxy verifier in Bash script - Viet&#039;s Blog","og_description":"I have a list of proxies and I need to verify if they are good to be used. I looked online and I found some options: Proprietary softwares that typically has a license fee; Web services that might store the information and use it elsewhere; Open-source tools that need a lot of effort just to install. I just want something&#46;&#46;&#46;","og_url":"https:\/\/viet.im\/blog\/proxy-verifier-in-bash-script\/","og_site_name":"Viet&#039;s Blog","article_published_time":"2024-05-02T07:26:51+00:00","author":"Viet","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Viet","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/viet.im\/blog\/proxy-verifier-in-bash-script\/","url":"https:\/\/viet.im\/blog\/proxy-verifier-in-bash-script\/","name":"Proxy verifier in Bash script - Viet&#039;s Blog","isPartOf":{"@id":"https:\/\/viet.im\/blog\/#website"},"datePublished":"2024-05-02T07:26:51+00:00","dateModified":"2024-05-02T07:26:51+00:00","author":{"@id":"https:\/\/viet.im\/blog\/#\/schema\/person\/0f7d8f880ca4892bf08c50b02c35809b"},"breadcrumb":{"@id":"https:\/\/viet.im\/blog\/proxy-verifier-in-bash-script\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/viet.im\/blog\/proxy-verifier-in-bash-script\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/viet.im\/blog\/proxy-verifier-in-bash-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/viet.im\/blog\/"},{"@type":"ListItem","position":2,"name":"Proxy verifier in Bash script"}]},{"@type":"WebSite","@id":"https:\/\/viet.im\/blog\/#website","url":"https:\/\/viet.im\/blog\/","name":"Viet&#039;s Blog","description":"-","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/viet.im\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/viet.im\/blog\/#\/schema\/person\/0f7d8f880ca4892bf08c50b02c35809b","name":"Viet","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/viet.im\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/36c308454c1e52331326d520483707bdd317dca24a5b16686d04023eaeb1240d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/36c308454c1e52331326d520483707bdd317dca24a5b16686d04023eaeb1240d?s=96&d=mm&r=g","caption":"Viet"},"sameAs":["https:\/\/viet.im\/blog"],"url":"https:\/\/viet.im\/blog\/author\/viet\/"}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/viet.im\/blog\/wp-json\/wp\/v2\/posts\/154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/viet.im\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/viet.im\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/viet.im\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/viet.im\/blog\/wp-json\/wp\/v2\/comments?post=154"}],"version-history":[{"count":1,"href":"https:\/\/viet.im\/blog\/wp-json\/wp\/v2\/posts\/154\/revisions"}],"predecessor-version":[{"id":155,"href":"https:\/\/viet.im\/blog\/wp-json\/wp\/v2\/posts\/154\/revisions\/155"}],"wp:attachment":[{"href":"https:\/\/viet.im\/blog\/wp-json\/wp\/v2\/media?parent=154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/viet.im\/blog\/wp-json\/wp\/v2\/categories?post=154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/viet.im\/blog\/wp-json\/wp\/v2\/tags?post=154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}