Virtualmachine memiliki hardware profile yang unik, sehingga dengan melakukanstring compare, kita bisa menentukan apakah program kita berjalan diatas virtual machine atau tidak. Inilah yang dinamakan dengan directhardware fingerprinting.
Bagi yang suka bahasa BASIC, ini ada code snippet yang bersumber dari http://blogs.msdn.com/virtual_pc_guy/archive/2005/10/27/484479.aspx>Virtual PC guy.Dim ManufacturerstrComputer
Code:
= "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colItems = objWMIService.ExecQuery("Select * from Win32_BaseBoard")For Each objItem in colItems
Manufacturer = objItem.Manufacturer
Nextif Manufacturer = "Microsoft Corporation" then
wscript.echo "In Microsoft virtual machine"
else
wscript.echo "Not in Microsoft virtual machine"
end if Bagiyang tidak mengerti bahasa BASIC dan mempunyai dasar algoritma, scriptmengidentifikasi Motherboard Manufacture Information dan meneruskannyauntuk dicheck apakah motherboardnya dibuat oleh Microsoft Corporation.Apabila iya, tentu program kita berjalan di atas virtual machine.
“Eh Den, yang indirect hardware fingerprintingnya belum tuh tadi?”
Oh ya sob…hampir lupa…
Bagi yang suka sedikit tantangan, indirect hardware fingerprinting tepat sekali untuk melakukan exercise. Saya kasi clue nih…
Ingetkalau Intel x86 mengizinkan kita melakukan operasi input/output (IO),yang dinamakan dengan IN dan OUT? Pertama, pada operasi I/O, keduaintruksi ini tidak bisa bisa berjalan di dalam user-mode tetapi apabiladilaksanakan di dalam privilege-mode maka akan memunculkan eksepsi “EXCEPTION_PRIV_INSTRUCTION” .
Kedua,pada VMWare, ada suatu I/O port spesifik yang dipergunakan untukmelakukan komunikasi dengan OS yang sebenarnya. Dalam assembly, portini didesign special dengan nama VX (0x5658).
Berikut adalah code snippet untuk mengidentifikasi OS Windows dalam VMWare (bahasa C):
bool IsInsideVMWare()
Code:
{
bool rc = true;
__try
{
__asm
{
push edx
push ecx
push ebx
mov eax, 'VMXh'
mov ebx, 0 // any value but not the MAGIC VALUE
mov ecx, 10 // get VMWare version
mov edx, 'VX' // port number
in eax, dx // read port
// on return EAX returns the VERSION
cmp ebx, 'VMXh' // is it a reply from VMWare?
setz [rc] // set return value
pop ebx
pop ecx
pop edx
}
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
rc = false;
}
return rc;
}
Source code lengkapnya dapat diperoleh di codeproject.
Untuk OS Linux dalam VMWare (ref. source code by Andrew Hintz)
/** 4tphi-vmchk.c * Detects if you are in a VMWare virtual machine. * *Written by Andrew Hintz * and AAron Walters * Fortify ResearchLaboratories * * "Oft at the hives of his tame bees * They would theirsugary thirst appease." * * This program is based on info and codefrom: * http://chitchat.tripod.co.jp/vmware/ * by [email protected] * * Notes: * The program can be run as a normal user. * We tested the program only in x86 Linux. * The m4dn3ss lives on! */
#include
#include
#if __INTSIZE == 2 /* 16 bit environment */
typedef unsigned int uint16;
typedef unsigned long uint32;
#else /* 32 bit environment */ typedef unsigned short uint16;
typedef unsigned int uint32;
#endif /* __INTSIZE */
void segfault()
{ printf("Not running inside VMware.\n"); exit(1); }
int main(){ uint32 verMajor, verMinor, magic, dout; signal(SIGSEGV, segfault);
__asm____volatile__ (" mov $0x564D5868, %%eax; /* magic number */ mov$0x3c6cf712, %%ebx; /* random number */ mov $0x0000000A, %%ecx; /*specifies command */ mov $0x5658, %%edx; /* VMware I/O port */ in %%dx,%%eax; mov %%eax, %0; mov %%ebx, %1; mov %%ecx, %2; mov %%edx, %3; " :"=r"(verMajor), "=r"(magic), "=r"(verMinor), "=r"(dout) );
if (magic == 0x564D5868)
{ printf("Running inside VMware. ");
printf("(Version %lu,%lu)\n", verMajor, verMinor); /* I'm not really sure what the versions mean. */ }
return 0; }
/* end main */
/* end of file */
“Syukurlah,akhirnya gw ngerti sekarang. Nah tapi, janji lo tadi? Gimana caraprogram kita melawan teknologi B-HAVE? Kan ini hanya untuk VMWare?”
Hahaha…benarjuga. Ini PR untuk teman2 semua. Intinya, kalau semua Virtual Machineselalu berkomunikasi dengan host induknya, sehingga kita bisa melakukanidentifikasi terhadap port special pada VMware.
Nah, teman-teman thanks a lot buat perhatiannya.
Share This Thread