A new (?) method of starting an executable file on bootup occured to me the other day...
It is reasonably easy to create a driver (.sys) that will load an executable in userland.
The .sys driver can be loaded using createservice api, and will NOT be visible in the service manager or in the control panel (since it did not use an .inf to install).
So, for the average admin this would be very hard to notice.
Also, you could do worse things, like keep a binary string of the executable embedded in the driver, and test for it's existance on each bootup, and recreate it if necessary.
I have no idea if anyone has actually done this, but it is perfectly achievable for a reasonably skilled programmer (which there are many of in the trojan world).
I won't provide POC for this, as it will only encourage use of the technique.
Cheer,
Tibbar.
nackas
Sep 2 2004, 06:56 AM
I'm quite sure that windows rootkits use this method (correct me if I'm wrong). But thanks for the info, I may look deeper into this.
NTIllusion is a userland rootkit, which doesn't use drivers - N.B. drivers work in the kernel not userland!
i was not implying using a rootkit.
What i am saying is that you can make a driver (a .sys), then register this using the service manager.
Now your driver will use the native NT api function ZwCreateProcess(...) to start the trojan app on startup.
If you are very clever, then you could use ZwCreateFile / ZwWriteFile to regenerate the .exe from an embedded hex dump of the file (as described in the forum before for userland apps).
It's not really that hard to do, but you need to be proficient with drivers first.
shiz
Sep 3 2004, 08:01 AM
hxdef does this...
tibbar
Sep 3 2004, 05:26 PM
no it doesn't. the driver used in hxdef is purely for process creation notification (if i remember correctly). hxdef uses userland hooking (the trampolene method).
...looking at driver.c from hxdef, it is used for process impersonation and process information.
Vort3x
Sep 3 2004, 05:33 PM
Well, if a trojan was to incorporate this as a startup method the user that that opens this program with this startup method would have to have Admin privelages for it to work right? So a startup method like this would be quite useless on personal computers(Just saying IF someone made this a part of a trojan).
tibbar
Sep 3 2004, 05:51 PM
well first of all, most people are running with adminstrator priviledges on their home pc.
if not, you could probably still install the service by getting debug privledges using a trick with tokens (ive not checked this point, but i think it would work).
thinking a bit harder, to install a driver (to run on next reboot) you only need registry access, and most users have this.
Flowby
Sep 4 2004, 03:01 AM
kick ass idea m8..a way to go!
chris105
Sep 4 2004, 12:57 PM
Flowby nice site, what happened to that other open source trojan site ?
NTSTATUS status = NT::RtlCreateAcl(dacl, PAGE_SIZE, ACL_REVISION); if (!NT_SUCCESS(status)) return status; status = NT::RtlAddAccessAllowedAce(dacl, ACL_REVISION, FILE_ALL_ACCESS, &SeWorldSid); if (!NT_SUCCESS(status)) return status; RtlZeroMemory(sd, PAGE_SIZE); status = NT::RtlCreateSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION); if (!NT_SUCCESS(status)) return status; status = RtlSetOwnerSecurityDescriptor(sd, &localSid, FALSE); if (!NT_SUCCESS(status)) return status; status = NT::RtlSetDaclSecurityDescriptor(sd, TRUE, dacl, FALSE); if (!NT_SUCCESS(status)) return status; if (!NT::RtlValidSecurityDescriptor(sd)) { _asm int 3; }
/* PAGE_EXECUTE_READWRITE is needed if initialisation code will be executed on stack*/ n = sii.StackCommit + PAGE_SIZE; PVOID p = PCHAR(stack.ExpandableStackBase) - n; NT::ZwAllocateVirtualMemory(hProcess, &p, 0, &n, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
I wish I knew the first thing about driver creation. I can make an EXE to do whatever I want, but as far as using drivers to essentially make it a "rootkit" I'm clueless.
ScriptGod
Sep 16 2004, 07:30 PM
QUOTE (Yorn @ Sep 15 2004, 07:06 PM)
I wish I knew the first thing about driver creation. I can make an EXE to do whatever I want, but as far as using drivers to essentially make it a "rootkit" I'm clueless.
No, you have to make ".sys" files. Normally you install those "drivers" as a system service. Then you can run somethink in ring0 and have access to all things of the system. The first thing you need is the Windows DDK. You will find tutorials etc. in kernel mode rootkits in google But it's not as easy as to write a user mode rootkit. And many things of the Windows internal system are unknown.
BTW: This technic decripted in phrack62 works only under Win2k. I tried this also under WinXP but it doesn't work. Therefore you this needs more research.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.