Page 1 of 1
Interesting VMM Detection Technique
Posted: Fri Jun 30, 2006 1:37 am
by SpooK
----->
http://invisiblethings.org/tools/redpill.c <-----
Thought it was pretty neat, although I have not tested it myself. I'll get around to testing it, eventually

Posted: Fri Jun 30, 2006 7:36 am
by gaf
Hi Spook,
is there some kind of competition going on about who can post the most obscure program ? After all this is alredy the second thread this week that presents some barely readable code-fragment..
It took me some time to get the hang of the snippet and I can't say that I was rewarded. All it seems to do is to check if the idt base-address is located in some special area (namely, base &0xff00 > 0xd000). This is however nonsense in my opinion as the IDT may be located pretty much anywhere in memory. The only restriction I'm aware of is that the table should (must?) be aligned to a 8 byte boundary.
Here's my interpretation of the snippet:
Code: Select all
struct idt_register
{
unsigned short limit;
unsigned long address;
}__attribute__((__packed__));
int main()
{
idt_register idtr;
// Get the IDT's base-address using the SIDT instruction
asm("sidt (%%eax)\n" : : "a"(&idtr));
// If the IDT is stored in the last 16k of a 64k block
// we're running on a virtual machine ?!
if((idtr.address &0xff00) > 0xd000)
cout << "Running on a virtual machine" << endl;
cout << "IDT location: " << setbase(16) << idtr.address;
}
Is there anything I missed ?
regards,
gaf
Posted: Fri Jun 30, 2006 3:06 pm
by Pelz
Posted: Fri Jun 30, 2006 3:24 pm
by SpooK
Learning is not about conforming to your assumptions and expectations.
Posted: Sat Jul 01, 2006 6:33 am
by gaf
Hello,
I've noted a small bug in the code that I provided in my last post. As the data in the array (m) is stored in the little-endian covention it would actually be if(idtr.address > 0xd0000000). Along with the article Pelz pointed out this at least explains how it's supposed to work.
Learning is not about conforming to your assumptions and expectations.
That's the very reason why I asked whether I missed anything. I still don't think that there's really much to learn from the snipped: It's just some utterly hacky piece of code based an a number of assumtions about the internal workings of VMWare.
regards,
gaf
Posted: Sat Jul 01, 2006 8:50 am
by chase
gaf wrote:Hello,
It's just some utterly hacky piece of code based an a number of assumtions about the internal workings of VMWare.
Kinda of reminds me of some of the old techniques to determine cpu models. You'd do things like see if segements rapped around in memory and other stuff. Ugly yes, but possibly useful under the right situation. Thank God for cpuid
I haven't looked at(used but not hacked at) a lot of the VM type software but I thought I remember reading something about the VMs providing extra BIOS services to interact the host OS. Is this a known/typical type thing?
Posted: Sat Jul 01, 2006 11:33 am
by carbonBased
chase wrote:
I haven't looked at(used but not hacked at) a lot of the VM type software but I thought I remember reading something about the VMs providing extra BIOS services to interact the host OS. Is this a known/typical type thing?
I guess that'd kind-of be like dpmi, but to the potentially-different host OS? Sounds feasible, but I don't understand why this is. Is there a breed of software designed to run in a VM? Or is this just an interface to allow them to run better in a VM, if they happen to be in one?
This also reminds me of Xen, which requires the guest OS to be built against a set of APIs that allow it to be better virtualized (that's what a gather the basic concept is... admitantely, I haven't looked at it much, so this may not be entirely accurate).
--Jeff