Write proxychains.conf
This commit is contained in:
parent
1464f16371
commit
1549877f26
17
main.py
17
main.py
@ -7,11 +7,11 @@ import logging
|
||||
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:
|
||||
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):
|
||||
@ -24,7 +24,7 @@ def main():
|
||||
logging.basicConfig(level=logging.WARN)
|
||||
|
||||
# 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)
|
||||
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',
|
||||
data='\n'.join(valid)
|
||||
)
|
||||
for proxy in valid:
|
||||
print(proxy)
|
||||
# Write proxychains conf
|
||||
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__':
|
||||
|
Loading…
Reference in New Issue
Block a user