Skip to content

Commit ce282c6

Browse files
committed
* Fixed proxy authentication check
1 parent 190b0ed commit ce282c6

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

_updates.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,7 @@ def check_updates():
106106
logging.warning("Failed to check for updates.", exc_info=traceback)
107107
return False
108108

109-
if r.status == 407:
110-
jexboss.print_and_flush(RED + BOLD + " * Error: Proxy authentication is required. \n"
111-
" Please enter the correct login and password for authentication. \n"
112-
" Example: -P http://proxy.com:3128 -L username:password\n" + ENDC)
113-
logging.error("Proxy authentication failed")
114-
exit(1)
115-
elif r.status != 200:
109+
if r.status != 200:
116110
jexboss.print_and_flush(RED + " * Error: could not check for updates ...\n" + ENDC)
117111
logging.warning("Failed to check for updates. HTTP Code: %s" % r.status)
118112
return False

jexboss.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
logging.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

4343
RED = '\x1b[91m'
4444
RED1 = '\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+
130160
def 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

Comments
 (0)