Skip to content

Commit 53ce08e

Browse files
committed
feat: add stdapi_webcam extension
1 parent 0206663 commit 53ce08e

File tree

2 files changed

+202
-0
lines changed

2 files changed

+202
-0
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# -*- coding: binary -*-
2+
3+
require 'rex/post/meterpreter/object_aliases'
4+
require 'rex/post/meterpreter/extension'
5+
require 'rex/post/meterpreter/extensions/stdapi/constants'
6+
require 'rex/post/meterpreter/extensions/stdapi/tlv'
7+
require 'rex/post/meterpreter/extensions/stdapi/command_ids'
8+
require 'rex/post/meterpreter/extensions/stdapi/mic/mic'
9+
require 'rex/post/meterpreter/extensions/stdapi/audio_output/audio_output'
10+
require 'rex/post/meterpreter/extensions/stdapi/webcam/webcam'
11+
require 'rex/post/meterpreter/extensions/stdapi/sys/config'
12+
require 'rex/post/meterpreter/extensions/stdapi/sys/process'
13+
require 'rex/post/meterpreter/extensions/stdapi/sys/registry'
14+
require 'rex/post/meterpreter/extensions/stdapi/sys/event_log'
15+
require 'rex/post/meterpreter/extensions/stdapi/sys/power'
16+
17+
module Rex
18+
module Post
19+
module Meterpreter
20+
module Extensions
21+
module Stdapi_Webcam
22+
module AudioOutput
23+
include Rex::Post::Meterpreter::Extensions::Stdapi::AudioOutput
24+
end
25+
26+
module Mic
27+
include Rex::Post::Meterpreter::Extensions::Stdapi::Mic
28+
end
29+
30+
module Webcam
31+
include Rex::Post::Meterpreter::Extensions::Stdapi::Webcam
32+
end
33+
34+
module Sys
35+
include Rex::Post::Meterpreter::Extensions::Stdapi::Sys
36+
end
37+
include Rex::Post::Meterpreter::Extensions::Stdapi
38+
39+
###
40+
#
41+
# Standard ruby interface to remote entities for meterpreter. It provides
42+
# basic access to files, network, system, and other properties of the remote
43+
# machine that are fairly universal.
44+
#
45+
###
46+
class Stdapi_Webcam < Extension
47+
48+
def self.extension_id
49+
Rex::Post::Meterpreter::Extensions::Stdapi::EXTENSION_ID_STDAPI
50+
end
51+
52+
#
53+
# Initializes an instance of the standard API extension.
54+
#
55+
def initialize(client)
56+
super(client, 'stdapi_webcam')
57+
58+
# Alias the following things on the client object so that they
59+
# can be directly referenced
60+
client.register_extension_aliases(
61+
[
62+
{
63+
'name' => 'audio_output',
64+
'ext' => Rex::Post::Meterpreter::Extensions::Stdapi_Webcam::AudioOutput::AudioOutput.new(client)
65+
},
66+
{
67+
'name' => 'mic',
68+
'ext' => Rex::Post::Meterpreter::Extensions::Stdapi_Webcam::Mic::Mic.new(client)
69+
},
70+
{
71+
'name' => 'sys',
72+
'ext' => ObjectAliases.new(
73+
{
74+
'config' => Rex::Post::Meterpreter::Extensions::Stdapi_Webcam::Sys::Config.new(client),
75+
'process' => process,
76+
'registry' => registry,
77+
'eventlog' => eventlog,
78+
'power' => power
79+
}
80+
)
81+
},
82+
{
83+
'name' => 'webcam',
84+
'ext' => Rex::Post::Meterpreter::Extensions::Stdapi_Webcam::Webcam::Webcam.new(client)
85+
},
86+
]
87+
)
88+
end
89+
90+
#
91+
# Sets the client instance on a duplicated copy of the supplied class.
92+
#
93+
def brand(klass)
94+
klass = klass.dup
95+
klass.client = client
96+
return klass
97+
end
98+
99+
#
100+
# Returns a copy of the Process class.
101+
#
102+
def process
103+
brand(Rex::Post::Meterpreter::Extensions::Stdapi_Webcam::Sys::Process)
104+
end
105+
106+
#
107+
# Returns a copy of the Registry class.
108+
#
109+
def registry
110+
brand(Rex::Post::Meterpreter::Extensions::Stdapi_Webcam::Sys::Registry)
111+
end
112+
113+
#
114+
# Returns a copy of the EventLog class.
115+
#
116+
def eventlog
117+
brand(Rex::Post::Meterpreter::Extensions::Stdapi_Webcam::Sys::EventLog)
118+
end
119+
120+
#
121+
# Returns a copy of the Power class.
122+
#
123+
def power
124+
brand(Rex::Post::Meterpreter::Extensions::Stdapi_Webcam::Sys::Power)
125+
end
126+
end
127+
end
128+
end
129+
end
130+
end
131+
end
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# -*- coding: binary -*-
2+
3+
require 'rex/post/meterpreter'
4+
5+
module Rex
6+
module Post
7+
module Meterpreter
8+
module Ui
9+
###
10+
#
11+
# Standard API extension.
12+
#
13+
###
14+
class Console::CommandDispatcher::Stdapi_Webcam
15+
require 'rex/post/meterpreter/ui/console/command_dispatcher/stdapi'
16+
require 'rex/post/meterpreter/ui/console/command_dispatcher/stdapi/webcam'
17+
18+
Klass = Console::CommandDispatcher::Stdapi_Webcam
19+
20+
Dispatchers =
21+
[
22+
Console::CommandDispatcher::Stdapi::Webcam,
23+
]
24+
25+
include Console::CommandDispatcher
26+
27+
def self.has_command?(name)
28+
Dispatchers.any? { |klass| klass.has_command?(name) }
29+
end
30+
31+
#
32+
# Initializes an instance of the stdapi command interaction.
33+
#
34+
def initialize(shell)
35+
super
36+
37+
Dispatchers.each do |d|
38+
shell.enstack_dispatcher(d)
39+
end
40+
str_dispatchers = []
41+
uniq_dispatchers = []
42+
idx = 0
43+
while idx < shell.dispatcher_stack.length
44+
unless str_dispatchers.include?(shell.dispatcher_stack[idx].class.to_s)
45+
str_dispatchers.push(shell.dispatcher_stack[idx].class.to_s)
46+
uniq_dispatchers.push(shell.dispatcher_stack[idx])
47+
end
48+
idx += 1
49+
end
50+
shell.dispatcher_stack = uniq_dispatchers
51+
end
52+
53+
#
54+
# List of supported commands.
55+
#
56+
def commands
57+
{}
58+
end
59+
60+
#
61+
# Name for this dispatcher
62+
#
63+
def name
64+
'Standard Webcam extension'
65+
end
66+
67+
end
68+
end
69+
end
70+
end
71+
end

0 commit comments

Comments
 (0)