Qwokka / Cetus

Browser extension for hacking WebAssembly games a la Cheat Engine
Apache License 2.0
530 stars 45 forks source link

Edit values at addresses #76

Open Eyoko1 opened 10 months ago

Eyoko1 commented 10 months ago

After finding the coins for example how can you change it using javascript? I haven't found anything about how to do this and there isn't a feature in cetus to do it

Qwokka commented 10 months ago

Hey @Eyoko1

This should all be doable from Javascript using the modifyMemory function of Cetus. Here's an example of searching and modifying memory using the Javascript console. This will find all values of type i32 matching 1000 and replace them with the value 2000.

const searchResults = cetus.search("eq", "i32", true, 1000);
const resultAddresses = Object.keys(searchResults.results);
for (const address of resultAddresses) {
    cetus.modifyMemory(address, 2000, "i32");
}

If you're using the latest git version, it's a little bit different (Because Cetus can now support multiple WASM binaries at once). The same example would look something like this:

const instance = cetusInstances.get(0);
const searchResults = instance.search("eq", "i32", true, 1000);
const resultAddresses = Object.keys(searchResults.results);
for (const address of resultAddresses) {
    instance.modifyMemory(address, 2000, "i32");
}  

Jack

Eyoko1 commented 10 months ago

I am on the latest version and neither 'cetus' nor 'cetusInstances' are defined

Qwokka commented 10 months ago

Is the browser console in the correct context? On chrome you're looking for a button like this.

context_select

If the extension is unlocked, then one of those variables must be defined.

Eyoko1 commented 10 months ago

Thank you that worked, I have to have the context in the pages html, but every time I load the page I have to manually find the html context and set it, is there a better way to do this?

Qwokka commented 9 months ago

Good question @Eyoko1 , this is one of my biggest annoyances too. I'm frankly not sure what the right fix would be, but I'm gonna add this as a possible improvement.