Changeset 2335
- Timestamp:
- 04/03/05 18:13:16 (3 years ago)
- Files:
-
- incoming/trunk/lib/rex/post/dir.rb (added)
- incoming/trunk/lib/rex/post/dispatch_ninja/client.rb (modified) (2 diffs)
- incoming/trunk/lib/rex/post/dispatch_ninja/dir.rb (modified) (2 diffs)
- incoming/trunk/lib/rex/post/dispatch_ninja/file.rb (modified) (1 diff)
- incoming/trunk/lib/rex/post/dispatch_ninja/process.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
incoming/trunk/lib/rex/post/dispatch_ninja/client.rb
r2334 r2335 4 4 require 'Rex/Post/DispatchNinja/FileStat' 5 5 require 'Rex/Post/DispatchNinja/Process' 6 require 'Rex/Post/DispatchNinja/Dir' 6 7 7 8 module Rex … … 21 22 end 22 23 23 def file24 klass = Rex::Post::DispatchNinja::File.dup24 def brand(klass) 25 klass = klass.dup 25 26 klass.client = self 26 27 return klass 27 28 end 28 29 30 def file 31 brand(Rex::Post::DispatchNinja::File) 32 end 29 33 def filestat 30 klass = Rex::Post::DispatchNinja::FileStat.dup 31 klass.client = self 32 return klass 34 brand(Rex::Post::DispatchNinja::FileStat) 33 35 end 34 35 36 def process 36 klass = Rex::Post::DispatchNinja::Process.dup 37 klass.client = self 38 return klass 37 brand(Rex::Post::DispatchNinja::Process) 38 end 39 def dir 40 brand(Rex::Post::DispatchNinja::Dir) 39 41 end 40 42 incoming/trunk/lib/rex/post/dispatch_ninja/dir.rb
r2334 r2335 1 1 #!/usr/bin/ruby 2 2 3 require 'Rex/ DispatchNinja/Stat'3 require 'Rex/Post/Dir' 4 4 5 5 module Rex … … 7 7 module DispatchNinja 8 8 9 class File < Rex::Post::File9 class Dir < Rex::Post::Dir 10 10 11 #12 # Class Methods13 #14 15 @@structstat = [16 'st_dev', 2,17 'pad1', 2,18 'st_ino', 4,19 'st_mode', 2,20 'st_nlink', 2,21 'st_uid', 2,22 'st_gid', 2,23 'st_rdev', 2,24 'pad2', 2,25 'st_size', 4,26 'st_blksize', 4,27 'st_blocks', 4,28 'st_atime', 4,29 'unused1', 4,30 'st_mtime', 4,31 'unused2', 4,32 'st_ctime', 4,33 'unused3', 4,34 'unused4', 4,35 'unused5', 436 ]37 38 # setup a class variable for our client pointer39 11 class <<self 40 12 attr_accessor :client 41 13 end 42 14 43 def File.stat(file) 44 return client.filestat.new(file) 45 end 46 def ls(dir) 15 def Dir.entries(name) 47 16 48 sendmodule('ls')17 client.sendmodule('ls') 49 18 50 sendfilename(dir)19 client.sendfilename(name) 51 20 52 res = sockread(4).unpack('l')[0] # ug, not portable, later...21 res = client.sockread(4).unpack('l')[0] # ug, not portable, later... 53 22 54 23 files = [ ] 55 24 56 25 while true 57 len = sockread(2).unpack('S')[0]26 len = client.sockread(2).unpack('S')[0] 58 27 break if len == 0 59 files << sockread(len)28 files << client.sockread(len) 60 29 end 61 62 checksig()63 64 return [ res, files ]65 end66 67 def File.stat_hash(file)68 69 client.sendmodule('stat')70 client.sendfilename(file)71 72 data = client.sockread(68)73 res = data[0, 4].unpack('l')[0]74 75 # throw exception! blah!76 30 77 31 client.checksig() 78 32 79 data = data[4 .. -1] 80 81 elements = @@structstat 82 hash = { } 83 i = 0 84 o = 0 85 while i < elements.length 86 name = elements[i] 87 size = elements[i + 1] 88 i += 2 89 90 e = data[o, size].unpack(size == 2 ? 'S' : 'L')[0] 91 o += size 92 93 hash[name] = e 33 if res < 0 # eek! error! 34 raise SystemCallError.new(name, -res) 94 35 end 95 36 96 return (hash)37 return files 97 38 end 98 99 #100 # Instance Methods101 #102 103 # setup an instance variable, just for ease and copy it over..104 # and so you can change it instance wise105 private106 attr_accessor :client107 public108 109 def initialize()110 self.client = self.class.client111 end112 113 39 114 40 end 115 41 116 42 end; end; end # DispatchNinja/Post/Rex 117 incoming/trunk/lib/rex/post/dispatch_ninja/file.rb
r2334 r2335 30 30 client.checksig() 31 31 32 if res < 0 33 raise SystemCallError.new(file, -res) 34 end 35 32 36 return data[4 .. -1] 33 37 end incoming/trunk/lib/rex/post/dispatch_ninja/process.rb
r2334 r2335 23 23 return data.unpack('l3') 24 24 end 25 26 def Process.pid() 27 client.sendmodule('getpid') 28 data = client.sockread(4) 29 client.checksig 30 return data.unpack('V')[0] 31 end 32 33 def Process.ppid() 34 client.sendmodule('getppid') 35 data = client.sockread(4) 36 client.checksig 37 return data.unpack('V')[0] 38 end 25 39 end 26 40
