2008年9月25日星期四

Disclosure Windows Kernel - Kernel time

Today, I disclose a method to get kernel time in Microsoft Windows Operating System. In order to get kernel time, the easy way is to call KeGetCurrentPrcb routine. That's undocument native API.
Using below code segment:PKPRCB Prcb;
ULONG ulKeTime = 0;
Prcb = KeGetCurrentPrcb();
ulKeTime = Prcb->KernelTime;
The prototype of KeGetCurrentPrcb isKPRCB* KeGetCurrentPrcb ( VOID )
Now, let's take a look at its code. It mainly has three rows instruction.
{
ULONG Value;
__asm mov eax, fs:[20h]
__asm mov [Value], eax
return (struct _KPRCB *) Value;
}

Another way is to get EPROCESS structure, then to locate KPROCESS fields.
The main fields of KPROCESS are followings:

DISPATCHER_HEADER Header
ULPTR DirectoryTableBase[2]
KGDTENTRY LdtDescriptor
KIDTENTRY Int21Descriptor
USHORT IopmOffset
UCHAR Ioplvolatile
KAFFINITY ActiveProcessors
ULONG KernelTime // here is kernel time
ULONG UserTime
LIST_ENTRY ReadyListHead
SINGLE_LIST_ENTRY SwapListEntry
LIST_ENTRY ThreadListHead
KSPIN_LOCK ProcessLock

2008年9月5日星期五

#2 - Hypervisor based security solution

Detection methods
1. Behavioral Detection
  • Detecting diverted execution paths
  • Detecting alterations in the number, order, and frequency of system calls
2. Signature Scanners – AV Products
  • Fingerprint Identification
3. Searches memory or the file system for unique byte patterns
4. Integrity Checkers – Tripwire
  • Detects unauthorized changes to system files or to loaded OS components in memory
  • Creates an initial baseline database containing their CRC values
  • Periodically calculates and compares the  CRC’s  of  these files against the initial trusted baseline
5. Diff Based Approach
  • Microsoft  Strider Ghost, System Internals Rootkit Revealer,  F-Secure Blacklight
6. HW-assistant Hypervisor based Approach?

2008年9月4日星期四

ThinkUtility - Proactive Protection against BOSDs

Today, I would like to talk about Operating System crash. First, let's take a look why does system crash? WOW, it's really hard to answer the question. General speaking, the result of BSOD is because system too "sick" to continue. e.g.
 
 A device driver or an operating system function running in kernel mode incurs an unhandled exception. 
  •  A call to a kernel support routine results in a reschedule, such as waiting for an unsignaled dispacther object when the interrunpt request level(IRQL) is DPC/Dispatch level or higher.
  •  A page fault on memory backed by data in a paging file or a memory mapped file occures at an IRQL of DPC/Dispatch level or above (Which would require the memory manager to have to wait for an I/O operation to occur - and, as just stated, waits cannot occur at DPC/Dispatch level or higher because that would require a reschedule. )
  • A device dirver or operating system function explicitly crashes the system (by calling the system function keBugCheckEx) because it detects an internal condition that indicates either a corruption or some other situation that indicates the system cannot continue execution w/o risking data corruption.
  • A hardware error, such as a machine check or a nonmaskable interrupt(NMI), occurs. 
The typical problems are that
  • Unhandled exception
  • OS or driver detects severe inconsistency
  • Invalid memory references
  • Hardware error
Well, Can I do something while system crash? The answer is nothing. If you have configed  system to dump memory, you would see infamous Blue Screen Of Death. 

That's current windows solution. Can we improve it? Definitely, YES. I have developed utility as  Proactive protection method. When I got appropriate FTP website, I will share to everyone.

To be continued...