Created
September 22, 2017 18:44
-
-
Save mIcHyAmRaNe/fa13dfe76474193e8f1a87ff3b95dc70 to your computer and use it in GitHub Desktop.
Python3: choice between tor , http/https proxies or direct connections to execute instructions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
try: | |
import os | |
os.path.abspath(__file__) #just to remember it :D (i have a bad memory ^^) | |
import urllib.request, urllib.error, urllib.parse | |
import requests | |
import socket | |
import socks | |
import sys | |
from urllib.request import urlopen | |
from colorama import Fore, Back, Style | |
except(): | |
exit( Fore.RED+'\n [x] Session Cancelled; Something wrong with import modules') #exit if cant load one of the modules above | |
try: | |
choice='' | |
while (choice not in ['1','2','3','tor','proxy']): | |
choice=input(Fore.YELLOW+''' | |
[1] tor | |
[2] proxy | |
[3] nothing | |
┌─[choose one option] ~$ ''') | |
if choice=='1' or choice=='tor': | |
socks.set_default_proxy(socks.SOCKS5, 'localhost', 9050) | |
socket.socket = socks.socksocket | |
urllib.request.urlopen | |
proxies="" | |
elif choice=='2' or choice=='proxy': | |
prox=input(' └──► set your HTTP proxy {example:127.0.0.1:80} : ~$ ') | |
proxies = { | |
'http': 'http://'+prox, | |
'https': 'http://'+prox, | |
} | |
else: | |
proxies="" | |
continue | |
try: | |
print(Fore.CYAN+' └─────►',requests.get('http://ip.42.pl/raw', proxies=proxies, timeout=15).text) | |
except (ConnectionError, HTTPError, Timeout): | |
print (Fore.RED+'\n [x] Server not responding') | |
except (KeyboardInterrupt, SystemExit): | |
print (Fore.RED+'\n [!] Session Cancelled; Unknown error') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment