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/appapi/appapi.rb
Views: 11791
# -*- coding: binary -*-12require 'rex/post/meterpreter/extensions/appapi/tlv'3require 'rex/post/meterpreter/extensions/appapi/command_ids'45module Rex6module Post7module Meterpreter8module Extensions9module AppApi1011###12#13# Application interface to control Applications on the device14#15###16class AppApi < Extension1718def self.extension_id19EXTENSION_ID_APPAPI20end2122#23# Typical extension initialization routine.24#25# @param client (see Extension#initialize)26def initialize(client)27super(client, 'appapi')2829client.register_extension_aliases(30[31{32'name' => 'appapi',33'ext' => self34}35])36end3738#39# Get list of installed applications40#41def app_list(app_opt)42request = Packet.create_request(COMMAND_ID_APPAPI_APP_LIST)43request.add_tlv(TLV_TYPE_APPS_LIST_OPT, app_opt)44response = client.send_request(request)45names = []46response.get_tlvs(TLV_TYPE_APPS_LIST).each do |tlv|47names << tlv.value48end49names50end5152#53# Uninstall application54#55def app_uninstall(packagename)5657request = Packet.create_request(COMMAND_ID_APPAPI_APP_UNINSTALL)58request.add_tlv(TLV_TYPE_APP_PACKAGE_NAME, packagename)59response = client.send_request(request)6061response.get_tlv(TLV_TYPE_APP_ENUM).value62end6364#65# Install application66#67def app_install(apk_path)68request = Packet.create_request(COMMAND_ID_APPAPI_APP_INSTALL)69request.add_tlv(TLV_TYPE_APP_APK_PATH, apk_path)70response = client.send_request(request)7172response.get_tlv(TLV_TYPE_APP_ENUM).value73end7475#76# Start Main Activity for installed application by Package name77#78def app_run(packagename)79request = Packet.create_request(COMMAND_ID_APPAPI_APP_RUN)80request.add_tlv(TLV_TYPE_APP_PACKAGE_NAME, packagename)81response = client.send_request(request)82response.get_tlv(TLV_TYPE_APP_RUN_ENUM).value83end8485end8687end; end; end; end; end88899091