├── LICENSE ├── README.md ├── prox.py └── requirements.txt /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Pythonism - The Pythonists' Org 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Proxy Checker 2 | 3 | Simple **HTTP/HTTPS** proxy checker written with Python 4 | 5 | # Usage 6 | 7 | ## Get started 8 | 9 | First you need to get rid of problems with executing permissions, so to do that, open terminal and say: 10 | 11 | ```bash 12 | chmod +x prox.py 13 | ``` 14 | 15 | ### Check proxies from file 16 | 17 | ```bash 18 | ./prox.py -f 19 | ``` 20 | 21 | ### Check only one proxy 22 | 23 | ```bash 24 | ./prox.py -p 25 | ``` 26 | -------------------------------------------------------------------------------- /prox.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | ''' 4 | PROX - utility for checking proxy in terminal under the GNU GPL V3.0 Licensy 5 | AUTHORS: Hasanov Abdurahmon & Ilyosiddin Kalandar 6 | Version: 0.2 7 | ''' 8 | 9 | from sys import argv 10 | import urllib3 11 | from os import system as terminal 12 | import requests 13 | from colorama import Fore,Style 14 | 15 | URL = "http://google.com" 16 | CMD_CLEAR_TERM = "clear" 17 | TIMEOUT = (3.05,27) 18 | 19 | def check_proxy(proxy): 20 | ''' 21 | Function for check proxy return ERROR 22 | if proxy is Bad else 23 | Function return None 24 | ''' 25 | try: 26 | session = requests.Session() 27 | session.headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36' 28 | session.max_redirects = 300 29 | proxy = proxy.split('\n',1)[0] 30 | print(Fore.LIGHTYELLOW_EX + 'Checking ' + proxy) 31 | session.get(URL, proxies={'http':'http://' + proxy}, timeout=TIMEOUT,allow_redirects=True) 32 | except requests.exceptions.ConnectionError as e: 33 | print(Fore.LIGHTRED_EX + 'Error!') 34 | return e 35 | except requests.exceptions.ConnectTimeout as e: 36 | print(Fore.LIGHTRED_EX + 'Error,Timeout!') 37 | return e 38 | except requests.exceptions.HTTPError as e: 39 | print(Fore.LIGHTRED_EX + 'HTTP ERROR!') 40 | return e 41 | except requests.exceptions.Timeout as e: 42 | print(Fore.LIGHTRED_EX + 'Error! Connection Timeout!') 43 | return e 44 | except urllib3.exceptions.ProxySchemeUnknown as e: 45 | print(Fore.LIGHTRED_EX + 'ERROR unkown Proxy Scheme!') 46 | return e 47 | except requests.exceptions.TooManyRedirects as e: 48 | print(Fore.LIGHTRED_EX + 'ERROR! Too many redirects!') 49 | return e 50 | def print_help(): 51 | terminal(CMD_CLEAR_TERM) 52 | print(Fore.LIGHTGREEN_EX + 'PROX v0.2 - Utility for checking proxy in terminal') 53 | print(Fore.LIGHTGREEN_EX + 'Authors: Hasanov Abdurahmon & Ilyosiddin Kalandar') 54 | print(Fore.LIGHTCYAN_EX) 55 | print('Usage -> prox -f - Check file with proxies') 56 | print('prox -p - check only one proxy') 57 | print('prox --help - show this menu') 58 | 59 | if len(argv) > 1: 60 | commands = ['--help','-h','-f','-p','/?','--file','-file','--proxy','-proxy'] 61 | if argv[1] in commands: 62 | if argv[1] in ('--help','-help','/?','--?'): 63 | print_help() 64 | elif argv[1] in ('-f','--file','-file'): 65 | try: 66 | file = open(argv[2]) 67 | proxies = list(file) 68 | goods = 0 69 | terminal(CMD_CLEAR_TERM) 70 | print(Fore.LIGHTCYAN_EX + '===========================================') 71 | for proxy in proxies: 72 | try: 73 | if check_proxy(proxy): 74 | print(Fore.LIGHTRED_EX + 'Bad proxy ' + proxy) 75 | else: 76 | print(Fore.LIGHTGREEN_EX + 'Good proxy ' + proxy) 77 | file_with_goods = open('good.txt','a') 78 | file_with_goods.write(proxy) 79 | goods += 1 80 | print(Fore.LIGHTCYAN_EX + '=================================================') 81 | except KeyboardInterrupt: 82 | print(Fore.LIGHTGREEN_EX + '\nExit.') 83 | exit() 84 | print(Fore.LIGHTGREEN_EX + 'Total ' + str(goods) + ' good proxies found') 85 | print(Fore.LIGHTRED_EX + 'And ' + str(len(proxies) - goods) + ' is bad') 86 | print(Fore.LIGHTYELLOW_EX + 'Have nice day! :)') 87 | print() 88 | except FileNotFoundError: 89 | print(Fore.LIGHTRED_EX + 'Error!\nFile Not found!') 90 | except IndexError: 91 | print(Fore.LIGHTRED_EX + 'Error!\nMissing filename!') 92 | elif argv[1] in ('-p','--proxy','-proxy'): 93 | try: 94 | argv[2] = argv[2].split(' ')[0] 95 | if check_proxy(argv[2]): 96 | print(Fore.LIGHTRED_EX + 'BAD PROXY ' + argv[2]) 97 | else: 98 | print(Fore.LIGHTGREEN_EX + 'GOOD PROXY ' + argv[2]) 99 | except IndexError: 100 | print(Fore.LIGHTRED_EX + 'Error! Missing proxy!') 101 | else: 102 | print(Fore.LIGHTRED_EX + 'Unknown option \"' + argv[1] + '\"') 103 | else: 104 | print_help() 105 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | colorama 2 | requests 3 | --------------------------------------------------------------------------------