-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hiding users (net.exe and lusrmgr.msc) #74
Comments
A user has lots of traces all over the system, such as its files, an entire registry hive, etc. etc... What's your intention? Why do you consider |
windows has RDP service and control over RDP service required Admin User.the most obvious way to list all local users is net.exe,net1.exe and lusrmgr.msc. |
Thanks for doing some research upfront. I've checked what this function is doing. It eventually calls Call stack: This is the call to
I've done only some quick research, but didn't check where this RPC is going. It would be best to hook the function at the remote endpoint (on the local computer of course). If this is not possible, hooking I think this function is filling an array with the users. Would you like to hook it and inspect the output? |
hooking NetUserEnum would do the trick about(net.exe user or net1.exe user),but not for "net.exe localgroup administrators" or "net1.exe localgroup administrators" command.trying NetGroupGetUsers,NetLocalGroupGetMembers and NetQueryDisplayInformation,but no luck. |
Have you tried hooking |
I will try |
there is an issue by hook NdrClientCall3 static CLIENT_CALL_RETURN RPC_VAR_ENTRY HookedNdrClientCall3(MIDL_STUBLESS_PROXY_INFO* pProxyInfo, unsigned long nProcNum, void* pReturnValue, ...)
} try hooking like this,NdrClientCall3 get trigged but result in The binding handle is invalid when use net.exe user command.no sure how to call the original api based on that api defination. |
I've disassembled
So first, I also wondered that such a low level function acutally uses argument lists, but it does. However, it calls Just to let you know, it's perfectly normal to spend weeks on figuring out one silly function. I've spent ages on figuring out the |
the NdrClientCall3 definetion is from rpcndr.h |
IDA is a nice thing to learn, if you regularly work with hooks, exploits, etc... You can hook a function that isn't exported, as long as you know the function pointer. You can get it using Dunno, if |
found an issue today.After install the rootkit, "net.exe localgroup" will always return the error "System error 234 has occurred.More data is available." |
The below should resolve the errors being described. 1. For Error 234 (ERROR_MORE_DATA): // Current problematic pattern
NetLocalGroupEnum(server, level, &buffer, prefmaxlen, &entriesread, &totalentries, &resumehandle)
// Solution: Implement proper buffer handling
DWORD FixNetLocalGroupEnum(LPCWSTR servername) {
LPBYTE buffer = NULL;
DWORD entriesread = 0;
DWORD totalentries = 0;
DWORD_PTR resumehandle = 0;
do {
DWORD result = NetLocalGroupEnum(
servername,
0, // Use level 0 first for names only
&buffer,
MAX_PREFERRED_LENGTH, // Let system allocate needed size
&entriesread,
&totalentries,
&resumehandle
);
if (result != NERR_Success && result != ERROR_MORE_DATA)
return result;
// Process buffer here
NetApiBufferFree(buffer);
} while (resumehandle != 0);
} 2. For NdrClientCall3 hooking: typedef struct _NDR_PROC_CONTEXT {
MIDL_STUBLESS_PROXY_INFO* pProxyInfo;
UINT32 ProcNum;
void* pReturnValue;
SIZE_T StackSize;
PVOID Args[];
} NDR_PROC_CONTEXT, *PNDR_PROC_CONTEXT;
// Correct x64 hooking
CLIENT_CALL_RETURN NTAPI HookedNdrClientCall3(
MIDL_STUBLESS_PROXY_INFO* pProxyInfo,
unsigned int procNum, // Changed from long to match platform size
void* pReturnValue,
...
) {
NDR_PROC_CONTEXT ctx;
va_list args;
va_start(args, pReturnValue);
// Preserve stack alignment for x64
ctx.pProxyInfo = pProxyInfo;
ctx.ProcNum = procNum;
ctx.pReturnValue = pReturnValue;
// Call original with preserved context
CLIENT_CALL_RETURN result = ((PFN_NDRCLIENTCALL3)OriginalNdrClientCall3)(
ctx.pProxyInfo,
ctx.ProcNum,
ctx.pReturnValue,
va_arg(args, void*) // Properly advance va_list
);
va_end(args);
return result;
} Key changes:
Next steps would be to:
|
I created a new branch NdrClientCall3 to test hooking of the To test it, I ran |
Working on mid term and I will test it this weekend
…---Original---
From: "Martin ***@***.***>
Date: Fri, Nov 1, 2024 08:53 AM
To: ***@***.***>;
Cc: ***@***.******@***.***>;
Subject: Re: [bytecode77/r77-rootkit] Hiding users (net.exe and lusrmgr.msc)(Issue #74)
I created a new branch NdrClientCall3 to test hooking of the NdrClientCall3 function. WARNING: Do not inject all processes! Only inject one process at a time.
To test it, I ran lusrmgr.msc and injected the mmc.exe process, which displays an empty list or crashes. @vps You seem to have gotten familiar with the function and I assume you did some testing yourself and that your tests didn't crash. Would you share your results with me? Do you see anything wrong with the code I pushed onto that branch?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
I didn't install R77,I will code a dll for NdrClientCall3 hook,and set the AppInit DLLs to load that dll would load from certain exe like mmc.exe,taskmgr.exe,quser.exe and ets,most of them crashed |
I know that it's crashing, just wondering if @vps has anything to share before I go down the rabbit hole myself. I thought that he might made it work since he shared the hook. Thanks for sharing the results! |
I did try different approach to make that hook work,but no luck |
would you add local user hidden from net.exe,net1.exe and lusrmgr.msc in the future?
The text was updated successfully, but these errors were encountered: