@@ -49,6 +49,34 @@ def initialize
49
49
50
50
end
51
51
52
+ def check_path ( path )
53
+ begin
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
58
+ rescue ::Rex ::Proto ::SMB ::Exceptions ::ErrorCode => e
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"
67
+ vprint_error ( "Host #{ rhost } reports access denied." )
68
+ when "STATUS_BAD_NETWORK_NAME"
69
+ vprint_error ( "Host #{ rhost } is NOT connected to #{ datastore [ 'SMBDomain' ] } !" )
70
+ when "STATUS_INSUFF_SERVER_RESOURCES"
71
+ vprint_error ( "Host #{ rhost } rejected with insufficient resources!" )
72
+ when "STATUS_OBJECT_NAME_INVALID"
73
+ vprint_error ( "opeining \\ #{ path } bad filename" )
74
+ else
75
+ raise e
76
+ end
77
+ end
78
+ end
79
+
52
80
def run_host ( ip )
53
81
vprint_status ( "Connecting to the server..." )
54
82
@@ -61,33 +89,7 @@ def run_host(ip)
61
89
vprint_status ( "Checking for file/folder #{ datastore [ 'RPATH' ] } ..." )
62
90
63
91
datastore [ 'RPATH' ] . each_line do |path |
64
- path . chomp!
65
-
66
- begin
67
- if ( fd = simple . open ( "\\ #{ path . chomp } " , 'o' ) ) # mode is open only - do not create/append/write etc
68
- print_good ( "File FOUND: \\ \\ #{ rhost } \\ #{ datastore [ 'SMBSHARE' ] } \\ #{ path } " )
69
- fd . close
70
- end
71
- rescue ::Rex ::Proto ::SMB ::Exceptions ::ErrorCode => e
72
- case e . get_error ( e . error_code )
73
- when "STATUS_FILE_IS_A_DIRECTORY"
74
- print_good ( "Directory FOUND: \\ \\ #{ rhost } \\ #{ datastore [ 'SMBSHARE' ] } \\ #{ path } " )
75
- when "STATUS_OBJECT_NAME_NOT_FOUND"
76
- vprint_error ( "Object \\ \\ #{ rhost } \\ #{ datastore [ 'SMBSHARE' ] } \\ #{ path } NOT found!" )
77
- when "STATUS_OBJECT_PATH_NOT_FOUND"
78
- vprint_error ( "Object PATH \\ \\ #{ rhost } \\ #{ datastore [ 'SMBSHARE' ] } \\ #{ path } NOT found!" )
79
- when "STATUS_ACCESS_DENIED"
80
- vprint_error ( "Host #{ rhost } reports access denied." )
81
- when "STATUS_BAD_NETWORK_NAME"
82
- vprint_error ( "Host #{ rhost } is NOT connected to #{ datastore [ 'SMBDomain' ] } !" )
83
- when "STATUS_INSUFF_SERVER_RESOURCES"
84
- vprint_error ( "Host #{ rhost } rejected with insufficient resources!" )
85
- when "STATUS_OBJECT_NAME_INVALID"
86
- vprint_error ( "opeining \\ #{ path } bad filename" )
87
- else
88
- raise e
89
- end
90
- end
92
+ check_path ( path . chomp )
91
93
end #end do
92
94
rescue ::Rex ::HostUnreachable
93
95
vprint_error ( "Host #{ rhost } offline." )
0 commit comments