Esempio n. 1
0
def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename): 
  cmd = settings.PS_VERSION
  if alter_shell:
    cmd = cmd.replace("'","\\'")
  else:
    cmd = "\"" + cmd + "\""
  #Command execution results.
  response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
  # Evaluate injection results.
  if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None:
    # Evaluate injection results.
    ps_version = cb_injector.injection_results(response, TAG)
    ps_version = "".join(str(p) for p in ps_version)
    session_handler.store_cmd(url, cmd, ps_version, vuln_parameter)
  else:
    ps_version = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
  try:
    if float(ps_version):
      settings.PS_ENABLED = True
      if menu.options.verbose:
        print ""
      # Output PowerShell's version number
      sys.stdout.write(Style.BRIGHT + "(!) The PowerShell's version number is " + Style.UNDERLINE +  ps_version + Style.RESET_ALL + Style.BRIGHT + Style.RESET_ALL + ".\n")
      sys.stdout.flush()
      # Add infos to logs file. 
      output_file = open(filename, "a")
      output_file.write("    (!) The PowerShell's version number is " + ps_version + ".\n")
      output_file.close()
  except ValueError:
    print Fore.YELLOW + settings.WARNING_SIGN + "Heuristics have failed to identify PowerShell's version, which means that some payloads or injection techniques may be failed." + Style.RESET_ALL 
    settings.PS_ENABLED = False
    checks.ps_check_failed()
Esempio n. 2
0
def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename): 
  cmd = settings.PS_VERSION
  if alter_shell:
    cmd = cmd.replace("'","\\'")
  else:
    cmd = "\"" + cmd + "\""
  #Command execution results.
  response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
  # Evaluate injection results.
  ps_version = cb_injector.injection_results(response, TAG)
  try:
    ps_version = "".join(str(p) for p in ps_version)
    if float(ps_version):
      settings.PS_ENABLED = True
      if menu.options.verbose:
        print ""
      # Output PowerShell's version number
      sys.stdout.write(Style.BRIGHT + "(!) The PowerShell's version number is " + Style.UNDERLINE +  ps_version + Style.RESET_ALL + Style.BRIGHT + Style.RESET_ALL + ".\n")
      sys.stdout.flush()
      # Add infos to logs file. 
      output_file = open(filename, "a")
      output_file.write("    (!) The PowerShell's version number is " + ps_version + ".\n")
      output_file.close()
  except ValueError:
    print Fore.YELLOW + "(^) Warning: Heuristics have failed to identify PowerShell's version, which means that some payloads or injection techniques may be failed." + Style.RESET_ALL 
    settings.PS_ENABLED = False
    checks.ps_check_failed()
Esempio n. 3
0
def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename): 
  cmd = settings.PS_VERSION
  if alter_shell:
    cmd = cmd.replace("'","\\'")
  #Command execution results.
  response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
  # Evaluate injection results.
  if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None:
    # Evaluate injection results.
    ps_version = cb_injector.injection_results(response, TAG, cmd)
    ps_version = "".join(str(p) for p in ps_version)
    session_handler.store_cmd(url, cmd, ps_version, vuln_parameter)
  else:
    ps_version = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
  try:
    if float(ps_version):
      settings.PS_ENABLED = True
      if settings.VERBOSITY_LEVEL >= 1:
        print ""
      # Output PowerShell's version number
      success_msg = "The PowerShell's version number is " 
      success_msg += ps_version + Style.RESET_ALL + Style.BRIGHT
      sys.stdout.write(settings.print_success_msg(success_msg) + ".\n")
      sys.stdout.flush()
      # Add infos to logs file. 
      output_file = open(filename, "a")
      success_msg = "The PowerShell's version number is " + ps_version + ".\n"
      output_file.write("    " + re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.SUCCESS_SIGN) + success_msg)
      output_file.close()
  except ValueError:
    warn_msg = "Heuristics have failed to identify PowerShell's version, "
    warn_msg += "which means that some payloads or injection techniques may be failed."
    print settings.print_warning_msg(warn_msg)
    settings.PS_ENABLED = False
    checks.ps_check_failed()
Esempio n. 4
0
def powershell_version(separator, TAG, prefix, suffix, whitespace,
                       http_request_method, url, vuln_parameter, alter_shell,
                       filename, delay):
    cmd = settings.PS_VERSION
    if alter_shell:
        cmd = cmd.replace("'", "\\'")
    else:
        cmd = "\"" + cmd + "\""
    #Command execution results.
    response = eb_injector.injection(separator, TAG, cmd, prefix, suffix,
                                     whitespace, http_request_method, url,
                                     vuln_parameter, alter_shell, filename)
    # Evaluate injection results.
    if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None:
        # Perform target page reload (if it is required).
        if settings.URL_RELOAD:
            response = requests.url_reload(url, delay)
        # Evaluate injection results.
        ps_version = eb_injector.injection_results(response, TAG, cmd)
        ps_version = "".join(str(p) for p in ps_version).replace(" ", "",
                                                                 1)[:-1]
        session_handler.store_cmd(url, cmd, ps_version, vuln_parameter)
    else:
        ps_version = session_handler.export_stored_cmd(url, cmd,
                                                       vuln_parameter)
    try:
        if float(ps_version):
            settings.PS_ENABLED = True
            if settings.VERBOSITY_LEVEL >= 1:
                print ""
            # Output PowerShell's version number
            success_msg = "The PowerShell's version number is "
            success_msg += ps_version + Style.RESET_ALL + Style.BRIGHT
            sys.stdout.write(settings.print_success_msg(success_msg) + ".\n")
            sys.stdout.flush()
            # Add infos to logs file.
            output_file = open(filename, "a")
            success_msg = "The PowerShell's version number is " + ps_version + ".\n"
            output_file.write(
                "    " +
                re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub(
                    "", settings.SUCCESS_SIGN) + success_msg)
            output_file.close()
    except ValueError:
        warn_msg = "Heuristics have failed to identify PowerShell's version, "
        warn_msg += "which means that some payloads or injection techniques may be failed."
        print settings.print_warning_msg(warn_msg)
        settings.PS_ENABLED = False
        checks.ps_check_failed()
Esempio n. 5
0
def powershell_version(separator, TAG, prefix, suffix, whitespace,
                       http_request_method, url, vuln_parameter, alter_shell,
                       filename, timesec):
    cmd = settings.PS_VERSION
    if alter_shell:
        cmd = cmd.replace("'", "\\'")
    # Evaluate injection results.
    if session_handler.export_stored_cmd(
            url, cmd, vuln_parameter) == None or menu.options.ignore_session:
        # Command execution results.
        response = cb_injector.injection(separator, TAG, cmd, prefix, suffix,
                                         whitespace, http_request_method, url,
                                         vuln_parameter, alter_shell, filename)
        # Perform target page reload (if it is required).
        if settings.URL_RELOAD:
            response = requests.url_reload(url, timesec)
        # Evaluate injection results.
        ps_version = cb_injector.injection_results(response, TAG, cmd)
        ps_version = "".join(str(p) for p in ps_version)
        session_handler.store_cmd(url, cmd, ps_version, vuln_parameter)
    else:
        ps_version = session_handler.export_stored_cmd(url, cmd,
                                                       vuln_parameter)
    try:
        if float(ps_version):
            settings.PS_ENABLED = True
            # Output PowerShell's version number
            info_msg = "The PowerShell's version number is "
            info_msg += ps_version + Style.RESET_ALL + Style.BRIGHT
            sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
            sys.stdout.flush()
            # Add infos to logs file.
            output_file = open(filename, "a")
            info_msg = "The PowerShell's version number is " + ps_version + ".\n"
            output_file.write(
                re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub(
                    "", settings.INFO_BOLD_SIGN) + info_msg)
            output_file.close()
    except ValueError:
        warn_msg = "Heuristics have failed to identify the version of Powershell, "
        warn_msg += "which means that some payloads or injection techniques may be failed."
        print(settings.print_warning_msg(warn_msg))
        settings.PS_ENABLED = False
        checks.ps_check_failed()