Class: Rex::Proto::ADB::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/proto/adb/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(sock, opts = {}) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
# File 'lib/rex/proto/adb/client.rb', line 10

def initialize(sock, opts = {})
  @sock = sock
  @opts = opts
  @local_id_counter = 0x0a
end

Instance Method Details

#connectObject



16
17
18
# File 'lib/rex/proto/adb/client.rb', line 16

def connect
  ADB::Message::Connect.new.send_recv(@sock)
end

#exec_cmd(cmd) ⇒ Object



20
21
22
23
24
# File 'lib/rex/proto/adb/client.rb', line 20

def exec_cmd(cmd)
  local_id = @local_id_counter += 1
  response = ADB::Message::Open.new(local_id, "shell:"+cmd).send_recv(@sock)
  ADB::Message::Close.new(local_id, response.arg0).send_recv(@sock)
end

#read_messageObject



26
27
28
# File 'lib/rex/proto/adb/client.rb', line 26

def read_message
  ADB::Message.read(@sock)
end