-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created WASM module. #3
Conversation
Here is the WASM file I extracted from the CoinHive JS module, pulled into radare2 it looks to have been stripped of all function names: This WASM file is a "last resort" only unpacked from a massive bin2dec array in the CoinHive JS when asking the server for a new WASM file fails. it appears to use emscripten which is considered "old-school" in the WASM world. This will require changes to my implementation depending on how the CoinHive script loads the WASM module. |
After testing a compile, the binary has the necessary function and should override the You can download the WASM file to test it yourself here: I currently have no idea how to get the CoinHive script to pull in this WASM file. Testing is going to be interesting to say the least. To compile this yourself you will need to:
|
A video of it functioning 2021-03-31.23-11-52.mp4 |
This won't work, even without seeing a page that uses it. The functions imported by the modal wasm are
These are functions that need to be provided by the page for this wasm to work, so without a way of also injecting JS, this will just cause a console error message. The imports the existing wasm uses are
None of which seem to provide a way to access the DOM. On top of that I believe any page using this would only run the WASM inside a worker, which means we would need a way to use the postMessage interface to cause something to display |
I'm open to pull requests on this if anyone can find a better approach. |
Perhaps we could use the syscall20 import to do something interesting. Edit: on second thought probably not: int env$$__syscall20(int Which, WasmArray<int> VarArgs) {
TRACE_ENTRY();
(void)Which;
(void)VarArgs;
return trace(getpid());
} |
The current code cannot possibly work, nor can it be made to actually create the message to alert the user that coinhive has been halted. Your post makes a somewhat misleading claim:
This simply did not happen. As mentioned by another user, it would definitely crash (the WebAssembly engine would not be able to link symbols). How about a simply not hosting the WebAssemby module? Nothing useful can be done with it. Alternatively, just trapping upon module instantiation, and trapping upon accessing any of the externalized functions - this should prevent/reduce overall code (JS/Wasm) execution, thus reducing resource consumption on affected users' machines. |
Edit: I have solved a lot of my listed problems and learned a lot from this. Read all of my comments for my progress/brain dump on solving this and see the success in the video of my last comment.
I have created the groundwork for a WASM module that also displays the modal. Without knowing more about how coinhive calls this WASM function (i.e. the javascript that loads and runs the WASM miner), there is not much else I can do from here. If you get me a copy or stub of the actual calling javascript I can finish this implementation.
Created in rust using:
An awesome guide on how to utilize Rust with WASM: https://rustwasm.github.io/docs/wasm-bindgen/introduction.html