Skip to content

Fix bugs #4

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions ContainerCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ BOOL RunExecutableInContainer(CHAR *executable_path)
break;
}

InitializeProcThreadAttributeList(NULL, 1, NULL, &attribute_size);
InitializeProcThreadAttributeList(NULL, 2, NULL, &attribute_size);
startup_info.lpAttributeList = (LPPROC_THREAD_ATTRIBUTE_LIST)malloc(attribute_size);

if(!InitializeProcThreadAttributeList(startup_info.lpAttributeList, 1, NULL, &attribute_size))
if(!InitializeProcThreadAttributeList(startup_info.lpAttributeList, 2, NULL, &attribute_size))
{
printf("InitializeProcThreadAttributeList() failed, last error: %d", GetLastError());
break;
Expand All @@ -98,7 +98,17 @@ BOOL RunExecutableInContainer(CHAR *executable_path)
break;
}

if(!CreateProcessA(executable_path, NULL, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL,
#define PROC_THREAD_ATTRIBUTE_ALL_APPLICATION_PACKAGES_POLICY \
ProcThreadAttributeValue (ProcThreadAttributeAllApplicationPackagesPolicy, FALSE, TRUE, FALSE)

DWORD all_applications_package_policy = 0x01;
if (!UpdateProcThreadAttribute(startup_info.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_ALL_APPLICATION_PACKAGES_POLICY, &all_applications_package_policy,
sizeof(all_applications_package_policy), NULL, NULL)) {
printf("UpdateProcThreadAttribute() (2) failed, last error: %d", GetLastError());
break;
}

if(!CreateProcessA(executable_path, NULL, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL,
(LPSTARTUPINFOA)&startup_info, &process_info))
{
printf("Failed to create process %s, last error: %d\n", executable_path, GetLastError());
Expand Down Expand Up @@ -243,11 +253,8 @@ BOOL GrantNamedObjectAccess(PSID appcontainer_sid, CHAR *object_name, SE_OBJECT_

} while (FALSE);

if(original_acl)
LocalFree(original_acl);

if(new_acl)
LocalFree(new_acl);

return success;
}
}
10 changes: 5 additions & 5 deletions ContainerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,20 @@ void FilesystemTest()
void ProcessListTest()
{
printf("[+] Running process list testing...\n");
tagPROCESSENTRY32W process_entry;
PROCESSENTRY32W process_entry;
HANDLE snapshot;

process_entry.dwSize = sizeof(process_entry);

snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(snapshot)
{
if(Process32First(snapshot, &process_entry))
if(Process32First(snapshot, (LPPROCESSENTRY32)&process_entry))
{
do
{
printf("Found process: %ws\n", process_entry.szExeFile);
} while (Process32Next(snapshot, &process_entry));
printf("Found process: %s\n", process_entry.szExeFile);
} while (Process32Next(snapshot, (LPPROCESSENTRY32)&process_entry));
}
CloseHandle(snapshot);
}else{
Expand Down Expand Up @@ -183,4 +183,4 @@ void CreateFileTest(CHAR *file_path)
printf("Opening of file %s failed but was not blocked\n", file_path);
}
}
}
}