-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxyTest.py
136 lines (119 loc) · 3.88 KB
/
proxyTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import requests
from selenium import webdriver
from requests.auth import HTTPBasicAuth
# from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.firefox.options import Options
import zipfile, random, string, time
username = "lum-customer-rubelrana-zone-rubel3-country-us-state-NY-city-buffalo-session-"
char_set = string.ascii_lowercase
ext = random.sample(char_set * 8, 8)
ext = ''.join(ext)
PROXY_HOST = "zproxy.lum-superproxy.io"
PROXY_PORT = 22225
PROXY_USER = username + ext
PROXY_PASS = "o1ockrt34qhh"
print(PROXY_USER)
manifest_json = """
{
"version": "1.0.0",
"manifest_version": 2,
"name": "Chrome Proxy",
"permissions": [
"proxy",
"tabs",
"unlimitedStorage",
"storage",
"<all_urls>",
"webRequest",
"webRequestBlocking"
],
"background": {
"scripts": ["background.js"]
},
"minimum_chrome_version":"22.0.0"
}
"""
background_js = """
var config = {
mode: "fixed_servers",
rules: {
singleProxy: {
scheme: "http",
host: "%(host)s",
port: parseInt(%(port)d)
},
bypassList: ["foobar.com"]
}
};
browser.proxy.settings.set({value: config, scope: "regular"}, function() {});
function callbackFn(details) {
return {
authCredentials: {
username: "%(user)s",
password: "%(pass)s"
}
};
}
browser.webRequest.onAuthRequired.addListener(
callbackFn,
{urls: ["<all_urls>"]},
['blocking']
);
""" % {
"host": PROXY_HOST,
"port": PROXY_PORT,
"user": PROXY_USER,
"pass": PROXY_PASS,
}
pluginfile = 'proxy_auth_plugin.xpi'
with zipfile.ZipFile(pluginfile, 'w') as zp:
zp.writestr("manifest.json", manifest_json)
zp.writestr("background.js", background_js)
# co = Options()
# co.add_argument("--start-maximized")
# # co.add_extension(pluginfile)
# # ----- without image ----- (uncomment this)
# # prefs = {"profile.managed_default_content_settings.images": 2}
# # co.add_experimental_option("prefs", prefs)
profile = webdriver.FirefoxProfile()
profile.add_extension(extension=pluginfile)
driver = webdriver.Firefox(executable_path='geckodriver.exe', firefox_profile=profile)
# driver = webdriver.Chrome(chrome_options=co)
# PROXY_HOST = "zproxy.lum-superproxy.io"
# PROXY_PORT = 22225
# USERNAME = username + ext
# PASSWORD = "o1ockrt34qhh"
# PROXY = "127.0.0.1:24000"
# webdriver.DesiredCapabilities.FIREFOX['proxy']={
# "httpProxy":PROXY,
# "ftpProxy":PROXY,
# "sslProxy":PROXY,
# "noProxy":None,
# "proxyType":"MANUAL",
# }
# driver = webdriver.Firefox(executable_path='geckodriver.exe')
# driver.get('http://www.whatsmyip.org/')
# profile = webdriver.FirefoxProfile()
# profile.set_preference("network.proxy.type", 1)
# profile.set_preference("network.proxy.http", PROXY_HOST)
# profile.set_preference("network.proxy.http_port", PROXY_PORT)
# profile.set_preference("network.proxy.socks_username", USERNAME)
# profile.set_preference("network.proxy.socks_password", PASSWORD)
# profile.update_preferences()
# # executable_path = define the path if u don't already have in the PATH system variable.
# driver = webdriver.Firefox(executable_path='geckodriver.exe',firefox_profile=profile)
driver.get("https://whatismyipaddress.com/")
# # driver.maximize_window()
# WebDriverWait(driver, 50).until(EC.alert_is_present(), 'Timed out waiting for alerts to appear')
# alert=driver.switch_to.alert
# print("here")
# time.sleep(2)
# # alert.send_keys(USERNAME+webdriver.common.keys.Keys.TAB+PASSWORD)
# alert.send_keys(USERNAME)
# time.sleep(2)
# time.sleep("here1")
# alert.accept()
time.sleep(10000)
# return driver