add SendUsrChk and test it

This commit is contained in:
DavidVentura
2024-01-25 10:09:41 +01:00
parent 723384b89a
commit 957a4b5cab
4 changed files with 29 additions and 4 deletions
+8
View File
@@ -0,0 +1,8 @@
{
"extensions": ["ts", "js"],
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm"
]
}
+7 -1
View File
@@ -1,4 +1,4 @@
.PHONY: run install-wireshark-dissector
.PHONY: run install-wireshark-dissector test
bundle.js: asd.js func_replacements.js
~/node_modules/.bin/frida-compile -o $@ asd.js
@@ -11,6 +11,12 @@ venv: requirements.txt
run: bundle.js venv
./venv/bin/python3 -u loader3.py
node_modules:
npm install
test: node_modules
./node_modules/.bin/mocha --require ts-node/register tests/fn.test.js
install-wireshark-dissector:
mkdir -p ~/.local/lib/wireshark/plugins
ln -s $(PWD)/dissector.lua ~/.local/lib/wireshark/plugins/dissector.lua
+2 -2
View File
@@ -7,7 +7,7 @@ const str2byte = (s: string): number[] => {
return Array.from(s).map((_, i) => s.charCodeAt(i));
};
const SendUsrChk = (username: string, password: string): DataView => {
export const SendUsrChk = (username: string, password: string): DataView => {
// type is char account[0x20]; char password[0x80];
let buf = new Uint8Array(0x20 + 0x80);
buf.fill(0);
@@ -40,4 +40,4 @@ const SendUsrChk = (username: string, password: string): DataView => {
return retret;
};
console.log(hexdump(SendUsrChk("admin", "admin").buffer, { ansi: true }));
//console.log(hexdump(SendUsrChk("admin", "admin").buffer, { ansi: true }));
+12 -1
View File
@@ -1,9 +1,10 @@
import "../shim.js";
import "../shim.ts";
import assert from "assert";
import { placeholderTypes, sprintf } from "../utils.js";
import { XqBytesDec, XqBytesEnc } from "../func_replacements.js";
import { SendUsrChk } from "../impl.ts";
describe("debug_tools", () => {
it("parses printed data", () => {
@@ -89,3 +90,13 @@ describe("module", () => {
assert.deepEqual(new Uint8Array(in_buf.buffer), long_dec_bytes); //DEC
});
});
const hstrToBA = (hs) => new Uint8Array(hs.match(/../g).map((h) => parseInt(h, 16))).buffer;
describe("make packet", () => {
it("builds a good SendUsrChk", () => {
const expected_str =
"f1d000b0d1000000110a2010a400ff00000000006f01010101010101010101010101010101010101010101010101010160656c686f01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010160656c68";
const expected = hstrToBA(expected_str);
assert.deepEqual(SendUsrChk("admin", "admin").buffer, expected);
});
});