2005-04-03 21:52:10 +00:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
2005-07-09 21:18:49 +00:00
|
|
|
require 'rex/post/dir'
|
2005-04-03 21:52:10 +00:00
|
|
|
|
|
|
|
module Rex
|
|
|
|
module Post
|
|
|
|
module DispatchNinja
|
|
|
|
|
2005-04-03 23:13:16 +00:00
|
|
|
class Dir < Rex::Post::Dir
|
2005-04-03 21:52:10 +00:00
|
|
|
|
|
|
|
class <<self
|
|
|
|
attr_accessor :client
|
|
|
|
end
|
|
|
|
|
2005-07-08 00:21:11 +00:00
|
|
|
#--
|
|
|
|
|
2005-04-03 23:13:16 +00:00
|
|
|
def Dir.entries(name)
|
2005-04-03 21:52:10 +00:00
|
|
|
|
2005-04-03 23:13:16 +00:00
|
|
|
client.sendmodule('ls')
|
2005-04-03 21:52:10 +00:00
|
|
|
|
2005-04-03 23:13:16 +00:00
|
|
|
client.sendfilename(name)
|
2005-04-03 21:52:10 +00:00
|
|
|
|
2005-04-03 23:13:16 +00:00
|
|
|
res = client.sockread(4).unpack('l')[0] # ug, not portable, later...
|
2005-04-03 21:52:10 +00:00
|
|
|
|
|
|
|
files = [ ]
|
|
|
|
|
|
|
|
while true
|
2005-04-03 23:13:16 +00:00
|
|
|
len = client.sockread(2).unpack('S')[0]
|
2005-04-03 21:52:10 +00:00
|
|
|
break if len == 0
|
2005-04-03 23:13:16 +00:00
|
|
|
files << client.sockread(len)
|
2005-04-03 21:52:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
client.checksig()
|
|
|
|
|
2005-04-03 23:13:16 +00:00
|
|
|
if res < 0 # eek! error!
|
|
|
|
raise SystemCallError.new(name, -res)
|
2005-04-03 21:52:10 +00:00
|
|
|
end
|
|
|
|
|
2005-04-03 23:13:16 +00:00
|
|
|
return files
|
2005-04-03 21:52:10 +00:00
|
|
|
end
|
|
|
|
|
2005-07-08 00:21:11 +00:00
|
|
|
#++
|
2005-04-03 21:52:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end; end; end # DispatchNinja/Post/Rex
|