@@ -11,6 +11,7 @@ class Metasploit3 < Msf::Auxiliary
11
11
12
12
# Exploit mixins should be called first
13
13
include Msf ::Exploit ::Remote ::SMB
14
+ include Msf ::Exploit ::Remote ::SMB ::Authenticated
14
15
include Msf ::Auxiliary ::Scanner
15
16
include Msf ::Auxiliary ::Report
16
17
@@ -33,6 +34,7 @@ def initialize
33
34
'Author' =>
34
35
[
35
36
'patrick' ,
37
+ 'j0hn__f'
36
38
] ,
37
39
'References' =>
38
40
[
@@ -47,44 +49,56 @@ def initialize
47
49
48
50
end
49
51
50
- def run_host ( ip )
51
-
52
- vprint_status ( "Connecting to the server..." )
53
-
52
+ def check_path ( path )
54
53
begin
55
- connect ( )
56
- smb_login ( )
57
-
58
- vprint_status ( "Mounting the remote share \\ \\ #{ datastore [ 'RHOST' ] } \\ #{ datastore [ 'SMBSHARE' ] } '..." )
59
- self . simple . connect ( "\\ \\ #{ rhost } \\ #{ datastore [ 'SMBSHARE' ] } " )
60
-
61
- vprint_status ( "Checking for file/folder #{ datastore [ 'RPATH' ] } ..." )
62
-
63
- if ( fd = simple . open ( "\\ #{ datastore [ 'RPATH' ] } " , 'o' ) ) # mode is open only - do not create/append/write etc
64
- print_good ( "File FOUND: \\ \\ #{ rhost } \\ #{ datastore [ 'SMBSHARE' ] } \\ #{ datastore [ 'RPATH' ] } " )
65
- fd . close
66
- end
67
- rescue ::Rex ::HostUnreachable
68
- vprint_error ( "Host #{ rhost } offline." )
69
- rescue ::Rex ::Proto ::SMB ::Exceptions ::LoginError
70
- vprint_error ( "Host #{ rhost } login error." )
54
+ if ( fd = simple . open ( "\\ #{ path } " , 'o' ) ) # mode is open only - do not create/append/write etc
55
+ print_good ( "File FOUND: \\ \\ #{ rhost } \\ #{ datastore [ 'SMBSHARE' ] } \\ #{ path } " )
56
+ fd . close
57
+ end
71
58
rescue ::Rex ::Proto ::SMB ::Exceptions ::ErrorCode => e
72
- if e . get_error ( e . error_code ) == "STATUS_FILE_IS_A_DIRECTORY"
73
- print_good ( "Directory FOUND: \\ \\ #{ rhost } \\ #{ datastore [ 'SMBSHARE' ] } \\ #{ datastore [ 'RPATH' ] } " )
74
- elsif e . get_error ( e . error_code ) == "STATUS_OBJECT_NAME_NOT_FOUND"
75
- vprint_error ( "Object \\ \\ #{ rhost } \\ #{ datastore [ 'SMBSHARE' ] } \\ #{ datastore [ 'RPATH' ] } NOT found!" )
76
- elsif e . get_error ( e . error_code ) == "STATUS_OBJECT_PATH_NOT_FOUND"
77
- vprint_error ( "Object PATH \\ \\ #{ rhost } \\ #{ datastore [ 'SMBSHARE' ] } \\ #{ datastore [ 'RPATH' ] } NOT found!" )
78
- elsif e . get_error ( e . error_code ) == "STATUS_ACCESS_DENIED"
59
+ case e . get_error ( e . error_code )
60
+ when "STATUS_FILE_IS_A_DIRECTORY"
61
+ print_good ( "Directory FOUND: \\ \\ #{ rhost } \\ #{ datastore [ 'SMBSHARE' ] } \\ #{ path } " )
62
+ when "STATUS_OBJECT_NAME_NOT_FOUND"
63
+ vprint_error ( "Object \\ \\ #{ rhost } \\ #{ datastore [ 'SMBSHARE' ] } \\ #{ path } NOT found!" )
64
+ when "STATUS_OBJECT_PATH_NOT_FOUND"
65
+ vprint_error ( "Object PATH \\ \\ #{ rhost } \\ #{ datastore [ 'SMBSHARE' ] } \\ #{ path } NOT found!" )
66
+ when "STATUS_ACCESS_DENIED"
79
67
vprint_error ( "Host #{ rhost } reports access denied." )
80
- elsif e . get_error ( e . error_code ) == "STATUS_BAD_NETWORK_NAME"
68
+ when "STATUS_BAD_NETWORK_NAME"
81
69
vprint_error ( "Host #{ rhost } is NOT connected to #{ datastore [ 'SMBDomain' ] } !" )
82
- elsif e . get_error ( e . error_code ) == "STATUS_INSUFF_SERVER_RESOURCES"
70
+ when "STATUS_INSUFF_SERVER_RESOURCES"
83
71
vprint_error ( "Host #{ rhost } rejected with insufficient resources!" )
72
+ when "STATUS_OBJECT_NAME_INVALID"
73
+ vprint_error ( "opeining \\ #{ path } bad filename" )
84
74
else
85
75
raise e
86
76
end
87
77
end
88
78
end
89
79
80
+ def run_host ( ip )
81
+ vprint_status ( "Connecting to the server..." )
82
+
83
+ begin
84
+ connect
85
+ smb_login
86
+
87
+ vprint_status ( "Mounting the remote share \\ \\ #{ datastore [ 'RHOST' ] } \\ #{ datastore [ 'SMBSHARE' ] } '..." )
88
+ self . simple . connect ( "\\ \\ #{ rhost } \\ #{ datastore [ 'SMBSHARE' ] } " )
89
+ vprint_status ( "Checking for file/folder #{ datastore [ 'RPATH' ] } ..." )
90
+
91
+ datastore [ 'RPATH' ] . each_line do |path |
92
+ check_path ( path . chomp )
93
+ end #end do
94
+ rescue ::Rex ::HostUnreachable
95
+ vprint_error ( "Host #{ rhost } offline." )
96
+ rescue ::Rex ::Proto ::SMB ::Exceptions ::LoginError
97
+ print_error ( "Host #{ rhost } login error." )
98
+ rescue ::Rex ::ConnectionRefused
99
+ print_error "Host #{ rhost } unable to connect - connection refused"
100
+ rescue ::Rex ::Proto ::SMB ::Exceptions ::ErrorCode
101
+ print_error "Host #{ rhost } unable to connect to share #{ datastore [ 'SMBSHARE' ] } "
102
+ end # end begin
103
+ end # end def
90
104
end
0 commit comments