@@ -59,7 +59,7 @@ def dir(directory)
59
59
#
60
60
# @param path [String] Remote filename to check
61
61
def directory? ( path )
62
- if session . type == " meterpreter"
62
+ if session . type == ' meterpreter'
63
63
stat = session . fs . file . stat ( path ) rescue nil
64
64
return false unless stat
65
65
return stat . directory?
@@ -70,9 +70,9 @@ def directory?(path)
70
70
f = session . shell_command_token ( "test -d \" #{ path } \" && echo true" )
71
71
end
72
72
73
- return false if f . nil? or f . empty?
73
+ return false if f . nil? || f . empty?
74
74
return false unless f =~ /true/
75
- return true
75
+ true
76
76
end
77
77
end
78
78
@@ -93,7 +93,7 @@ def expand_path(path)
93
93
#
94
94
# @param path [String] Remote filename to check
95
95
def file? ( path )
96
- if session . type == " meterpreter"
96
+ if session . type == ' meterpreter'
97
97
stat = session . fs . file . stat ( path ) rescue nil
98
98
return false unless stat
99
99
return stat . file?
@@ -107,20 +107,40 @@ def file?(path)
107
107
f = session . shell_command_token ( "test -f \" #{ path } \" && echo true" )
108
108
end
109
109
110
- return false if f . nil? or f . empty?
110
+ return false if f . nil? || f . empty?
111
111
return false unless f =~ /true/
112
- return true
112
+ true
113
113
end
114
114
end
115
115
116
116
alias file_exist? file?
117
117
118
+ #
119
+ # See if +path+ on the remote system is a setuid file
120
+ #
121
+ # @param path [String] Remote filename to check
122
+ def setuid? ( path )
123
+ if session . type == 'meterpreter'
124
+ stat = session . fs . file . stat ( path ) rescue nil
125
+ return false unless stat
126
+ return stat . setuid?
127
+ else
128
+ if session . platform != 'windows'
129
+ f = session . shell_command_token ( "test -u \" #{ path } \" && echo true" )
130
+ end
131
+
132
+ return false if f . nil? || f . empty?
133
+ return false unless f =~ /true/
134
+ true
135
+ end
136
+ end
137
+
118
138
#
119
139
# Check for existence of +path+ on the remote file system
120
140
#
121
141
# @param path [String] Remote filename to check
122
142
def exist? ( path )
123
- if session . type == " meterpreter"
143
+ if session . type == ' meterpreter'
124
144
stat = session . fs . file . stat ( path ) rescue nil
125
145
return !!( stat )
126
146
else
@@ -130,9 +150,9 @@ def exist?(path)
130
150
f = cmd_exec ( "test -e \" #{ path } \" && echo true" )
131
151
end
132
152
133
- return false if f . nil? or f . empty?
153
+ return false if f . nil? || f . empty?
134
154
return false unless f =~ /true/
135
- return true
155
+ true
136
156
end
137
157
end
138
158
@@ -290,7 +310,7 @@ def write_file(file_name, data)
290
310
end
291
311
292
312
end
293
- return true
313
+ true
294
314
end
295
315
296
316
#
@@ -314,7 +334,7 @@ def append_file(file_name, data)
314
334
_write_file_unix_shell ( file_name , data , true )
315
335
end
316
336
end
317
- return true
337
+ true
318
338
end
319
339
320
340
#
0 commit comments