frida / frida-compile

Compile a Frida script comprised of one or more Node.js modules
Other
190 stars 48 forks source link

Fix to ensure module map data can be omitted correctly #95

Open hexploitable opened 2 months ago

hexploitable commented 2 months ago

Currently module map data is written out to the JS irrespective of whether -S is used. This PR addresses this and correctly produces JS without the module map data embedded within.

Example:

➜  frida-compile git:(main) βœ— frida-compile foo.js
πŸ“¦
358 /foo.js.map
171 /foo.js
11 /foo.d.ts
βœ„
{"version":3,"file":"foo.js","sourceRoot":"/home/hex/Tools/frida-compile/","sources":["foo.js"],"names":[],"mappings":"AAAA,MAAM,GAAG,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAA;AAEtC,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAA;AAC3C,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;IACnB,OAAO,CAAC,GAAG,CAAC,cAAc,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;AAC5C,CAAC,CAAC,CAAA"}
βœ„
const mod = Process.enumerateModules();
console.log(`Modules found: ${mod.length}`);
mod.forEach((modObj) => {
    console.log(`Mod name:= ${modObj.name}`);
});
export {};
βœ„
export {};

Vs:

➜  frida-compile git:(main) βœ— frida-compile -S foo.js
πŸ“¦
172 /foo.js
11 /foo.d.ts
βœ„
const mod = Process.enumerateModules();
console.log(`Modules found: ${mod.length}`);
mod.forEach((modObj) => {
    console.log(`Mod name:= ${modObj.name}`);
});
export {};

βœ„
export {};