-
Notifications
You must be signed in to change notification settings - Fork 82
Injection example doesn't list processes. #2
Comments
Must be some null pointer read. Will have to investigate. |
Or it could also be wrong offsets. In fact, all reads should be sanitized properly. Could you run the commands of injection manually inside GDB and post the backtrace here once it crashes? Build in debug mode first so that line information is preserved. |
I'm not sure line information was preserved here. |
Okay, so apparently injecting the library does work just fine. It is the unloading part that is not properly working. Which version of Windows 10 LTSC are you running. Could you, please, post the OS version and build information here (through winver or settings)? That will help me either get my hands on the windows version or at least look for correct structures. |
Okay, I will take a look. Thank you. In addition, what is your qemu set up? Are you using q35 chipset? In case you are using the other (default) platform chipset, it could actually be the main issue. |
I took a look and I was not using the q32 chipset I changed it from "pc-i440fx-2.1" to "pc-q35-2.12" in my VM XML file.
|
Lol my curiousity peaked at the standalone example you had. It works. |
So the non-injecting code works fine? Then it seems that once again, unloading doesn't properly work, but the output file should be in tact inside the /tmp folder. Anyways, I will have to figure out what is causing the unload problem and then also add a note regarding the chipset, as it seems to be a recurring problem. |
I ran the injector again to double check, but there was no "testr.txt" in /tmp. |
Does running the ./inject normally work? I believe the issue could be the fact that relative (CWD) paths do not work on dlopen. I have just tested ./inject and it ran just fine for me. |
No.
Doesn't the injection script use a absolute path? |
The injection script does use absolute path but it is expanded by shell. I do not know whether you did expand the path or not. |
The fact that injection does not work properly is rather worrying, because I am unable to reproduce it and yet the library does not load for you (assuming $library is null after dlopen. Otherwise it should either work or crash). I suppose it would be wise to check with dlerror what load error was that, however, it is rather finicky to execute it through GDB. |
And I did just that, dlopen returns a nullptr, so when dlclose is called it dereferences a null pointer Currently checking why with dlerror.. |
Note, gdb was was ran as root. |
Try checking whether or not libexample.so has executable permissions set on all users. If that fails, try moving it to the /usr/lib directory (however, I doubt that would change anything). Also check with ldd -r libexample.so to check all the library dependencies. In some cases it could be that requested library versions and the ones used in qemu are mismatching and can not co-exist (can be checked through /pid/$(pidof qemu-system-x86_64)/maps). In that case you would need to figure out a way to make qemu use the latest libraries, or link the example against the newest ones. |
I chmod'ed it to 777 (all user all access) - Nope.
|
Oh yeah, it injects alright, I found "/tmp/testr.txt"
I am also confused and amazed that moving the shared lib to /usr/lib actually fixes the issue of injecting. Odd. |
Really odd. For starters it fails to create the testr file when being in the build directory (could be due to /tmp permissions). The really odd part is that it fails to locate the kernel base. As you said, the standalone example works. Thus, there is no real reason why this should not work. Try breakpointing here or adding a MSG to print out the pid, mapsStart and mapsSize variables. |
Compare it with what happens on the standalone example, see if something odd occurs. |
Wasn't reason why it didn't create testr.txr when in the build dir. because dlopen failed open the .so because of permission issues so that the init() wasn't called at all?
Kay. |
Yeah my bad. I misread that the crash happened when you set the permissions to 777. |
Getting closer, the injector shits itself at: Now comparing with standalone as to why. |
out file pointer must be null. But it worked once previously, didn't it? |
Wow, I was just about to say, yes. Also I think it is (as you said) a permission issue with /tmp. |
It could definitely be the case since by default, qemu runs on a highly unprivileged user. |
That occurs when setting VM up with virt-manager. You could try making kvm run as your user (this might be needed anyways in case audio does not work really well out of the box), however, it may bring potential security complications (after all, you are executing arbritary code, even though it is rather sandboxed). |
Those options are in the /etc/libvirt directory |
Alright I pinpointed the issue, if you are using virt-manager it places qemu by default in a security context.
I learned a lot today. By the way, awesome project @Heep042 and thanks for the help. |
You are welcome, and I'm glad to know the problem is solved. |
Running Windows 10 LTSC,
The external method returns the following:
The injection method simply crashes Qemu.
Possibly caused by the wrong offsets?
The text was updated successfully, but these errors were encountered: