Module: Risu::Templates::SharesTemplateHelper

Included in:
TemplateHelper
Defined in:
lib/risu/base/shares_template_helper.rb

Instance Method Summary collapse

Instance Method Details

#anon_ftp_countObject



26
27
28
29
30
31
32
# File 'lib/risu/base/shares_template_helper.rb', line 26

def anon_ftp_count
	begin
		return Item.where(:plugin_id => Plugin.where(:plugin_name => "Anonymous FTP Enabled").first.id).count
	rescue
		return 0
	end
end

#anon_ftp_sectionObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/risu/base/shares_template_helper.rb', line 35

def anon_ftp_section

	if anon_ftp_count() <= 0
		return
	end

	heading2 "Anonymous FTP Detection"

	findings =  Item.where(:plugin_id => Plugin.where(:plugin_name => "Anonymous FTP Enabled").first.id)

	findings.each do |finding|
		host = Host.find_by_id(finding.host_id)

		host_string = "#{host.name}"
		host_string << " (#{host.fqdn})" if host.fqdn != nil

		text "Host", :style => :bold
		text host_string

		text "\n"

		text "Plugin Output", :style => :bold
		text finding.plugin_output

		text "\n"
	end
end

#anon_smb_countObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/risu/base/shares_template_helper.rb', line 69

def anon_smb_count
	count = 0
	begin
		anon_smb_query().each do |finding|
			host = Host.find_by_id(finding.host_id)

			 = host.host_properties.where(:name => 'smb-login-used').first.value
			 = .split("\\")[1] if .include?("\\")

			if finding.plugin_output.include?("The following shares can be accessed as #{}")
				# If the output was collect via the username that is authenitcated skip it.
				next
			end

			count = count + 1
		end
	rescue
		return 0
	end

	return count
end

#anon_smb_queryObject



64
65
66
# File 'lib/risu/base/shares_template_helper.rb', line 64

def anon_smb_query
	return Item.where(:plugin_id => Plugin.where(:plugin_name => "Microsoft Windows SMB Shares Unprivileged Access").first.id)
end

#anon_smb_sectionObject



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/risu/base/shares_template_helper.rb', line 93

def anon_smb_section
	if anon_smb_count() <= 0
		return
	end

	heading2 "Anonymous SMB Share Detection"

	anon_smb_query().each do |finding|
		host = Host.find_by_id(finding.host_id)

		 = host.host_properties.where(:name => 'smb-login-used').first.value
		 = .split("\\")[1] if .include?("\\")

		if finding.plugin_output.include?("The following shares can be accessed as #{}")
			# If the output was collect via the username that is authenitcated skip it.
			next
		end

		host_string = "#{host.name}"
		host_string << " (#{host.fqdn})" if host.fqdn != nil

		text "Host", :style => :bold
		text host_string

		text "\n"

		text "Plugin Output", :style => :bold
		text finding.plugin_output

		text "\n"
	end
end

#shares_appendix_sectionObject



171
172
173
174
# File 'lib/risu/base/shares_template_helper.rb', line 171

def shares_appendix_section
	anon_ftp_section
	anon_smb_section
end

#shares_sectionObject



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/risu/base/shares_template_helper.rb', line 126

def shares_section
	poor_count = 0

	anon_ftp_text = ""
	anon_smb_text = ""

	v_anon_smb_count = 0
	v_anon_ftp_count = 0

	begin
		v_anon_ftp_count = anon_ftp_count()
	rescue Exception => e
	end

	begin
		v_anon_smb_count = anon_smb_count()
	rescue Exception => e
	end

	if v_anon_ftp_count > 1
		anon_ftp_text = "Anonymous FTP was detected as being enabled on #{anon_ftp_count} network nodes. Anonymous FTP allows anyone to access files stored on the FTP server, depending on the server's configuration also write files. "
		poor_count = poor_count + 1
	elsif v_anon_ftp_count == 1
		anon_ftp_text = "Anonymous FTP was detected as being enabled on #{anon_ftp_count} network node. Anonymous FTP allows anyone to access files stored on the FTP server, depending on the server's configuration also write files. "
		poor_count = poor_count + 1
	end

	if v_anon_smb_count > 1
		anon_smb_text = "Anonymous SMB shares were detected on #{anon_smb_count} network nodes. These shares also were found to have read and write access enabled. "
		poor_count = poor_count + 1
	elsif v_anon_smb_count == 1
		anon_smb_text = "Anonymous SMB shares were detected on #{anon_smb_count} network node. These shares also were found to have read and write access enabled. "
		poor_count = poor_count + 1
	end

	anonymous_access_text = "Allowing anonymous access to a file server can lead to information disclosures and other security violations. Each instance should be evaluated and removed or noted in the network's security policy.\n"

	heading1 "Other Findings of Interest" if poor_count > 0

	#Anon ftp/smb + clear text
	@output.text anon_ftp_text + anon_smb_text + anonymous_access_text if v_anon_ftp_count > 0 || v_anon_smb_count > 0
	@output.text "\n"
	@output.text "\n"
end

#shares_section_has_findings?Boolean

Returns:

  • (Boolean)


177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/risu/base/shares_template_helper.rb', line 177

def shares_section_has_findings?
	poor_count = 0

	anon_ftp_text = ""
	anon_smb_text = ""

	v_anon_smb_count = 0
	v_anon_ftp_count = 0

	begin
		v_anon_ftp_count = anon_ftp_count()
	rescue Exception => e
	end

	begin
		v_anon_smb_count = anon_smb_count()
	rescue Exception => e
	end

	if v_anon_ftp_count >= 1
		poor_count = poor_count + 1
	end

	if v_anon_smb_count >= 1
		poor_count = poor_count + 1
	end

	if poor_count >= 1
		return true
	else
		return false
	end
end