Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F10361088
index.mjs
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
index.mjs
View Options
import
express
from
"express"
;
import
{
readFile
}
from
"node:fs/promises"
;
import
{
guardedScreenshot
,
android_websocket
,
waitFullBoot
,
}
from
"./screenshot.mjs"
;
import
{
execSync
}
from
"node:child_process"
;
import
fileUpload
from
"express-fileupload"
;
const
device_size_x
=
320
;
const
device_size_y
=
640
;
const
app
=
express
();
app
.
use
(
express
.
urlencoded
({
extended
:
false
}));
app
.
use
(
express
.
static
(
"/code/dist"
));
console
.
log
(
"Waiting for full boot..."
);
await
waitFullBoot
();
console
.
log
(
"Boot detected! activating endpoints"
);
//GET
app
.
get
(
"/favicon.ico"
,
function
(
req
,
res
)
{
res
.
sendFile
(
"/code/favicon.ico"
);
});
app
.
get
(
"/htmx.js"
,
function
(
req
,
res
)
{
res
.
sendFile
(
"/code/node_modules/htmx.org/dist/htmx.min.js"
);
});
app
.
get
(
"/trafficLog"
,
async
function
(
req
,
res
)
{
res
.
sendFile
(
"/log/trafficLog"
);
});
app
.
get
(
"/screen"
,
async
function
(
req
,
res
)
{
await
guardedScreenshot
();
res
.
sendFile
(
"/code/screenshot.png"
);
});
app
.
get
(
"/"
,
async
function
(
req
,
res
)
{
let
fileData
=
(
await
readFile
(
"/code/index.html"
)).
toString
();
fileData
=
fileData
.
replace
(
"___screenshotDelayMs___"
,
process
.
env
.
screenshotDelayMs
);
res
.
setHeader
(
"Content-Type"
,
"text/html"
);
res
.
setHeader
(
"Content-Disposition"
,
"inline"
);
res
.
send
(
fileData
);
});
//POST
app
.
post
(
"/back"
,
function
(
req
,
res
)
{
android_websocket
.
send
(
`back`
);
res
.
sendStatus
(
200
);
});
// default options
app
.
use
(
fileUpload
());
app
.
post
(
"/upload_apk"
,
async
function
(
req
,
res
)
{
if
(
!
req
.
files
||
Object
.
keys
(
req
.
files
).
length
===
0
)
{
return
res
.
status
(
400
).
send
(
"No files were uploaded."
);
}
execSync
(
"rm -rf /shared_buffer/*"
);
if
(
Array
.
isArray
(
req
.
files
.
app
))
{
for
(
const
[
idx
,
file
]
of
req
.
files
.
app
.
entries
())
{
let
uploadPath
=
"/shared_buffer/app"
+
idx
+
".apk"
;
await
file
.
mv
(
uploadPath
);
}
}
else
{
let
uploadPath
=
"/shared_buffer/app"
+
0
+
".apk"
;
await
req
.
files
.
app
.
mv
(
uploadPath
);
}
android_websocket
.
send
(
`install`
);
res
.
send
(
"Files uploaded!"
);
});
app
.
post
(
"/home"
,
function
(
req
,
res
)
{
android_websocket
.
send
(
`home`
);
res
.
sendStatus
(
200
);
});
app
.
post
(
"/touch"
,
function
(
req
,
res
)
{
const
x
=
parseInt
(
req
.
body
.
x
);
const
y
=
parseInt
(
req
.
body
.
y
);
if
(
isNaN
(
x
)
||
isNaN
(
y
)
||
x
>
device_size_x
||
y
>
device_size_y
)
{
res
.
send
(
`the query params must be x <=
${
device_size_x
}
, y <=
${
device_size_y
}
\n`
);
}
else
{
android_websocket
.
send
(
`touch
${
x
}
${
y
}
`
);
res
.
sendStatus
(
200
);
}
});
app
.
post
(
"/drag"
,
function
(
req
,
res
)
{
const
body
=
req
.
body
;
const
startX
=
Number
(
body
.
startX
);
const
startY
=
Number
(
body
.
startY
);
const
endX
=
Number
(
body
.
endX
);
const
endY
=
Number
(
body
.
endY
);
android_websocket
.
send
(
`drag
${
startX
}
${
startY
}
${
endX
}
${
endY
}
`
);
res
.
sendStatus
(
200
);
});
app
.
listen
(
8080
,
()
=>
console
.
log
(
"Listening in port 8080"
));
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sat, Nov 8, 11:02 (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1034495
Default Alt Text
index.mjs (2 KB)
Attached To
Mode
R134 rentgen-android
Attached
Detach File
Event Timeline
Log In to Comment