Jump to content

Bug in APP launch (environment)


FierceRecon

Recommended Posts

If you are to create a user and start a program (cmd.exe will do), WIHU's environment is not passed to the program.

E.X.

[Environment]
HELLO=BLA

...
[Some section]
command.0 = cmd.exe
description.0 = just a test

if you don't skip user creation (e.g. you create a new user), and you type in set when the cmd window shows up, you won't see the variable HELLO there.

(simple fix - download source and)

Open wihu.c
Find:
LV_EX_ITEM *Parent;
DWORD BlankPasswordUsage = 0;
WIHU_USER *User;

After, add:
LPVOID env = NULL;
Find
while (Env) {
 WCHAR EnvData[MAX_ENVVAL_SHORT_SIZE];
 ExpandEnvironmentStrings(Env->Value, EnvData, MAX_ENVVAL_SHORT_SIZE);
 SetEnvironmentVariable(Env->Key, EnvData);
 Env = Env->Next;
 }
After, Add (MAKE SURE TO ADD BEFORE } else {:
 CreateEnvironmentBlock(&env, NULL, TRUE);
Find
/* Start process in new user account context */
 Result = CreateProcessWithLogonW(User->Name, User->Domain, User->Password, LOGON_WITH_PROFILE, NULL, ExeCmd, 0, NULL, CurDir, &sti, π);

REPLACE WITH:
/* Start process in new user account context */
 Result = CreateProcessWithLogonW(User->Name, User->Domain, User->Password, LOGON_WITH_PROFILE, NULL, ExeCmd, CREATE_UNICODE_ENVIRONMENT, env, CurDir, &sti, π);

Recompile source...

Hope that helps some headaches.

Limitation: Generic environment for the user is not loaded, e.g. %USERNAME% will be that of the user that wihu is being run from (use %ThisUser%)

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...