Heeding the call of vx-underground at 11pm on a Sunday night.
As the goblin that I am, I decided to take on this challenge despite having an 8 am math class in ~7 hours (at the time of writing). A few problems for me though:
- I don't own MATLAB
- MATLAB costs money that I don't have right now
- Octave, the open source option, doesn't really support
loadlibraryspecifically, and even then, seems more oriented and built for Linux- Anything is possible, but the gymnastics of trying to do this in Octave instead seemed like a headache
- Definitely a place for Linux malware though with the
.octfiles for sure
- My school has a license, but I have to use this Citrix-like option to remote into the computers with MATLAB, which was not working when I wanted to try this
So, I go on my humble journey to sign up for a trial, download said trial, and get to work. Knowing that waking up for this math class is probably more important than writing the cleanest and crispiest MATLAB malware possible, I decided to not fight the arcane usage and implementation of loadlibrary and calllib (but I will be coming back to those once I have time).
Also, turns out that I can't use the mcc MATLAB compiler without first asking reps for a free trial? It's definitely possible to compile the code I have here into a standalone executable, but the capitalist gods above have said no for the time being. 😔
WIP - not done, might do later, might do never who knows
A mex file effectively allows you call C or C++ (or Fortran???) from within a MATLAB script. They have documentation for it here, or you can be a skid like me and just ask ChatGPT for a basic template and move on. Rather than do some weird MATLAB stuff to take an array, treat it as shellcode, and call WinAPI functions on it, just throw the C in there 🤷♂️