Write proxychains.conf

This commit is contained in:
agatha 2023-11-09 17:52:44 -05:00
parent 1464f16371
commit 1549877f26

17
main.py
View File

@ -7,11 +7,11 @@ import logging
from harvester.proxy import fetch_all, validate_socks from harvester.proxy import fetch_all, validate_socks
def load_urls(path): def read_file(path):
with open(path, 'r', encoding='utf-8') as file: with open(path, 'r', encoding='utf-8') as file:
urls = [line.strip() for line in file.readlines()] data = [line.strip() for line in file.readlines()]
return urls return data
def write_file(path, data): def write_file(path, data):
@ -24,7 +24,7 @@ def main():
logging.basicConfig(level=logging.WARN) logging.basicConfig(level=logging.WARN)
# Load proxy source list and fetch proxies # Load proxy source list and fetch proxies
urls = load_urls('data/proxy-sources.txt') urls = read_file('data/proxy-sources.txt')
proxies = fetch_all(urls) proxies = fetch_all(urls)
print(f'Fetched {len(proxies)} proxies!') print(f'Fetched {len(proxies)} proxies!')
@ -52,8 +52,13 @@ def main():
path=f'proxies/valid-socks-{time.strftime("%Y%m%d%H%M%S")}.txt', path=f'proxies/valid-socks-{time.strftime("%Y%m%d%H%M%S")}.txt',
data='\n'.join(valid) data='\n'.join(valid)
) )
for proxy in valid: # Write proxychains conf
print(proxy) proxychains_template = read_file('templates/proxychains.conf')
proxychains_data = [f'socks5 {proxy.replace(":", " ")}' for proxy in proxies]
write_file(
path=f'proxies/proxychains-{time.strftime("%Y%m%d%H%M%S")}.conf',
data='\n'.join(proxychains_template + proxychains_data)
)
if __name__ == '__main__': if __name__ == '__main__':