Init Case
![]() |
![]() INIT SILICONE DIGITAL CAMERA CASE CANON 1100 IS WHITE $2.95 Time Remaining: 6d 10h 54m Buy It Now for only: $2.95 |
![]() INIT SILICONE DIGITAL CAMERA CASE FOR SONY W120 $2.95 Time Remaining: 3d 13h 15m Buy It Now for only: $2.95 |
![]() Sony DSC W120 Digital Camera Silicone Case White INIT $3.99 Time Remaining: 21d 3h 19m Buy It Now for only: $3.99 |
![]() New Init Silver Satin Camera Case 5 w Wrist Strap $6.99 Time Remaining: 4d 9h 21m Buy It Now for only: $6.99 |
![]() Init NT CA127 Silicone Case for Canon SD1100 IS Digital $5.00 Time Remaining: 20d 2h 50m Buy It Now for only: $5.00 |
![]() Init Compact Camera Black Silicone Case for Sony W120 $0.99 Time Remaining: 17d 2h 19m Buy It Now for only: $0.99 |
![]() New init universal camera case fits most SILVER $5.99 Time Remaining: 26d 4h 14m Buy It Now for only: $5.99 |
![]() Init NT CA125 Black Silicone Skin Case for Sony W120 $3.80 Time Remaining: 18d 21h 43m Buy It Now for only: $3.80 |
![]() Init NT CA126 White Silicone Skin Camera Case for Sony W120 Digital Cameras $3.80 Time Remaining: 18d 21h 41m Buy It Now for only: $3.80 |
![]() Init NT CA125 Sony W120 Silicone Camera Skin Case Black $3.99 Time Remaining: 21d 3h 19m Buy It Now for only: $3.99 |
![]() init Silicone Camera Case Sony W120 Digital Cameras NEW $6.00 Time Remaining: 5d 5h 21m Buy It Now for only: $6.00 |
![]() New init universal digital camera case NT CA102 RED $9.10 Time Remaining: 23d 2h Buy It Now for only: $9.10 |
![]() init silicone camera caseNT CA127 Canon SD 1100 IS $2.50 Time Remaining: 27d 2h 15m Buy It Now for only: $2.50 |
![]() NEW init compact digital camera case pouch BURGUNDY $7.99 Time Remaining: 24d 4h 53m Buy It Now for only: $7.99 |
![]() init silicone camera clear caseNT CA126 for sony w120 $2.50 Time Remaining: 19d 4h 5m Buy It Now for only: $2.50 |
![]() init silicone camera caseNT CA128 Canon SD 1100 IS $2.50 Time Remaining: 27d 2h 21m Buy It Now for only: $2.50 |
![]() NEW init ultracompact digital camera case pouch brown $6.99 Time Remaining: 24d 5h 53m Buy It Now for only: $6.99 |
![]() Init NT CA125 Silicone Camera Case for Sony W120 black $3.84 Time Remaining: 20d 3h 28m Buy It Now for only: $3.84 |
![]() Init NT CA126 Silicone Camera Case for Sony W120 trans $3.84 Time Remaining: 20d 3h 29m Buy It Now for only: $3.84 |
![]() Init NT CA128 Silicone Case for Canon SD1100 IS Digital $3.84 Time Remaining: 20d 3h 28m Buy It Now for only: $3.84 |
![]() NEW init compact digital camera case pouch Light blue $7.99 Time Remaining: 24d 4h 24m Buy It Now for only: $7.99 |
![]() init silicone camera black caseNT CA125 for sony w120 $2.50 Time Remaining: 27d 1h 50m Buy It Now for only: $2.50 |
![]() NEW init ultracompact digital camera case pouch $6.99 Time Remaining: 24d 5h 26m Buy It Now for only: $6.99 |
![]() NEW Red Init NT CA102 Nylon Universal Case NEW IN BOX $5.99 Time Remaining: 28d 21h 20m Buy It Now for only: $5.99 |
![]() NEW Blue Init NT CA110 Nylon Universal Case NEW IN BOX $5.99 Time Remaining: 28d 23h 38m Buy It Now for only: $5.99 |
![]() INIT SILICONE CAMERA CASE BLACK FITS SONY W120 CAMERAS $3.99 Time Remaining: 12d 56m Buy It Now for only: $3.99 |
![]() New init universal digital camera case NT CA102 BLACK $6.99 Time Remaining: 13d 18h 36m Buy It Now for only: $6.99 |
![]() INIT black silicone camera case fits Canon SD 1100 IS $3.99 Time Remaining: 1d 3h 44m Buy It Now for only: $3.99 |
| Account limit of 2197 requests per hour exceeded. |
Simple Antirootkit
1. SST: references
2. Algorithm
3. Memory mapped files
4. Implementation
5. Demonstration
6. How to build
Written by:
Victor Milokum, Development Leader of Network Security Team.
1. SST: references
This article is a logical continuation to the article "Driver to Hide Processes and Files" http://www.codeproject.com/KB/system/hide-driver.aspx by Ivan Romananko. You can find all necessary information about System Service Table (SST) and its hooking in it.
In this article I would like to present how to write your own unhooker that will restore original SST hooked by drivers like Ivan's one.
2. Algorithm
My goal is to write a simple driver for SST hooking detection and removing purposes.
This means that our driver should not use various Zw-functions and SST table because I suppose that SST table is corrupted by unknown rootkits.
I do not care about filter drivers and function code splicers for now, but maybe I will come back to them in future.
The simplest way to detect and remove hooks is to compare SST that is placed in memory with the initial SST from ntoskernel.exe file.
So the goal is:
- to find ntoskernel module in memory;
- to find the section of ntoskernel where SST is placed and to calculate relative offset of SST in the section;
- to find this section in the ntoskernel.exe file;
- to calculate real address of SST in the file;
- to read values from the file and to compare them with SST.
But before the implementation I would like to present some additional information.
3. Memory mapped files in kernel mode
"A memory-mapped file is a segment of virtual memory which has been assigned a direct byte-for-byte correlation with some portion of a file or file-like resource". (c) Wiki
Yeah, we want to parse the PE file and memory mapped files are very useful for this task.
And it is easy enough to use mapped files API from the kernel mode, because it is very similar to Win32 API. Instead of CreateFileMapping and MapViewOfSection functions in kernel mode driver should access
NTSTATUS ZwCreateSection( OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL );
and
NTSTATUS ZwMapViewOfSection( IN HANDLE SectionHandle, IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, IN OUT PSIZE_T ViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Win32Protect );
functions.
But if we use these functions we will break our own rule not to use SST. Also, it is good for antirootkit to use extremely low level functions in the hope of being invisible to the possible rootkits.
With regard to this we can use undocumented functions of Memory Manager (Mm), of course at our own risk:
NTSTATUS
MmCreateSection ( OUT PVOID *SectionObject, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize, IN ULONG SectionPageProtection, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL, IN PFILE_OBJECT File OPTIONAL ); NTSTATUS
MmMapViewOfSection( IN PVOID SectionToMap, IN PEPROCESS Process, IN OUT PVOID *CapturedBase, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset, IN OUT PSIZE_T CapturedViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Protect ); NTSTATUS
MmUnmapViewOfSection( IN PEPROCESS Process, IN PVOID BaseAddress ); NTSTATUS drv_MapAllFileEx(HANDLE hFile OPTIONAL, drv_MappedFile * pMappedFile, LARGE_INTEGER * pFileSize, ULONG Protect)
{ NTSTATUS status = STATUS_SUCCESS; PVOID section = 0; PCHAR pData=0; LARGE_INTEGER offset; offset.QuadPart = 0; // check zero results if (!pFileSize->QuadPart) goto calc_exit; status = MmCreateSection (§ion, SECTION_MAP_READ, 0, // OBJECT ATTRIBUTES pFileSize, // MAXIMUM SIZE Protect, 0x8000000, hFile, 0 ); if (status!= STATUS_SUCCESS) goto calc_exit; status = MmMapViewOfSection(section, PsGetCurrentProcess(), (PVOID*)&pData, 0, 0, &offset, &pFileSize->LowPart, ViewUnmap, 0, Protect); if (status!= STATUS_SUCCESS) goto calc_exit; calc_exit: if (NT_SUCCESS(status)) { pMappedFile->fileSize.QuadPart = pFileSize->QuadPart; pMappedFile->pData = pData; pMappedFile->section = section; } else { if (pData) MmUnmapViewOfSection(PsGetCurrentProcess(), pData); if (section) { ObMakeTemporaryObject(section); ObDereferenceObject(section); } } return status;
}
This example demonstrates an alternative approach to the usage of mapped files through MmCreateSection/MmMapViewOfSection functions.
The presented approach is pretty good because it doesn't utilize Zw* functions and even handles at all, but it has one restriction. If you start this sample from DriverEntry it will work fine, but if you start it from the IRP_MJ_DEVICE_CONTROL handler you will see that MmCreateSection function fails with STATUS_ACCESS_DENIED. Why?
The answer is: Zw* functions do one good thing - they set previous mode to KernelMode and this allows to utilize kernel mode pointers and handles as parameters for them (for more information see Nt vs. Zw - Clearing Confusion On The Native API article - http://www.osronline.com/article.cfm?id=257)
So, the presented above function can be called only from DriverEntry or from the system thread.
4. Algorithm implementation
I designed the following structure to save all ntoskernel parsing results:
#define IMAGE_SIZEOF_SHORT_NAME 8
typedef struct _Drv_VirginityContext
{ drv_MappedFile m_mapped; HANDLE m_hFile; UCHAR m_SectionName[IMAGE_SIZEOF_SHORT_NAME+1]; ULONG m_sstOffsetInSection; char * m_mappedSST; ULONG m_imageBase; char * m_pSectionStart; char * m_pMappedSectionStart; char * m_pLoadedNtAddress;
}Drv_VirginityContext;
And I implemented the chosen algorithm as follows:
static NTSTATUS ResolveSST(Drv_VirginityContext * pContext, SYSTEM_MODULE * pNtOsInfo)
{ PIMAGE_SECTION_HEADER pSection = 0; PIMAGE_SECTION_HEADER pMappedSection = 0; NTSTATUS status = 0; PNTPROC pStartSST = KeServiceDescriptorTable->ntoskrnl.ServiceTable; char * pSectionStart = 0; char * pMappedSectionStart = 0; // Drv_ResolveSectionAddress function detects // to which section pStartSST belongs // pSection will contain the section of ntoskernel.exe that contains SST pContext->m_pLoadedNtAddress = (char*)pNtOsInfo->pAddress; status = Drv_ResolveSectionAddress(pNtOsInfo->pAddress, pStartSST, &pSection); if (!NT_SUCCESS(status)) goto clean; // save section name to context memcpy(pContext->m_SectionName, pSection->Name, IMAGE_SIZEOF_SHORT_NAME); // calculate m_sstOffsetInSection - offset of SST in section pSectionStart = (char *)pNtOsInfo->pAddress + pSection->VirtualAddress; pContext->m_sstOffsetInSection = (char*)pStartSST - pSectionStart; // find section in mapped file - on disk! status = Drv_FindSection(pContext->m_mapped.pData, pSection->Name, &pMappedSection); if (!NT_SUCCESS(status)) goto clean; pMappedSectionStart = (char *)pContext->m_mapped.pData + pMappedSection->PointerToRawData; pContext->m_mappedSST = pMappedSectionStart + pContext->m_sstOffsetInSection; { // don´t forget to save ImageBase PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)pContext->m_mapped.pData; PIMAGE_NT_HEADERS pNTHeader = (PIMAGE_NT_HEADERS)((char*)dosHeader + dosHeader->e_lfanew); pContext->m_imageBase = pNTHeader->OptionalHeader.ImageBase; } pContext->m_pSectionStart = pSectionStart; pContext->m_pMappedSectionStart = pMappedSectionStart;
clean: return status;
}
And here is the function that returns real value of SST:
void Drv_GetRealSSTValue(Drv_VirginityContext * pContext, long index, void ** ppValue)
{ char * pSST = pContext->m_mappedSST; ULONG * pValue = ((ULONG *) pSST) + index; // now pValue points to the mapped SST entry // but entry contains offset from the beginning of ntoskernel file, // so correct it *ppValue = (void*)(*pValue + (ULONG)pContext->m_pLoadedNtAddress – pContext->m_imageBase);
}
After that it is quite simple to implement main functionality:
virtual NTSTATUS ExecuteReal()
{ CAutoVirginity initer; NT_CHECK(initer.Init(&m_virginityContext)); // now we are ready to scan
for(int i = 0, sstSize = Drv_GetSizeOfNtosSST(); i < sstSize; ++i) { void ** pCurrentHandler = Drv_GetNtosSSTEntry(i); void * pRealHandler = 0; Drv_GetRealSSTValue(&m_virginityContext, i, &pRealHandler); if (pRealHandler != *pCurrentHandler) { // oops, we found the difference! // unhook this entry Drv_HookSST(pCurrentHandler, pRealHandler); } } return NT_OK;
}
This tiny cycle completely removes all SST hooks and brings SST to its initial state.
6. Demonstration
For testing purposes I developed simple console utility named unhooker.exe. This utility can be started without parameters; in this case it shows information about its abilities:
- "stat" command shows statistics about SST hooking;
- "unhook" command cleans SST;
This sample demonstrates how to use utility to detect and erase hooks:
Have fun!
6. How to build
Build steps are the same as in the "Hide Driver" article. They are:
- Install Windows Driver Developer Kit 2003 - http://www.microsoft.com/whdc/devtools/ddk/default.mspx
- Set global environment variable "BASEDIR" to path of installed DDK. Go here: Computer -> Properties -> Advanced -> Environment variables ->System Variables -> New
And set it like this: BASEDIR -> c:winddk3790
(You have to restart your computer after this.)
If you choose Visual Studio 2003, then you can simply open UnhookerMain.sln and build all.
Downloads (solution and sources)
About the Author
Apriorit is worldwide provider of professional consulting and software development services.
Company operates in the advanced IT fields like Virtualization, Corporate Security, Driver Development.
www.apriorit.com
Second Generation Ipod shuffle InIt Case




























