Skip to content

Commit cf7cfa9

Browse files
committed
Add check() implementation based on bcoles notes
1 parent 0520d7c commit cf7cfa9

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

modules/exploits/linux/samba/is_known_pipename.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def initialize(info = {})
2424
[
2525
'steelo <knownsteelo[at]gmail.com>', # Vulnerability Discovery
2626
'hdm', # Metasploit Module
27+
'Brendan Coles <bcoles[at]gmail.com>', # Check logic
2728
],
2829
'License' => MSF_LICENSE,
2930
'References' =>
@@ -270,6 +271,54 @@ def find_payload
270271
end
271272
end
272273

274+
def check
275+
res = smb_fingerprint
276+
277+
unless res['native_lm'] =~ /Samba ([\d\.]+)/
278+
print_error("does not appear to be Samba: #{res['os']} / #{res['native_lm']}")
279+
return CheckCode::Safe
280+
end
281+
282+
samba_version = Gem::Version.new($1.gsub(/\.$/, ''))
283+
284+
vprint_status("Samba version identified as #{samba_version.to_s}")
285+
286+
if samba_version < Gem::Version.new('3.5.0')
287+
return CheckCode::Safe
288+
end
289+
290+
# Patched in 4.4.14
291+
if samba_version < Gem::Version.new('4.5.0') &&
292+
samba_version >= Gem::Version.new('4.4.14')
293+
return CheckCode::Safe
294+
end
295+
296+
# Patched in 4.5.10
297+
if samba_version > Gem::Version.new('4.5.0') &&
298+
samba_version < Gem::Version.new('4.6.0') &&
299+
samba_version >= Gem::Version.new('4.5.10')
300+
return CheckCode::Safe
301+
end
302+
303+
# Patched in 4.6.4
304+
if samba_version >= Gem::Version.new('4.6.4')
305+
return CheckCode::Safe
306+
end
307+
308+
connect
309+
smb_login
310+
find_writeable_share_path
311+
disconnect
312+
313+
if @share.to_s.length == 0
314+
print_status("Samba version #{samba_version.to_s} found, but no writeable share has been identified")
315+
return CheckCode::Detected
316+
end
317+
318+
print_good("Samba version #{samba_version.to_s} found with writeable share '#{@share}'")
319+
return CheckCode::Appears
320+
end
321+
273322
def exploit
274323
# Setup SMB
275324
connect

0 commit comments

Comments
 (0)