Articles

Metasploit Framework Windows Tutorial
Remote Desktop Connection
Windows Processes That May Be Dangerous
How-To use NetCat a Tutorial
Common Linux Commands
Common Ports
Netcat Commands
HTTP Response Codes
War-Google Hack Terms
Wardriving
Avoiding Social Engineering and Phishing Attacks
Intrusion Detection on Linux
Linux Intrusion Detection
Penetration Testing Guide
Penetration Testing Tools
Social Engineering Fundamentals, Part I: Hacker Tactics
Social engineering (computer security)
The Psychology of Social Engineering

The Archives

General GSO
GovernmentSecurity.org News & Suggestions
In The News
Open Topic
General Security Information
Trash Can
Exploit & Vulnerability Mailing List Archives
Trial Member Forum
Product and Program Reviews GSO Tutorials
System Security
Windows Systems
Beginners Section
Linux & Unix Systems
File Downloads
Exploit Research & Discussion Trojan & Virus Errata
Networking Security / Firewall / IDS / VPN / Routers
System Hardening
E-Mail Security
Wifi Security
Trial Member Uploads
Upload discovered Trojans & Mal ware
GSO Programming Section
C , C++ , VC++
Visual Basic.NET
Perl /CGI
Java/Javascript
PHP/XML/ASP/HTML
Assembly + Other
The Cork Board
Network Security Consultant Directory
Network Security Jobs
The Archives
Encryption Information
General Network Security
Internet Anonymity
HTTP Protocol Security
Linux Security
MS IIS Information
Exploit Articles
Programming / Tool Design
GSO Software Projects
Public Downloads
Microsoft Security Questions and Papers

tibbar
I found this on CodeProject.com:

http://www.codeproject.com/system/VmDetect.asp

Adding it to the beginning of your malware, you can test whether you are running on a honeypot (usually virtual machines), and if so, abandon the attack.

i.e.
CODE

if(IsInsideVPC() == true) return;
if(IsInsideVMWare() == true) return;

... otherwise go ahead....


Here's the functions to do this:

CODE

__declspec(naked) bool IsInsideVPC()
{
 __asm
 {
   push ebp
   mov  ebp, esp

   mov  ecx, offset exception_handler

   push ebx
   push ecx

   push dword ptr fs:[0]
   mov  dword ptr fs:[0], esp

   mov  ebx, 0 // Flag
   mov  eax, 1 // VPC function number
 }

   // call VPC
  _asm __emit 0Fh
  _asm __emit 3Fh
  _asm __emit 07h
  _asm __emit 0Bh

 _asm
 {
   mov eax, dword ptr ss:[esp]
   mov dword ptr fs:[0], eax

   add esp, 8

   test ebx, ebx
   
   setz al

   lea esp, dword ptr ss:[ebp-4]
   mov ebx, dword ptr ss:[esp]
   mov ebp, dword ptr ss:[esp+4]

   add esp, 8

   jmp ret1
  exception_handler:
   mov ecx, [esp+0Ch]
   mov dword ptr [ecx+0A4h], -1 // EBX = -1 ->; not running, ebx = 0 -> running
   add dword ptr [ecx+0B8h], 4 // ->; skip past the call to VPC
   xor eax, eax // exception is handled
   ret
  ret1:
   ret
 }
}



CODE

bool IsInsideVMWare_()
{
 bool r;
 _asm
 {
   push   edx
   push   ecx
   push   ebx

   mov    eax, 'VMXh'
   mov    ebx, 0 // any value but 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   [r] // set return value

   pop    ebx
   pop    ecx
   pop    edx
 }
 return r;
}

bool IsInsideVMWare()
{
 __try
 {
   return IsInsideVMWare_();
 }
 __except(1) // 1 = EXCEPTION_EXECUTE_HANDLER
 {
   return false;
 }
}
BuzzDee
very interesting piece of code! didn't know sth like that is possible! thx!
belgther
but this can be avoided by changing port of vmware which is done by reverse engineering... isn't it?
btw, why ports? does vmware have to do something special with the ports? If yes, what is that?
tibbar
im not sure how vmware works internally, but i guess it might be possible to modify the port number.

in practice though, no honeypot is going to be modded, and most will run under vmware or virtual machine.

few ppl will run a honeypot on a real pc, for fear of malware destroying the bios or HD
belgther
i guess it must be a port that is used for contacting virtual adapter of vmware, and maybe that port is meant... It can be changed somehow, maybe by the drivers... Vmware does that, Virtual PC doesn't...

BTW, i thought in and out instructions were privileged instructions and would be blocked by NT-based systems which i tested with XP... Does this code work? Has anyone tested it?
tibbar
the code works ok on xp, the try catch block is there to handle the case when ur not running vmware (i think in is allowed on vmware but not on proper windows, but i may well be wrong!)
sk3tch
The only thing I would caution against is that there are plenty of legitimate systems now running virtually. With enterprise products such as Microsoft Virtual Server and VMware GSX/ESX (and their amazing P2V which lets you convert a physical box into a virtual machine) there are a lot of companies virtualizing systems.
fulvioo
Related codes:

Detecting SoftICE
Detecting SoftICE NT
Detecting OllyDbg
Detecting Breakpoints
Detecting VMWare
Fooling ProcDump

from
CODE
http://www.honeynet.org/papers/bots/botnet-code.html
belgther
I have some questions about the following code:
Where is INT41 used there? I didn't see it... What did I ever miss?
Why is AX set to 0xF386 by all system debuggers?

CODE

/*
Function: IsSICELoaded
Description: This method is used by a lot of crypters/compresors it uses INT 41,
             this interrupt is used by Windows debugging interface to detect if a
             debugger is present. Only works under Windows.  
Returns: true if a debugger is detected
*/

__inline bool IsSICELoaded() {
_asm {
 mov ah, 0x43
 int 0x68
 cmp ax, 0x0F386 // Will be set by all system debuggers.
 jz out_

 xor ax, ax
 mov es, ax
 mov bx, word ptr es:[0x68*4]
 mov es, word ptr es:[0x68*4+2]
 mov eax, 0x0F43FC80
 cmp eax, dword ptr es:[ebx]
 jnz out_
 jmp normal_
normal_:
 xor eax, eax
 leave
 ret
out_:
 mov eax, 0x1
 leave
 ret
}
return false;
}
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2005 Invision Power Services, Inc.