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.


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

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

Instance Method Details

#connectObject


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

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

#exec_cmd(cmd) ⇒ Object


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

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


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

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