first commit
This commit is contained in:
commit
b6256abbfb
397 files changed
+537630
No files matched your search
@@ -0,0 +1,107 @@
|
||||
import "dotenv/config";
|
||||
export { LocoClient, type ChatMessage } from "./client.js";
|
||||
export {
|
||||
LocoSocket,
|
||||
fetchBookingServer,
|
||||
resolveCheckinServer,
|
||||
} from "./net/index.js";
|
||||
export {
|
||||
buildLocoPacket,
|
||||
parseLocoPacket,
|
||||
buildEncryptedPacket,
|
||||
parseEncryptedPacket,
|
||||
buildHandshakePacket,
|
||||
PacketReader,
|
||||
} from "./protocol/index.js";
|
||||
export {
|
||||
aesEncryptGCM,
|
||||
aesDecryptGCM,
|
||||
generateAESKey,
|
||||
generateNonce,
|
||||
rsaEncryptOAEP,
|
||||
toPem,
|
||||
} from "./crypto/index.js";
|
||||
export type * from "./types/index.js";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Example: run directly with `node --experimental-strip-types src/index.ts`
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const isMain = process.argv[1]?.endsWith("index.js");
|
||||
|
||||
if (isMain) {
|
||||
const { LocoClient } = await import("./client.js");
|
||||
const { toPem } = await import("./crypto/rsa.js");
|
||||
const { resolveCheckinServer } = await import("./net/booking.js");
|
||||
|
||||
const pubkeyHex = process.env["LOCO_SERVER_PUBKEY_HEX"] ?? "";
|
||||
const serverPublicKey = pubkeyHex
|
||||
? toPem(Buffer.from(pubkeyHex, "hex").toString("base64"))
|
||||
: "";
|
||||
|
||||
const credentials = {
|
||||
oauthToken: process.env["LOCO_OAUTH_TOKEN"] ?? "",
|
||||
duuid: process.env["LOCO_DUUID"] ?? "",
|
||||
userId: Number(process.env["LOCO_USER_ID"] ?? "0"),
|
||||
appVer: process.env["LOCO_APP_VER"] ?? "26.1.2",
|
||||
lang: "ko",
|
||||
mccmnc: "45005",
|
||||
};
|
||||
|
||||
if (!serverPublicKey || !credentials.oauthToken) {
|
||||
console.error(
|
||||
"Missing environment variables. Required:\n" +
|
||||
" LOCO_SERVER_PUBKEY_HEX - Server RSA public key (DER hex)\n" +
|
||||
" LOCO_OAUTH_TOKEN - OAuth token from Frida capture\n" +
|
||||
" LOCO_DUUID - Device UUID\n" +
|
||||
" LOCO_USER_ID - KakaoTalk user ID\n" +
|
||||
" LOCO_APP_VER - App version (default: 26.1.2)\n",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Step 1: Booking — discover LOCO server via LOCO protocol
|
||||
console.log("[Booking] Resolving LOCO server from booking-loco.kakao.com...");
|
||||
const locoServer = await resolveCheckinServer(serverPublicKey, {
|
||||
os: "android",
|
||||
MCCMNC: credentials.mccmnc,
|
||||
model: "",
|
||||
});
|
||||
console.log(`[Booking] LOCO server: ${locoServer.host}:${locoServer.port}`);
|
||||
|
||||
// Step 2: Connect to LOCO server (raw TCP + RSA handshake + AES-GCM)
|
||||
// CHECKIN + LOGINLIST + all commands happen on this single encrypted connection
|
||||
const config = {
|
||||
host: locoServer.host,
|
||||
port: locoServer.port,
|
||||
useTLS: false,
|
||||
serverPublicKey,
|
||||
};
|
||||
|
||||
const client = new LocoClient(config, credentials);
|
||||
|
||||
// Log every raw packet for protocol analysis
|
||||
client.onPacket = (header, body) => {
|
||||
console.log(
|
||||
`[${header.command}] id=${header.id} status=${header.statusCode}`,
|
||||
);
|
||||
console.log(JSON.stringify(body, null, 2));
|
||||
console.log("---");
|
||||
};
|
||||
|
||||
// Log decoded messages
|
||||
client.onMessage = (msg) => {
|
||||
console.log(
|
||||
`\n[Chat ${msg.chatId}] sender=${msg.sender}: ${msg.message}\n`,
|
||||
);
|
||||
};
|
||||
|
||||
try {
|
||||
const loginData = await client.login();
|
||||
console.log("[LocoClient] Login successful. Chat data received.");
|
||||
client.listen();
|
||||
} catch (err) {
|
||||
console.error("[LocoClient] Failed:", err);
|
||||
client.disconnect();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user