CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/rex/post/meterpreter/channels/pools/file.rb
Views: 1904
1
# -*- coding: binary -*-
2
3
require 'rex/post/meterpreter/channels/pool'
4
require 'rex/post/meterpreter/extensions/stdapi/tlv'
5
6
module Rex
7
module Post
8
module Meterpreter
9
module Channels
10
module Pools
11
12
###
13
#
14
# File
15
# ----
16
#
17
# This class represents a channel that is associated with a file
18
# on the remote half of the meterpreter connection.
19
#
20
###
21
class File < Rex::Post::Meterpreter::Channels::Pool
22
23
##
24
#
25
# Factory
26
#
27
##
28
29
#
30
# This method returns an instance of a file pool channel that can be read
31
# from, written to, seeked on, and other interacted with.
32
#
33
def File.open(client, name, mode = "r", perm = 0)
34
Channel.create(client, 'stdapi_fs_file',
35
self, CHANNEL_FLAG_SYNCHRONOUS,
36
[
37
{
38
'type' => Rex::Post::Meterpreter::Extensions::Stdapi::TLV_TYPE_FILE_PATH,
39
'value' => client.unicode_filter_decode( name )
40
},
41
{
42
'type' => Rex::Post::Meterpreter::Extensions::Stdapi::TLV_TYPE_FILE_MODE,
43
'value' => mode + "b"
44
},
45
])
46
end
47
48
##
49
#
50
# Constructor
51
#
52
##
53
54
# Initializes the file channel instance
55
def initialize(client, cid, type, flags, packet, **_)
56
super(client, cid, type, flags, packet)
57
end
58
59
end
60
61
end; end; end; end; end
62
63
64