Login Register






Simple Proxy Checker filter_list
Author
Message
Simple Proxy Checker #1
Hey there, I made a simple proxy checker in Python.
Save the proxies like that in the proxylist.txt:
Code:
IP:PORT

Spoiler:
Code:
import socket import os.path class ProxyChecker():     def __init__(self):         print("Starting the checker...")     def CheckProxy(self):         try:             with open('proxylist.txt', 'r+') as f:                 for line in f.readlines():                     ipAddress = str.split(line, ':')[0]                     port = str.split(line, ':')[1]                     proxyIP = (ipAddress, int(port))                     s = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)                     s.settimeout(5)                     print("[!] - Checking {} ...".format(proxyIP))                     if s.connect_ex(proxyIP):                         pass                     else:                         self.AddProxy(ipAddress + ":" + str(port))         except IOError:             print('proxylist.txt not found')     def AddProxy(self, proxyAddress):         with open('positive.txt', 'a') as f:             #Duplicate Check:             with open('positive.txt', 'r+') as r:                 if proxyAddress in r.readlines():                     print("[!] - {} already added!".format(proxyAddress))                 else:                     print("[+] - {} added!".format(proxyAddress))                     f.write(proxyAddress) if __name__ == "__main__":     ProxyChecker().CheckProxy()
[Image: i446OyG.png]

[+] 1 user Likes Leviathan's post
Reply

RE: Simple Proxy Checker #2
Learn this language by myself or take courses?

Reply

RE: Simple Proxy Checker #3
(01-22-2021, 07:07 PM)Oliver45U Wrote: Learn this language by myself or take courses?

Python is a very simple language and a very good place to start your coding journey. There are plenty of online resources including hackerrank.com where you can learn for free without having to install python on your pc. I do suggest you download Visual Studio Code to use as your IDE as the debugging is very good.
Code:
  _______              _   _________   \      \            | | /        /   |      | _____  ____| | |   ____/ _____  _____  _____  _____   |   |  |/  _  \/      | \____   |/     \/     \/  ___\/  _  \   |      |    __/|  |   |/        |   |  |   |   \  \__ |   __/  /_______/\_____/\____|_/________/|  ____/\_____|_\____/\_____/                                   | |                                   |_/                         BTC Address:  bc1qds8uqnt4ga0zn9ftrm45cq9u9hfct0qluqes5a

Reply

RE: Simple Proxy Checker #4
(08-18-2019, 08:47 AM)Leviathan Wrote: Hey there, I made a simple proxy checker in Python.

Hi. I like your script and thought it could do with some more functionality. It now allows users to specify input file name, output file name, verbosity, and timeout with default value of 2s. If a proxy server takes more than 2 seconds to reply it's not worth using. I also added the shebang so just run "./scriptname -h" to get the help message up (Linux only). Also, put it in /bin/ so you can just run "scriptname" from anywhere. Again, Linux only.

Code:
#! /usr/bin/python3 import socket import os.path import argparse as arg class ProxyChecker(): def __init__(self): print("Starting the checker...") def CheckProxy(self, file, timeout, verbose, output): try: with open(file, 'r') as f: for line in f.readlines(): ipAddress = str.split(line, ':')[0] port = str.split(line, ':')[1] proxyIP = (ipAddress, int(port)) s = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM) s.settimeout(timeout) if verbose: print("[!] - Checking {} ...".format(proxyIP)) if s.connect_ex(proxyIP): pass else: self.AddProxy(ipAddress + ":" + str(port), verbose, output) except IOError: print(file + ' not found') def AddProxy(self, proxyAddress, verbose, output): with open(output, 'a') as f: #Duplicate Check: with open(output, 'r+') as r: if proxyAddress in r.readlines(): if verbose: print("[!] - {} already added!".format(proxyAddress)) else: if verbose: print("[+] - {} added!".format(proxyAddress)) f.write(proxyAddress) def main(): parser = arg.ArgumentParser() parser.add_argument("--file", "-f", type=str, required=True, help="File to check.") parser.add_argument("--timeout", "-t", type=int, default=2, help="Integer time out value, default value is 2 seconds.") parser.add_argument("--output", "-o", default="positive.txt", help="Output filename, default is 'positive.txt'") parser.add_argument("--verbose", "-v", default=False, action="store_true", help="Print proxies as they are checked and added.") args = parser.parse_args() file = args.file timeout = args.timeout verbose = args.verbose output = args.output ProxyChecker().CheckProxy(file, timeout, verbose, output) print("Done!") if __name__ == "__main__": main()
Code:
  _______              _   _________   \      \            | | /        /   |      | _____  ____| | |   ____/ _____  _____  _____  _____   |   |  |/  _  \/      | \____   |/     \/     \/  ___\/  _  \   |      |    __/|  |   |/        |   |  |   |   \  \__ |   __/  /_______/\_____/\____|_/________/|  ____/\_____|_\____/\_____/                                   | |                                   |_/                         BTC Address:  bc1qds8uqnt4ga0zn9ftrm45cq9u9hfct0qluqes5a

[+] 2 users Like DedSpace's post
Reply