mirror of
https://github.com/djhackersdev/minime.git
synced 2026-08-21 18:04:04 -05:00
wip
This commit is contained in:
@@ -36,7 +36,7 @@ export default async function aimedb(socket) {
|
||||
// We get sent here if lookup does not return an aimeId
|
||||
|
||||
console.log("Aimedb: Mifare register", req.luid);
|
||||
output.write({ type: req.type, status: 1, aimeId: 12345678 });
|
||||
output.write({ type: req.type, status: 1, aimeId: 0x55667788 });
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -13,6 +13,15 @@ function readHeader(buf: Buffer) {
|
||||
};
|
||||
}
|
||||
|
||||
readers.set(MSG.ACCOUNT_LOCK_REQ, buf => {
|
||||
return {
|
||||
type: "account_lock_req",
|
||||
aimeId: buf.readInt32LE(0x0004),
|
||||
pcbId: buf.slice(0x0008, buf.indexOf("\0", 0x0008)).toString("ascii"),
|
||||
field_0018: buf.readInt16LE(0x0018),
|
||||
};
|
||||
});
|
||||
|
||||
readers.set(MSG.GET_CONFIG_DATA_REQ, () => {
|
||||
return { type: "get_config_data_req" };
|
||||
});
|
||||
@@ -68,9 +77,8 @@ export class Decoder extends Transform {
|
||||
|
||||
const msgCode = this.state.readUInt16LE(0x30);
|
||||
const msgLen = MSG_LEN.get(msgCode);
|
||||
const reader = readers.get(msgCode);
|
||||
|
||||
if (msgLen === undefined || reader === undefined) {
|
||||
if (msgLen === undefined) {
|
||||
return callback(
|
||||
new Error(
|
||||
`Unknown command code ${msgCode.toString(16)}, cannot continue`
|
||||
@@ -82,12 +90,23 @@ export class Decoder extends Transform {
|
||||
return callback(null);
|
||||
}
|
||||
|
||||
const reqBuf = this.state.slice(0x30, 0x30 + msgLen);
|
||||
const payload = reader(reqBuf);
|
||||
const reqBuf = this.state.slice(0, 0x30 + msgLen);
|
||||
const payloadBuf = reqBuf.slice(0x30);
|
||||
|
||||
console.log("Idz: RAW:", reqBuf.toString("hex"));
|
||||
console.log("Idz: Header:", header);
|
||||
console.log("Idz: Payload:", payload);
|
||||
console.log("Idz: Req: Raw:", reqBuf.toString("hex"));
|
||||
console.log("Idz: Req: Header:", header);
|
||||
|
||||
const reader = readers.get(msgCode);
|
||||
|
||||
if (reader === undefined) {
|
||||
return callback(
|
||||
new Error(`No reader for command code ${msgCode.toString(16)}`)
|
||||
);
|
||||
}
|
||||
|
||||
const payload = reader(payloadBuf);
|
||||
|
||||
console.log("Idz: Req: Payload:", payload);
|
||||
|
||||
return callback(null, payload);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@ export const MSG = {
|
||||
GET_CONFIG_DATA_RES: 0x0005,
|
||||
GET_SERVER_LIST_REQ: 0x0006,
|
||||
GET_SERVER_LIST_RES: 0x0007,
|
||||
ACT_LOCK_REQ: 0x0069,
|
||||
ACT_LOCK_RES: 0x006a,
|
||||
ACCOUNT_LOCK_REQ: 0x0069,
|
||||
ACCOUNT_LOCK_RES: 0x006a,
|
||||
UPDATE_STORY_CLEAR_NUM: 0x007f,
|
||||
GET_CONFIG_DATA_2_REQ: 0x00ab,
|
||||
GET_CONFIG_DATA_2_RES: 0x00ac,
|
||||
};
|
||||
@@ -13,5 +14,6 @@ export const MSG_LEN = new Map();
|
||||
|
||||
MSG_LEN.set(MSG.GET_CONFIG_DATA_REQ, 0x0050);
|
||||
MSG_LEN.set(MSG.GET_CONFIG_DATA_2_REQ, 0x0010);
|
||||
MSG_LEN.set(MSG.ACT_LOCK_REQ, 0x001c);
|
||||
MSG_LEN.set(MSG.ACCOUNT_LOCK_REQ, 0x0020);
|
||||
MSG_LEN.set(MSG.UPDATE_STORY_CLEAR_NUM, 0x0020);
|
||||
MSG_LEN.set(MSG.GET_SERVER_LIST_REQ, 0x0020);
|
||||
|
||||
@@ -12,11 +12,20 @@ export class Encoder extends Transform {
|
||||
}
|
||||
|
||||
_transform(obj: Response, encoding, callback) {
|
||||
console.log("Idz: Response:", obj);
|
||||
console.log("Idz: Res: Object:", obj);
|
||||
|
||||
let buf: Buffer;
|
||||
|
||||
switch (obj.type) {
|
||||
case "account_lock_res":
|
||||
buf = Buffer.alloc(0x0020);
|
||||
buf.writeUInt16LE(MSG.ACCOUNT_LOCK_RES, 0x0000);
|
||||
buf.writeInt8(obj.field_0018, 0x0018);
|
||||
buf.writeInt16LE(obj.field_001A, 0x001a);
|
||||
buf.writeUInt32LE(obj.field_001C.getTime() / 1000, 0x001c);
|
||||
|
||||
break;
|
||||
|
||||
case "get_config_data_res":
|
||||
buf = Buffer.alloc(0x01a0);
|
||||
buf.writeUInt16LE(MSG.GET_CONFIG_DATA_RES, 0x0000);
|
||||
@@ -63,6 +72,12 @@ export class Encoder extends Transform {
|
||||
return callback(new Error(`No writer fn for ${obj["type"]}`));
|
||||
}
|
||||
|
||||
console.log("Idz: Res: Encoded:", buf.toString("hex"));
|
||||
|
||||
if (buf.readInt16LE(0) === 0) {
|
||||
throw new Error("MESSAGE TYPE CODE YOU FUCKING IDIOT");
|
||||
}
|
||||
|
||||
return callback(null, buf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Socket } from "net";
|
||||
import { hostname } from "os";
|
||||
|
||||
import setup from "./setup";
|
||||
|
||||
export default async function idz(socket) {
|
||||
export default async function idz(socket: Socket) {
|
||||
const { input, output } = setup(socket);
|
||||
|
||||
console.log("Idz: Connection opened");
|
||||
@@ -10,6 +11,16 @@ export default async function idz(socket) {
|
||||
try {
|
||||
for await (const msg of input) {
|
||||
switch (msg.type) {
|
||||
case "account_lock_req":
|
||||
output.write({
|
||||
type: "account_lock_res",
|
||||
field_0018: 1,
|
||||
field_001A: -1,
|
||||
field_001C: new Date(Date.now() + 3600000),
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "get_server_list_req":
|
||||
const myHost = hostname();
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
export interface AccountLockRequest {
|
||||
type: "account_lock_req";
|
||||
field_0002: number;
|
||||
field_0004: number;
|
||||
field_0008: Buffer;
|
||||
aimeId: number;
|
||||
pcbId: string;
|
||||
field_0018: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
export interface AccountLockResponse {
|
||||
type: "account_lock_res";
|
||||
field_0018: number;
|
||||
field_001A: number;
|
||||
field_001C: Date;
|
||||
}
|
||||
|
||||
export interface GetConfigDataResponse {
|
||||
type: "get_config_data_res";
|
||||
status: number;
|
||||
@@ -49,6 +56,7 @@ export interface GetServerListResponse {
|
||||
}
|
||||
|
||||
export type Response =
|
||||
| AccountLockResponse
|
||||
| GetConfigDataResponse
|
||||
| GetConfigDataResponse2
|
||||
| GetServerListResponse;
|
||||
|
||||
Reference in New Issue
Block a user