added eof
git-svn-id: file:///home/svn/incoming/trunk@2373 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
63213353f0
commit
f43c076313
|
@ -153,7 +153,11 @@ class Channel
|
||||||
request.add_tlv(TLV_TYPE_LENGTH, length)
|
request.add_tlv(TLV_TYPE_LENGTH, length)
|
||||||
request.add_tlvs(addends)
|
request.add_tlvs(addends)
|
||||||
|
|
||||||
response = self.client.send_request(request)
|
begin
|
||||||
|
response = self.client.send_request(request)
|
||||||
|
rescue
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
# If the channel is in synchronous mode, the response should contain
|
# If the channel is in synchronous mode, the response should contain
|
||||||
# data that was read from the remote side of the channel
|
# data that was read from the remote side of the channel
|
||||||
|
|
|
@ -48,6 +48,20 @@ class Pool < Rex::Post::Meterpreter::Channel
|
||||||
#
|
#
|
||||||
##
|
##
|
||||||
|
|
||||||
|
# Synonym for tell
|
||||||
|
def pos
|
||||||
|
return tell
|
||||||
|
end
|
||||||
|
|
||||||
|
# Wraps the read operation to raise end-of-file as necessary
|
||||||
|
def read(length = nil)
|
||||||
|
if (self.eof)
|
||||||
|
raise EOFError
|
||||||
|
end
|
||||||
|
|
||||||
|
return super(length)
|
||||||
|
end
|
||||||
|
|
||||||
# Stub for seeking to a different location on the remote half of the
|
# Stub for seeking to a different location on the remote half of the
|
||||||
# channel
|
# channel
|
||||||
def seek(offset, whence = SEEK_SET)
|
def seek(offset, whence = SEEK_SET)
|
||||||
|
@ -60,10 +74,8 @@ class Pool < Rex::Post::Meterpreter::Channel
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
# Synonym for tell
|
protected
|
||||||
def pos
|
attr_accessor :_eof
|
||||||
return tell
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,31 @@ TLV_TYPE_SEEK_POS = TLV_META_TYPE_UINT | (TLV_TEMP + 2)
|
||||||
super(client, cid, type, flags)
|
super(client, cid, type, flags)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
#
|
||||||
|
# I/O operations
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
# Checks to see if the end-of-file has been reached
|
||||||
|
def eof
|
||||||
|
request = Packet.create_request('stdapi_fs_file_eof')
|
||||||
|
|
||||||
|
request.add_tlv(TLV_TYPE_CHANNEL_ID, self.cid)
|
||||||
|
|
||||||
|
begin
|
||||||
|
response = self.client.send_request(request)
|
||||||
|
rescue
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if (response.has_tlv?(TLV_TYPE_BOOL))
|
||||||
|
return response.get_tlv_value(TLV_TYPE_BOOL)
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
# Seeks to a different location in the file
|
# Seeks to a different location in the file
|
||||||
def seek(offset, whence = SEEK_SET)
|
def seek(offset, whence = SEEK_SET)
|
||||||
sane = 0
|
sane = 0
|
||||||
|
|
|
@ -42,6 +42,11 @@ class File < Rex::Post::Meterpreter::Extensions::Stdapi::IO
|
||||||
# IO implementators
|
# IO implementators
|
||||||
#
|
#
|
||||||
##
|
##
|
||||||
|
|
||||||
|
# Returns whether or not the file has reach EOF
|
||||||
|
def eof
|
||||||
|
return self.filed.eof
|
||||||
|
end
|
||||||
|
|
||||||
# Returns the current position of the file pointer
|
# Returns the current position of the file pointer
|
||||||
def pos
|
def pos
|
||||||
|
|
|
@ -128,7 +128,11 @@ class Tlv
|
||||||
elsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)
|
elsif (self.type & TLV_META_TYPE_UINT == TLV_META_TYPE_UINT)
|
||||||
raw = [value].pack("N")
|
raw = [value].pack("N")
|
||||||
elsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)
|
elsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)
|
||||||
raw = [value].pack("c")
|
if (value == true)
|
||||||
|
raw = [1].pack("c")
|
||||||
|
else
|
||||||
|
raw = [0].pack("c")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return [raw.length + 8, self.type].pack("NN") + raw
|
return [raw.length + 8, self.type].pack("NN") + raw
|
||||||
|
@ -150,6 +154,12 @@ class Tlv
|
||||||
self.value = raw.unpack("NNN")[2]
|
self.value = raw.unpack("NNN")[2]
|
||||||
elsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)
|
elsif (self.type & TLV_META_TYPE_BOOL == TLV_META_TYPE_BOOL)
|
||||||
self.value = raw.unpack("NNc")[2]
|
self.value = raw.unpack("NNc")[2]
|
||||||
|
|
||||||
|
if (self.value == 1)
|
||||||
|
self.value = true
|
||||||
|
else
|
||||||
|
self.value = false
|
||||||
|
end
|
||||||
else
|
else
|
||||||
self.value = raw[8..raw.length-1]
|
self.value = raw[8..raw.length-1]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue