3838logging .basicConfig (filename = 'jexboss_' + str (datetime .datetime .today ().date ())+ '.log' , format = FORMAT , level = logging .INFO )
3939
4040__author__ = "João Filho Matos Figueiredo <[email protected] >" 41- __version = "1.1.2 "
41+ __version = "1.1.3 "
4242
4343RED = '\x1b [91m'
4444RED1 = '\033 [31m'
@@ -127,6 +127,36 @@ def get_random_user_agent():
127127 return user_agents [randint (0 , len (user_agents ) - 1 )]
128128
129129
130+ def is_proxy_ok ():
131+ print_and_flush (GREEN + "\n ** Checking proxy: %s **\n \n " % gl_args .proxy )
132+
133+ headers = {"Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" ,
134+ "Connection" : "keep-alive" ,
135+ "User-Agent" : get_random_user_agent ()}
136+ try :
137+ r = gl_http_pool .request ('GET' , gl_args .host , redirect = False , headers = headers )
138+ except :
139+ print_and_flush (RED + " * Error: Failed to connect to %s using proxy %s.\n "
140+ " See logs for more details...\n " % (gl_args .host ,gl_args .proxy ) + ENDC )
141+ logging .warning ("Failed to connect to %s using proxy" % gl_args .host , exc_info = traceback )
142+ return False
143+
144+ if r .status == 407 :
145+ print_and_flush (RED + " * Error 407: Proxy authentication is required. \n "
146+ " Please enter the correct login and password for authentication. \n "
147+ " Example: -P http://proxy.com:3128 -L username:password\n " + ENDC )
148+ logging .error ("Proxy authentication failed" )
149+ return False
150+
151+ elif r .status == 503 or r .status == 502 :
152+ print_and_flush (RED + " * Error %s: The service %s is not availabel to your proxy. \n "
153+ " See logs for more details...\n " % (r .status ,gl_args .host )+ ENDC )
154+ logging .error ("Service unavailable to your proxy" )
155+ return False
156+ else :
157+ return True
158+
159+
130160def configure_http_pool ():
131161
132162 global gl_http_pool
@@ -140,7 +170,7 @@ def configure_http_pool():
140170 # when using proxy, protocol should be informed
141171 if 'http' not in gl_args .host or 'http' not in gl_args .proxy :
142172 print_and_flush (RED + " * When using proxy, you must specify the http or https protocol"
143- " (eg. http://%s).\n \n " % (gl_args .host if 'http' not in gl_args .host else gl_args .proxy ) + ENDC )
173+ " (eg. http://%s).\n \n " % (gl_args .host if 'http' not in gl_args .host else gl_args .proxy ) + ENDC )
144174 logging .critical ('Protocol not specified' )
145175 exit (1 )
146176
@@ -646,4 +676,6 @@ def main():
646676 _updates .set_http_pool (gl_http_pool )
647677 _exploits .set_http_pool (gl_http_pool )
648678 banner ()
679+ if gl_args .proxy and not is_proxy_ok ():
680+ exit (1 )
649681 main ()
0 commit comments