Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added usb-device-dashboard.zip
Binary file not shown.
49 changes: 49 additions & 0 deletions usb-device-dashboard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# USB Device Dashboard

Plug-and-play PHP 8+ web app (Bootstrap 5) to read and display information from Android devices connected via Fastboot, ADB/MTP, or Samsung Download/COM Port.

## Features
- Fastboot: auto-detect, manual serial, `getvar all` parsing
- ADB/MTP: list devices, select to show `getprop`, run `mtp-detect`
- Samsung: list COM ports, probe with `heimdall print-pit`
- Bootstrap 5 UI with light/dark toggle, responsive layout, AJAX refresh
- Optional WebSocket server for instant actions and selection
- Full in-browser ADB via WebUSB (Chromium-based browsers) — no server binaries required for ADB
- No database, no installer

## Quick Start
1. Upload this folder to your hosting (cPanel) or local PHP server.
2. Ensure PHP 8+ with `proc_open`/`exec` enabled.
3. Linux: place platform-tools binaries as:
- `bin/linux/adb.bin`, `bin/linux/fastboot.bin`
- `bin/linux/heimdall.bin`, `bin/linux/mtp-detect.bin`
Or install them in PATH. Wrappers in `bin/linux/*` will find them.
4. Windows: put binaries next to wrappers in `bin/windows/` (e.g., `adb.exe`, `fastboot.exe`, `heimdall.exe`, `mtp-detect.exe`) or ensure they’re in PATH.
5. Optional: start WebSocket server for live actions
- Linux: `bin/linux/ws-server`
- Windows: `bin/windows/ws-server.cmd`
- Defaults to `ws://0.0.0.0:8081`. Configure in `config.php` under `ws`.
6. Visit `index.php` in a Chromium-based browser for WebUSB support.

## WebUSB / WebADB
- Click “Connect WebADB” to run ADB entirely in browser via WebUSB.
- Requires Chrome/Edge on HTTPS or localhost, USB debugging enabled, and driver/udev set up.
- “Select via WebUSB” can still be used for basic serial detection.

## Notes
- Some shared hosts restrict USB access and process execution. For full functionality use a local machine or a VPS with USB passthrough.
- Samsung COM detection on Linux scans `/dev/ttyUSB*` and `/dev/ttyACM*`. On Windows it uses the `mode` command.
- MTP detection uses `mtp-detect` (Linux). If unavailable, the UI will show raw output as empty.

## Structure
- `assets/` CSS, JS, Bootstrap
- `includes/` PHP helpers
- `api/` endpoints: `fastboot.php`, `adb.php`, `samsung.php`, `mtp.php`
- `bin/` wrappers for Linux/Windows incl. `ws-server`
- `ws-server.php` minimal WebSocket server
- `index.php` UI dashboard
- `config.php` paths and settings

## Security
- This app executes system commands. Host it on trusted machines only.
- WebSocket server is unauthenticated by default. Set `ws.secret` and pass via subprotocol if you expose it.
31 changes: 31 additions & 0 deletions usb-device-dashboard/api/adb.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

require_once __DIR__ . '/../includes/helpers.php';

$action = $_GET['action'] ?? 'auto';

switch ($action) {
case 'devices':
respond_ok(adb_list_devices());
break;
case 'props':
$deviceId = $_GET['id'] ?? '';
if ($deviceId === '') {
respond_error('Missing id');
}
$props = adb_get_properties($deviceId);
respond_ok(['id' => $deviceId, 'props' => $props, 'summary' => extract_adb_summary($props)]);
break;
case 'auto':
default:
$devices = adb_list_devices();
if (count($devices) > 0) {
$id = $devices[0]['id'];
$props = adb_get_properties($id);
respond_ok(['id' => $id, 'props' => $props, 'summary' => extract_adb_summary($props)]);
} else {
respond_ok(['id' => null, 'props' => [], 'summary' => []]);
}
}
28 changes: 28 additions & 0 deletions usb-device-dashboard/api/fastboot.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

require_once __DIR__ . '/../includes/helpers.php';

$action = $_GET['action'] ?? 'auto';

switch ($action) {
case 'devices':
respond_ok(detect_fastboot_device());
break;
case 'getvars':
$serial = $_GET['serial'] ?? null;
$vars = fastboot_getvars($serial);
respond_ok(['serial' => $serial, 'vars' => $vars, 'summary' => extract_fastboot_summary($vars)]);
break;
case 'auto':
default:
$devices = detect_fastboot_device();
if (count($devices) > 0) {
$serial = $devices[0]['serial'];
$vars = fastboot_getvars($serial);
respond_ok(['serial' => $serial, 'vars' => $vars, 'summary' => extract_fastboot_summary($vars)]);
} else {
respond_ok(['serial' => null, 'vars' => [], 'summary' => []]);
}
}
13 changes: 13 additions & 0 deletions usb-device-dashboard/api/mtp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

require_once __DIR__ . '/../includes/helpers.php';

$action = $_GET['action'] ?? 'auto';

switch ($action) {
case 'detect':
default:
respond_ok(mtp_detect_info());
}
28 changes: 28 additions & 0 deletions usb-device-dashboard/api/samsung.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

require_once __DIR__ . '/../includes/helpers.php';

$action = $_GET['action'] ?? 'auto';

switch ($action) {
case 'ports':
respond_ok(detect_samsung_com_ports());
break;
case 'probe':
$port = $_GET['port'] ?? null;
$data = heimdall_print_pit($port);
respond_ok(['port' => $port, 'output' => $data]);
break;
case 'auto':
default:
$ports = detect_samsung_com_ports();
if (count($ports) > 0) {
$port = $ports[0]['port'];
$data = heimdall_print_pit($port);
respond_ok(['port' => $port, 'output' => $data]);
} else {
respond_ok(['port' => null, 'output' => ['stdout' => '', 'stderr' => '']]);
}
}
6 changes: 6 additions & 0 deletions usb-device-dashboard/assets/bootstrap/css/bootstrap.min.css

Large diffs are not rendered by default.

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions usb-device-dashboard/assets/css/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
body {
font-feature-settings: "tnum";
}
pre {
white-space: pre-wrap;
word-break: break-word;
}
.card-body .btn {
white-space: nowrap;
}
Loading