Today we’ve been working with Vincent Mussot on a way to prevent VMM detection with red pill. We implemented it as a simple pintool:
// see the PIN manual for compilation instructions #include <iostream> #include <string> #include "pin.H" unsigned long int fake_idt = 0; VOID poison(unsigned int* m) { *(unsigned int*)((*m)+2) = fake_idt; } VOID Instruction(INS ins, VOID *v) { string dis = INS_Disassemble(ins); if (dis.substr(0,4)=="sidt") { unsigned int rpill = INS_Address(ins); unsigned int* m = (unsigned int *)(((char *)rpill)+3); INS_InsertCall(ins, IPOINT_AFTER, (AFUNPTR)poison, IARG_PTR, m, IARG_END); } } // omitted for brevity // parses the command line and sets fakeidt int parseArguments(int argc, char **argv); int main(int argc, char * argv[]) { if(parseArguments(argc, argv)) { printf("Usage: pin -f <toolname> <fake_idt> -- <binary> [arguments]\n"); exit(1); } PIN_Init(argc, argv); INS_AddInstrumentFunction(Instruction, 0); PIN_StartProgram(); return 0; }
Definitely not easy to read, but we followed the red pill coding standards ;) It waits for red pill to execute the SIDT instruction and then overwrites the memory location containing the value of the interrupt descriptor table register (IDTR) with an arbitrary value, given on the command line.
> redpill.exe idt base: 0xff03f400 Inside Matrix! > pin -t puppetmaster.dll 0x2501 -- redpill.exe idt base: 0x2501 Not in Matrix.
Useless when redpill is in kernelland. It’s possible to do the same thing with ptrace (which is GPL :)).
>Useless when redpill is in kernelland
true
>It’s possible to do the same thing with ptrace
what about Windows systems ?
>what about Windows systems ?
Use a hypervisor to prevent redpill on windows in kernelmode.
good job… but… we need puppet master for PIN :)