本文整理汇总了Python中src.utils.settings.print_error_msg函数的典型用法代码示例。如果您正苦于以下问题:Python print_error_msg函数的具体用法?Python print_error_msg怎么用?Python print_error_msg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_error_msg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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_error_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_error_msg(err_msg)
continue_tests = checks.continue_tests(err)
if continue_tests == True:
settings.IGNORE_ERR_MSG = True
else:
os._exit(0)
示例2: continue_tests
def continue_tests(err):
# If defined "--ignore-401" option, ignores HTTP Error 401 (Unauthorized)
# and continues tests without providing valid credentials.
if menu.options.ignore_401:
settings.WAF_ENABLED = True
return True
# Possible WAF/IPS/IDS
if (str(err.code) == "403" or "406") and \
not menu.options.skip_waf:
# Check if "--skip-waf" option is defined
# that skips heuristic detection of WAF/IPS/IDS protection.
settings.WAF_ENABLED = True
warn_msg = "It seems that target is protected by some kind of WAF/IPS/IDS."
print settings.print_warning_msg(warn_msg)
try:
while True:
question_msg = "Do you want to ignore the error (" + str(err.code)
question_msg += ") message and continue the tests? [Y/n/q] > "
continue_tests = raw_input(settings.print_question_msg(question_msg)).lower()
if continue_tests in settings.CHOICE_YES:
return True
elif continue_tests in settings.CHOICE_NO:
return False
elif continue_tests in settings.CHOICE_QUIT:
return False
else:
if continue_tests == "":
continue_tests = "enter"
err_msg = "'" + continue_tests + "' is not a valid answer."
print settings.print_error_msg(err_msg) + "\n"
pass
except KeyboardInterrupt:
print "\n" + Back.RED + settings.ABORTION_SIGN + "Ctrl-C was pressed!" + Style.RESET_ALL
raise SystemExit()
示例3: ps_check
def ps_check():
if settings.PS_ENABLED == None and menu.options.is_admin or menu.options.users or menu.options.passwords:
if settings.VERBOSITY_LEVEL >= 1:
print ""
warn_msg = "The payloads in some options that you "
warn_msg += "have chosen, are requiring the use of PowerShell. "
print settings.print_warning_msg(warn_msg)
while True:
question_msg = "Do you want to use the \"--ps-version\" option "
question_msg += "so ensure that PowerShell is enabled? [Y/n/q] > "
sys.stdout.write(settings.print_question_msg(question_msg))
ps_check = sys.stdin.readline().replace("\n","").lower()
if ps_check in settings.CHOICE_YES:
menu.options.ps_version = True
break
elif ps_check in settings.CHOICE_NO:
break
elif ps_check in settings.CHOICE_QUIT:
print ""
os._exit(0)
else:
if ps_check == "":
ps_check = "enter"
err_msg = "'" + ps_check + "' is not a valid answer."
print settings.print_error_msg(err_msg)
pass
示例4: exploitation
def exploitation(url, delay, filename, http_request_method, url_time_response):
if url_time_response >= settings.SLOW_TARGET_RESPONSE:
warn_msg = "It is highly recommended, due to serious response delays, "
warn_msg += "to skip the time-based (blind) technique and to continue "
warn_msg += "with the file-based (semiblind) technique."
print settings.print_warning_msg(warn_msg)
go_back = False
while True:
if go_back == True:
return False
question_msg = "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
proceed_option = raw_input(settings.print_question_msg(question_msg)).lower()
if proceed_option.lower() in settings.CHOICE_PROCEED :
if proceed_option.lower() == "s":
from src.core.injections.semiblind.techniques.file_based import fb_handler
fb_handler.exploitation(url, delay, filename, http_request_method, url_time_response)
elif proceed_option.lower() == "c":
if tb_injection_handler(url, delay, filename, http_request_method, url_time_response) == False:
return False
elif proceed_option.lower() == "q":
raise SystemExit()
else:
if proceed_option == "":
proceed_option = "enter"
err_msg = "'" + proceed_option + "' is not a valid answer."
print settings.print_error_msg(err_msg) + "\n"
pass
else:
if tb_injection_handler(url, delay, filename, http_request_method, url_time_response) == False:
return False
示例5: 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()
# Check if defined "--force-ssl" option AND "--proxy" option.
# We then force the proxy to https
if menu.options.force_ssl and menu.options.proxy:
settings.PROXY_PROTOCOL = 'https'
else:
print "[" + Fore.RED + " FAILED " + Style.RESET_ALL + "]"
err_msg = "Could not connect to proxy."
print settings.print_error_msg(err_msg)
sys.exit(0)
示例6: define_py_working_dir
def define_py_working_dir():
if settings.TARGET_OS == "win" and menu.options.alter_shell:
while True:
if not menu.options.batch:
question_msg = "Do you want to use '" + settings.WIN_PYTHON_DIR
question_msg += "' as Python working directory on the target host? [Y/n] > "
sys.stdout.write(settings.print_question_msg(question_msg))
python_dir = sys.stdin.readline().replace("\n","").lower()
else:
python_dir = ""
if len(python_dir) == 0:
python_dir = "y"
if python_dir in settings.CHOICE_YES:
break
elif python_dir in settings.CHOICE_NO:
question_msg = "Please provide a custom working directory for Python (e.g. '"
question_msg += settings.WIN_PYTHON_DIR + "') > "
sys.stdout.write(settings.print_question_msg(question_msg))
settings.WIN_PYTHON_DIR = sys.stdin.readline().replace("\n","").lower()
break
else:
err_msg = "'" + python_dir + "' is not a valid answer."
print settings.print_error_msg(err_msg)
pass
settings.USER_DEFINED_PYTHON_DIR = True
# eof
示例7: check_for_update
def check_for_update():
try:
response = urllib2.urlopen('https://raw.githubusercontent.com/stasinopoulos/commix/master/src/utils/settings.py')
version_check = response.readlines()
for line in version_check:
line = line.rstrip()
if "VERSION = " in line:
update_version = line.replace("VERSION = ", "").replace("\"", "")
break
if float(settings.VERSION.replace(".","")) < float(update_version.replace(".","")):
warn_msg = "Current version seems to be out-of-date."
print settings.print_warning_msg(warn_msg)
while True:
question_msg = "Do you want to update to the latest version now? [Y/n] > "
sys.stdout.write(settings.print_question_msg(question_msg))
do_update = sys.stdin.readline().replace("\n","").lower()
if do_update in settings.CHOICE_YES:
updater()
os._exit(0)
elif do_update in settings.CHOICE_NO:
break
else:
if do_update == "":
do_update = "enter"
err_msg = "'" + do_update + "' is not a valid answer."
print settings.print_error_msg(err_msg)
pass
except:
print ""
pass
# eof
示例8: process_json_data
def process_json_data():
while True:
success_msg = "JSON data found in POST data."
if not menu.options.batch:
question_msg = success_msg
question_msg += " Do you want to process it? [Y/n] > "
sys.stdout.write(settings.print_question_msg(question_msg))
json_process = sys.stdin.readline().replace("\n","").lower()
else:
if settings.VERBOSITY_LEVEL >= 1:
print settings.print_success_msg(success_msg)
json_process = ""
if len(json_process) == 0:
json_process = "y"
if json_process in settings.CHOICE_YES:
settings.IS_JSON = True
break
elif json_process in settings.CHOICE_NO:
break
elif json_process in settings.CHOICE_QUIT:
raise SystemExit()
else:
err_msg = "'" + json_process + "' is not a valid answer."
print settings.print_error_msg(err_msg)
pass
示例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_error_msg(err_msg)
raise SystemExit()
示例10: mobile_user_agents
def mobile_user_agents():
print """---[ """ + Style.BRIGHT + Fore.BLUE + """Available Mobile HTTP User-Agent headers""" + Style.RESET_ALL + """ ]---
Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' for BlackBerry 9900 HTTP User-Agent header.
Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' for Samsung Galaxy S HTTP User-Agent header.
Type '""" + Style.BRIGHT + """3""" + Style.RESET_ALL + """' for HP iPAQ 6365 HTTP User-Agent header.
Type '""" + Style.BRIGHT + """4""" + Style.RESET_ALL + """' for HTC Sensation HTTP User-Agent header.
Type '""" + Style.BRIGHT + """5""" + Style.RESET_ALL + """' for Apple iPhone 4s HTTP User-Agent header.
Type '""" + Style.BRIGHT + """6""" + Style.RESET_ALL + """' for Google Nexus 7 HTTP User-Agent header.
Type '""" + Style.BRIGHT + """7""" + Style.RESET_ALL + """' for Nokia N97 HTTP User-Agent header.
"""
while True:
question_msg = "Which mobile HTTP User-Agent header do you want to use? "
sys.stdout.write(settings.print_question_msg(question_msg))
mobile_user_agent = sys.stdin.readline().replace("\n","").lower()
try:
if int(mobile_user_agent) in range(0,len(settings.MOBILE_USER_AGENT_LIST)):
return settings.MOBILE_USER_AGENT_LIST[int(mobile_user_agent)]
elif mobile_user_agent.lower() == "q":
raise SystemExit()
else:
err_msg = "'" + mobile_user_agent + "' is not a valid answer."
print settings.print_error_msg(err_msg)
pass
except ValueError:
err_msg = "'" + mobile_user_agent + "' is not a valid answer."
print settings.print_error_msg(err_msg)
pass
示例11: 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_error_msg(err_msg)
sys.exit(0)
示例12: flush
def flush(url):
try:
conn = sqlite3.connect(settings.SESSION_FILE)
tables = list(conn.execute("SELECT name FROM sqlite_master WHERE type is 'table'"))
conn.executescript(';'.join(["DROP TABLE IF EXISTS %s" %i for i in tables]))
conn.commit()
conn.close()
except sqlite3.OperationalError, err_msg:
print settings.print_error_msg(err_msg)
示例13: check_lport
def check_lport(lport):
try:
if float(lport):
settings.LPORT = lport
print "LPORT => " + settings.LPORT
return True
except ValueError:
err_msg = "The port must be numeric."
print settings.print_error_msg(err_msg) + "\n"
return False
示例14: check_lhost
def check_lhost(lhost):
parts = lhost.split('.')
if len(parts) == 4 and all(part.isdigit() for part in parts) and all(0 <= int(part) <= 255 for part in parts):
settings.LHOST = lhost
print "LHOST => " + settings.LHOST
return True
else:
err_msg = "The IP format is not valid."
print settings.print_error_msg(err_msg) + "\n"
return False
示例15: check_srvport
def check_srvport(srvport):
try:
if float(srvport):
settings.SRVPORT = srvport
print "SRVPORT => " + settings.SRVPORT
return True
except ValueError:
err_msg = "The provided port must be numeric (i.e. 1234)"
print settings.print_error_msg(err_msg)
return False