CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/rex/proto/adb/client.rb
Views: 11704
1
# -*- coding: binary -*-
2
3
4
module Rex
5
module Proto
6
module ADB
7
8
class Client
9
10
def initialize(sock, opts = {})
11
@sock = sock
12
@opts = opts
13
@local_id_counter = 0x0a
14
end
15
16
def connect
17
ADB::Message::Connect.new.send_recv(@sock)
18
end
19
20
def exec_cmd(cmd)
21
local_id = @local_id_counter += 1
22
response = ADB::Message::Open.new(local_id, "shell:"+cmd).send_recv(@sock)
23
ADB::Message::Close.new(local_id, response.arg0).send_recv(@sock)
24
end
25
26
def read_message
27
ADB::Message.read(@sock)
28
end
29
30
end # Client
31
32
end # ADB
33
end # Proto
34
end # Rex
35
36