Class: Rex::Post::Meterpreter::Extensions::AppApi::AppApi

Inherits:
Rex::Post::Meterpreter::Extension show all
Defined in:
lib/rex/post/meterpreter/extensions/appapi/appapi.rb

Overview

Application interface to control Applications on the device

Instance Attribute Summary

Attributes inherited from Rex::Post::Meterpreter::Extension

#client, #name

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ AppApi

Typical extension initialization routine.


27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rex/post/meterpreter/extensions/appapi/appapi.rb', line 27

def initialize(client)
  super(client, 'appapi')

  client.register_extension_aliases(
    [
      {
        'name' => 'appapi',
        'ext'  => self
      }
    ])
end

Class Method Details

.extension_idObject


19
20
21
# File 'lib/rex/post/meterpreter/extensions/appapi/appapi.rb', line 19

def self.extension_id
  EXTENSION_ID_APPAPI
end

Instance Method Details

#app_install(apk_path) ⇒ Object

Install application


68
69
70
71
72
73
74
# File 'lib/rex/post/meterpreter/extensions/appapi/appapi.rb', line 68

def app_install(apk_path)
  request = Packet.create_request(COMMAND_ID_APPAPI_APP_INSTALL)
  request.add_tlv(TLV_TYPE_APP_APK_PATH, apk_path)
  response = client.send_request(request)

  response.get_tlv(TLV_TYPE_APP_ENUM).value
end

#app_list(app_opt) ⇒ Object

Get list of installed applications


42
43
44
45
46
47
48
49
50
51
# File 'lib/rex/post/meterpreter/extensions/appapi/appapi.rb', line 42

def app_list(app_opt)
  request = Packet.create_request(COMMAND_ID_APPAPI_APP_LIST)
  request.add_tlv(TLV_TYPE_APPS_LIST_OPT, app_opt)
  response = client.send_request(request)
  names = []
  response.get_tlvs(TLV_TYPE_APPS_LIST).each do |tlv|
    names << tlv.value
  end
  names
end

#app_run(packagename) ⇒ Object

Start Main Activity for installed application by Package name


79
80
81
82
83
84
# File 'lib/rex/post/meterpreter/extensions/appapi/appapi.rb', line 79

def app_run(packagename)
  request = Packet.create_request(COMMAND_ID_APPAPI_APP_RUN)
  request.add_tlv(TLV_TYPE_APP_PACKAGE_NAME, packagename)
  response = client.send_request(request)
  response.get_tlv(TLV_TYPE_APP_RUN_ENUM).value
end

#app_uninstall(packagename) ⇒ Object

Uninstall application


56
57
58
59
60
61
62
63
# File 'lib/rex/post/meterpreter/extensions/appapi/appapi.rb', line 56

def app_uninstall(packagename)

  request = Packet.create_request(COMMAND_ID_APPAPI_APP_UNINSTALL)
  request.add_tlv(TLV_TYPE_APP_PACKAGE_NAME, packagename)
  response = client.send_request(request)

  response.get_tlv(TLV_TYPE_APP_ENUM).value
end