Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb
Views: 11791
# -*- coding: binary -*-12require 'rex/post/meterpreter/object_aliases'3require 'rex/post/meterpreter/extension'4require 'rex/post/meterpreter/extensions/stdapi/constants'5require 'rex/post/meterpreter/extensions/stdapi/tlv'6require 'rex/post/meterpreter/extensions/stdapi/command_ids'7require 'rex/post/meterpreter/extensions/stdapi/fs/dir'8require 'rex/post/meterpreter/extensions/stdapi/fs/file'9require 'rex/post/meterpreter/extensions/stdapi/fs/file_stat'10require 'rex/post/meterpreter/extensions/stdapi/fs/mount'11require 'rex/post/meterpreter/extensions/stdapi/net/resolve'12require 'rex/post/meterpreter/extensions/stdapi/net/config'13require 'rex/post/meterpreter/extensions/stdapi/net/socket'14require 'rex/post/meterpreter/extensions/stdapi/sys/config'15require 'rex/post/meterpreter/extensions/stdapi/sys/process'16require 'rex/post/meterpreter/extensions/stdapi/sys/registry'17require 'rex/post/meterpreter/extensions/stdapi/sys/event_log'18require 'rex/post/meterpreter/extensions/stdapi/sys/power'19require 'rex/post/meterpreter/extensions/stdapi/railgun/railgun'20require 'rex/post/meterpreter/extensions/stdapi/ui'21require 'rex/post/meterpreter/extensions/stdapi/webcam/webcam'22require 'rex/post/meterpreter/extensions/stdapi/mic/mic'23require 'rex/post/meterpreter/extensions/stdapi/audio_output/audio_output'2425module Rex26module Post27module Meterpreter28module Extensions29module Stdapi3031###32#33# Standard ruby interface to remote entities for meterpreter. It provides34# basic access to files, network, system, and other properties of the remote35# machine that are fairly universal.36#37###38class Stdapi < Extension3940def self.extension_id41EXTENSION_ID_STDAPI42end4344#45# Initializes an instance of the standard API extension.46#47def initialize(client)48super(client, 'stdapi')4950# Alias the following things on the client object so that they51# can be directly referenced52client.register_extension_aliases(53[54{55'name' => 'fs',56'ext' => ObjectAliases.new(57{58'dir' => self.dir,59'file' => self.file,60'filestat' => self.filestat,61'mount' => Fs::Mount.new(client)62})63},64{65'name' => 'sys',66'ext' => ObjectAliases.new(67{68'config' => Sys::Config.new(client),69'process' => self.process,70'registry' => self.registry,71'eventlog' => self.eventlog,72'power' => self.power73})74},75{76'name' => 'net',77'ext' => ObjectAliases.new(78{79'config' => Rex::Post::Meterpreter::Extensions::Stdapi::Net::Config.new(client),80'socket' => Rex::Post::Meterpreter::Extensions::Stdapi::Net::Socket.new(client),81'resolve' => Rex::Post::Meterpreter::Extensions::Stdapi::Net::Resolve.new(client)82})83},84{85'name' => 'railgun',86'ext' => Rex::Post::Meterpreter::Extensions::Stdapi::Railgun::Railgun.new(client)87},88{89'name' => 'webcam',90'ext' => Rex::Post::Meterpreter::Extensions::Stdapi::Webcam::Webcam.new(client)91},92{93'name' => 'mic',94'ext' => Rex::Post::Meterpreter::Extensions::Stdapi::Mic::Mic.new(client)95},96{97'name' => 'audio_output',98'ext' => Rex::Post::Meterpreter::Extensions::Stdapi::AudioOutput::AudioOutput.new(client)99},100{101'name' => 'ui',102'ext' => UI.new(client)103}104105])106end107108#109# Sets the client instance on a duplicated copy of the supplied class.110#111def brand(klass)112klass = klass.dup113klass.client = self.client114return klass115end116117#118# Returns a copy of the Dir class.119#120def dir121brand(Rex::Post::Meterpreter::Extensions::Stdapi::Fs::Dir)122end123124#125# Returns a copy of the File class.126#127def file128brand(Rex::Post::Meterpreter::Extensions::Stdapi::Fs::File)129end130131#132# Returns a copy of the FileStat class.133#134def filestat135brand(Rex::Post::Meterpreter::Extensions::Stdapi::Fs::FileStat)136end137138#139# Returns a copy of the Process class.140#141def process142brand(Rex::Post::Meterpreter::Extensions::Stdapi::Sys::Process)143end144145#146# Returns a copy of the Registry class.147#148def registry149brand(Rex::Post::Meterpreter::Extensions::Stdapi::Sys::Registry)150end151152#153# Returns a copy of the EventLog class.154#155def eventlog156brand(Rex::Post::Meterpreter::Extensions::Stdapi::Sys::EventLog)157end158159#160# Returns a copy of the Power class.161#162def power163brand(Rex::Post::Meterpreter::Extensions::Stdapi::Sys::Power)164end165end166167end; end; end; end; end168169170