-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
197 lines (180 loc) · 6.39 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<!DOCTYPE html>
<html>
<head>
<head>
<title>WebADB | Android Debug Bridge WebApp</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="WebUSB based Android Debug Bridge (adb) host" />
<meta name="keywords" content="adb, webusb, android adb, adb host, adb webapp" />
<link rel="manifest" href="manifest-webadb.json" />
<link rel="stylesheet" type="text/css" href="https://www.w3schools.com/w3css/3/w3.css" />
</head>
<style>
.loading{
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background: rgba(0,0,0,.2);
}
.box{
background: #fdf5e6;
padding: 0.01em 16px;
border: 1px solid #ff9800;
border-radius: 4px;
}
.doconnect{
border-color: #2196F3;
}
span.btn{
padding: 8px 16px;
background: #4CAF50;
color: #fff;
border: none;
cursor: pointer;
display: inline-block;
margin: 10px 0;
}
span.btn:hover{
color: #333;
background: #ccc;
}
.clearfix::after{
content: ' ';
display: table;
clear: both;
}
.label,.item{
display: inline-block;
}
.stdin{
padding: 8px;
}
.stdout{
padding: 12px 16px;
}
</style>
</head>
<body>
<div id="app">
<form>
<div id="disclaimer" class="tipbox box"
>
<p>
This
<span>page</span> uses the
<a href="https://developer.android.com/studio/command-line/adb.html">ADB</a> protocol over
<a href="https://wicg.github.io/webusb">WebUSB</a> to access the Android device connected to your PC via USB. The whole elaboration is done locally and
under your complete responsibility.
<br>
</p>
<p>
<a href="https://labs.mwrinfosecurity.com/blog/webusb/">What could possibly go wrong?</a>
</p>
</div>
<div class="doconnect box ">
<div class="">
<span class="btn" @click="connect">{{vm ? 'disconnect' : 'connect'}}</span>
</div>
</div>
<div class="box" v-show="vm">
<div class="">
<div class="label">
<span class="btn" @click="install">安装</span>
</div>
<div class="item">
<input type="text" @keyUp.enter="install" v-model="url" placeholder="请输入样本地址" class="stdin" />
</div>
</div>
<div class="">
<div class="label">
<span class="btn" @click="() => shell(shellStr)">执行</span>
</div>
<div class="item">
<input type="text" @keyUp.enter="() => shell(shellStr)" v-model="shellStr" placeholder="请输入要执行的命令" class="stdin" />
</div>
</div>
<pre class="stdout" v-html="stdout"></pre>
</div>
</form>
<div v-show="loading" class="loading"></div>
<img src="./adb.svg" alt="">
</div>
<script src="./adb.js"></script>
<script src="./vue.js"></script>
<script>
let app = new Vue({
el: '#app',
data(){
return {
stdout: '',
loading: false,
url: '',
vm: null,
shellStr: '',
boot: null
}
},
created(){
console.log(1)
},
methods:{
async connect(){
if (this.vm) {
this.vm.close()
this.vm = null
this.stdout = ''
this.shellStr = ''
this.url = ''
this.boot = null
await this.sync.quit()
this.sync = null
return
}
try {
this.vm = await Adb.open("WebUSB")
this.boot = await this.vm.connectAdb("host::")
this.sync = await this.boot.sync()
} catch (error) {
this.vm = null
this.boot = null
this.sync = null
}
},
async install(){
this.loading = true
try{
let data = await fetch(this.url).then(res => Promise.resolve(res.blob()))
let file = new File([data], 'test.apk')
await this.sync.push(file, '/sdcard/Download/test.apk', 0644, (e) => {
// console.log(e)
})
await this.shell('pm install /sdcard/Download/test.apk')
}catch(e){
console.log(e)
}
this.loading = false
},
async shell(str){
let shell = await this.boot.shell(str)
let decoder = new TextDecoder();
let html = ''
r = await shell.receive();
while (r.cmd == "WRTE") {
if (r.data != null) {
html += decoder.decode(r.data)
}
shell.send("OKAY");
r = await shell.receive();
}
this.stdout = html
},
async doshell(){
}
}
})
</script>
</body>
</html>