mirror of
https://github.com/rapid7/metasploit-framework
synced 2024-11-05 14:57:30 +01:00
ug
git-svn-id: file:///home/svn/incoming/trunk@2339 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
9390d9957d
commit
95ec287d94
@ -6,7 +6,7 @@ module Post
|
||||
class Dir
|
||||
|
||||
def Dir.entries(name)
|
||||
throw NotImplementedError
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def Dir.foreach(name, &block)
|
||||
|
@ -42,7 +42,7 @@ class Client
|
||||
|
||||
def sendmodule(name)
|
||||
name = 'lib/Rex/Post/DispatchNinja/modules/' + name
|
||||
data = IO.readlines(name, '')[0]
|
||||
data = ::IO.readlines(name, '')[0]
|
||||
sockwrite([data.length].pack('V'))
|
||||
sockwrite(data)
|
||||
end
|
||||
|
@ -1,18 +1,47 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
require 'Rex/Post/File'
|
||||
require 'Rex/Post/DispatchNinja/IO'
|
||||
|
||||
module Rex
|
||||
module Post
|
||||
module DispatchNinja
|
||||
|
||||
class File < Rex::Post::File
|
||||
class File < Rex::Post::DispatchNinja::IO
|
||||
|
||||
include Rex::Post::File
|
||||
|
||||
# setup a class variable for our client pointer
|
||||
class <<self
|
||||
attr_accessor :client
|
||||
end
|
||||
|
||||
protected
|
||||
attr_accessor :client
|
||||
public
|
||||
|
||||
# !!! make mode/perms work!
|
||||
def initialize(name, mode="r", perms=0)
|
||||
self.client = self.class.client
|
||||
self.filed = _open(name, mode, perms)
|
||||
end
|
||||
|
||||
def _open(name, mode="r", perms=0)
|
||||
|
||||
client.sendmodule('open')
|
||||
client.sendfilename(name)
|
||||
|
||||
res = client.sockread(4).unpack('l')[0]
|
||||
|
||||
client.checksig()
|
||||
|
||||
if res < 0
|
||||
raise SystemCallError.new(name, -res)
|
||||
end
|
||||
|
||||
return res
|
||||
end
|
||||
|
||||
def File.stat(name)
|
||||
client.filestat.new(name)
|
||||
end
|
||||
|
35
lib/rex/post/dispatch_ninja/i_o.rb
Normal file
35
lib/rex/post/dispatch_ninja/i_o.rb
Normal file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
require 'Rex/Post/IO'
|
||||
|
||||
module Rex
|
||||
module Post
|
||||
module DispatchNinja
|
||||
|
||||
class IO < Rex::Post::IO
|
||||
|
||||
# setup a class variable for our client pointer
|
||||
class <<self
|
||||
attr_accessor :client
|
||||
end
|
||||
|
||||
def close
|
||||
_close(filed)
|
||||
end
|
||||
|
||||
def _close(fd)
|
||||
client.sendmodule('close')
|
||||
client.sockwrite([ fd ].pack('l'))
|
||||
|
||||
res = client.sockread(4).unpack('L')[0]
|
||||
|
||||
client.checksig()
|
||||
|
||||
if res < 0
|
||||
raise SystemCallError.new("close(#{fd})", -res)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end; end; end # DispatchNinja/Post/Rex
|
||||
|
@ -1,26 +1,87 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
require 'Rex/Post/IO'
|
||||
|
||||
module Rex
|
||||
module Post
|
||||
|
||||
class File
|
||||
# make this a module so we can mix it in, and have inheritence like..
|
||||
# => [Rex::Post::DispatchNinja::File, Rex::Post::File,
|
||||
# Rex::Post::DispatchNinja::IO, Rex::Post::IO, Object, Kernel]
|
||||
|
||||
#
|
||||
# Class Methods
|
||||
#
|
||||
module File
|
||||
|
||||
# setup a class variable for our client pointer
|
||||
# class <<self
|
||||
# attr_accessor :client
|
||||
# end
|
||||
protected
|
||||
# inherits fd and mode from IO
|
||||
attr_accessor :filename
|
||||
public
|
||||
|
||||
# f = File.new("testfile", "r")
|
||||
# f = File.new("newfile", "w+")
|
||||
# f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644)
|
||||
# !!! I suppose I should figure out the correct default for perm..
|
||||
def initialize(name, mode='r', perm=0)
|
||||
end
|
||||
|
||||
# def File.stat(file)
|
||||
# return client.filestat.new(file)
|
||||
# end
|
||||
def path
|
||||
filename
|
||||
end
|
||||
|
||||
# def File.stat_hash(file)
|
||||
# raise NotImplementedError
|
||||
# end
|
||||
# ctime/atime blah need fstat..
|
||||
# need lchown/chown/fchown, etc, etc
|
||||
|
||||
# proxy this crap, whatever
|
||||
def File.basename(*a)
|
||||
::File.basename(*a)
|
||||
end
|
||||
def File.dirname(*a)
|
||||
::File.dirname(*a)
|
||||
end
|
||||
def File.extname(*a)
|
||||
::File.extname(*a)
|
||||
end
|
||||
# !!! we might actually want to handle this File::SEPERATOR stuff
|
||||
# for win32 support, etc. And you know, when we rock the vax n shit
|
||||
def File.join(*a)
|
||||
::File.join(*a)
|
||||
end
|
||||
|
||||
def File.chmod
|
||||
raise NotImplementedError
|
||||
end
|
||||
def File.chown
|
||||
raise NotImplementedError
|
||||
end
|
||||
def File.delete(*a)
|
||||
unlink(*a)
|
||||
end
|
||||
def File.unlink
|
||||
raise NotImplementedError
|
||||
end
|
||||
def File.lchmod
|
||||
raise NotImplementedError
|
||||
end
|
||||
def File.lchown
|
||||
raise NotImplementedError
|
||||
end
|
||||
def File.link
|
||||
raise NotImplementedError
|
||||
end
|
||||
def File.lstat
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
# this, along with all the other globbing/search stuff, probably
|
||||
# won't get implemented, atleast for a bit...
|
||||
def File.expand_path
|
||||
raise NotImplementedError
|
||||
end
|
||||
def File.fnmatch(*a)
|
||||
fnmatch?(*a)
|
||||
end
|
||||
def File.fnmatch?
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
#
|
||||
# autogen'd stat passthroughs
|
||||
@ -98,23 +159,6 @@ class File
|
||||
stat(name).zero?
|
||||
end
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Instance Methods
|
||||
#
|
||||
|
||||
# setup an instance variable, just for ease and copy it over..
|
||||
# and so you can change it instance wise
|
||||
# private
|
||||
# attr_accessor :client
|
||||
# public
|
||||
|
||||
# def initialize()
|
||||
# self.client = self.class.client
|
||||
# end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end; end # Post/Rex
|
||||
|
14
lib/rex/post/i_o.rb
Normal file
14
lib/rex/post/i_o.rb
Normal file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
module Rex
|
||||
module Post
|
||||
|
||||
class IO
|
||||
|
||||
protected
|
||||
attr_accessor :filed, :mode
|
||||
public
|
||||
end
|
||||
|
||||
end; end # Post/Rex
|
||||
|
@ -41,10 +41,10 @@ class Process
|
||||
end
|
||||
|
||||
def Process.pid
|
||||
throw NotImplementedError
|
||||
raise NotImplementedError
|
||||
end
|
||||
def Process.ppid
|
||||
throw NotImplementedError
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user