Module 3 Flashcards

(60 cards)

1
Q

What is the primary purpose of building custom payloads using raw shellcode instead of using ready-to-run payloads from C2 frameworks?

A

It is beneficial in situations like initial access where custom payloads may evade defenses more effectively.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the Portable Executable (PE) file format?

A

It’s a file format for executables and DLLs that holds information necessary for the operating system to load a program into memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the fixed size of the DOS header (IMAGE_DOS_HEADER) at the start of every PE file?

A

The DOS header is a fixed 64-byte structure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the constant 2-byte value found in the ‘e_magic’ member of the DOS header, and what does it represent in ASCII?

A

The value is ‘4D 5A’, which represents ‘MZ’ in ASCII, serving as a signature for the PE file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which member of the DOS header contains an offset to the PE signature at the start of the NT headers?

A

The ‘e_lfanew’ member.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

At what fixed offset from the start of a PE file is the ‘e_lfanew’ member located?

A

It is always located at an offset of ‘3C’ (60 in decimal).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the primary function of the DOS stub in a modern Windows environment?

A

The modern Windows loader uses the offset in ‘e_lfanew’ to skip over the stub and go directly to the NT headers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The constant 4-byte value ‘50 45 00 00’ (‘PE\0\0’) at the beginning of the NT headers is known as the _____.

A

PE signature

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In the PE file header (IMAGE_FILE_HEADER), what does the ‘Machine’ member indicate?

A

It indicates the CPU architecture the PE file is compiled for.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What information is held in the ‘NumberOfSections’ member of the PE file header?

A

It holds the total number of sections the PE file has.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which member of the Optional Header determines if a PE image is 32-bit (PE32) or 64-bit (PE32+)?

A

The ‘Magic’ member.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does the ‘AddressOfEntryPoint’ member in the Optional Header specify?

A

It specifies the address of the PE’s entry point relative to the image base when loaded into memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the ‘ImageBase’ in the Optional Header?

A

It is the preferred base address for the PE image to be loaded into memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The _____ contains information needed by the Windows loader, such as details of the DLLs that a PE requires to function.

A

import directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which PE section typically contains the executable code of the program?

A

The ‘.text’ section.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which PE section contains resources used by a program, such as icons and images?

A

The ‘.rsrc’ section.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

In a section header, what is the difference between ‘VirtualSize’ and ‘SizeOfRawData’?

A

‘VirtualSize’ is the total size of the section in memory, while ‘SizeOfRawData’ is its size on disk, which may differ due to padding.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What do the ‘Characteristics’ in a PE section header describe?

A

They are a set of flags that describe attributes of the section, including its final memory permissions (e.g., R, RW, RX).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Distinguish between a ‘program’ and a ‘process’.

A

A program is a compiled PE file, while a process is a container that holds the resources for a running instance of that program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Which Windows API is the simplest way to create a new process that has the same access token as the caller?

A

CreateProcessW.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Ultimately, process creation APIs like CreateProcessW and CreateProcessAsUserW call into which kernel function?

A

NtCreateUserProcess.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is a thread in the context of the Windows OS?

A

A thread is an object that Windows schedules for execution within a process, holding the CPU state and a call stack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Which API creates a new thread within the calling process’s address space?

A

CreateThread.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

To create a new thread in a different process, which API would you use?

A

CreateRemoteThread.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
How does the Windows memory manager handle a process's virtual memory?
It transparently maps a process's virtual memory to physical memory and may page data to disk when needed.
26
The 'Virtual APIs' like VirtualAlloc always allocate memory that is rounded up to the nearest complete _____.
page
27
For managing memory allocations that are smaller than a page, which family of APIs should be used?
The Heap APIs, such as HeapAlloc.
28
What is the purpose of memory-mapping APIs like CreateFileMappingA and MapViewOfFile?
They are designed to map files into memory from disk and can be used to share memory mappings across processes.
29
What is a primary access token in the context of a Windows process?
It is an object assigned to a process at creation that describes the security context of the user who started it.
30
What specifies who has what access to a securable object like a file or process in Windows?
The object's discretionary access control list (DACL).
31
What does a 'privilege' grant to a security principal in Windows?
It grants the right to perform a specific system-related operation, like changing the time zone or shutting down the computer.
32
Which API must a process use to enable a privilege within its access token before performing a privileged operation?
AdjustTokenPrivileges.
33
Which powerful privilege allows a user to obtain read/write handles to any process, even those owned by other users or SYSTEM?
SeDebugPrivilege.
34
The _____ privilege allows a user to create arbitrary access tokens to impersonate any user with any privilege.
SeCreateTokenPrivilege
35
What is the difference between 'graceful' and 'ungraceful' process termination?
Graceful termination (ExitProcess) allows loaded modules to clean up, while ungraceful termination (TerminateProcess) ends threads abruptly.
36
Which API can only be used by a program to terminate itself?
ExitProcess.
37
According to MITRE, process injection is a technique for _____ and _____.
privilege escalation, defense evasion
38
What are the three high-level steps required for most process injection techniques?
Allocate memory in the process, copy shellcode into it, and execute the shellcode.
39
The 'classic' remote injection technique uses which three key Win32 APIs in sequence?
VirtualAllocEx, WriteProcessMemory, and CreateRemoteThread.
40
To perform classic injection on a remote process, what must be obtained first using its Process ID (PID)?
A handle to the target process, typically using the OpenProcess API.
41
What is the core idea behind the 'thread hijacking' evasion technique?
Create a new thread in a suspended state pointing to a benign location, then later change its context to point to the shellcode before resuming it.
42
In thread hijacking, which flag is passed to CreateThread to start the new thread in a non-executing state?
CREATE_SUSPENDED.
43
After creating a suspended thread, which two APIs are used to modify its execution context to point to the shellcode?
GetThreadContext and SetThreadContext.
44
How is shellcode executed using the Asynchronous Procedure Call (APC) injection technique?
An APC pointing to the shellcode is queued on an existing thread, which executes it when the thread enters an 'alertable' state.
45
To queue an APC on a thread in another process, you must first obtain a thread ID by performing a _____.
thread walk
46
Which API is used to queue an Asynchronous Procedure Call on a target thread?
QueueUserAPC.
47
What is the primary risk or downside of the standard APC injection method?
There is no guarantee that the selected thread will ever enter an alertable state, meaning the shellcode may not run.
48
How does the 'early bird' technique overcome the main downside of standard APC injection?
It spawns a new process in a suspended state, queues the APC on its primary thread, and then resumes it, guaranteeing the APC will trigger.
49
What is the fundamental concept of process hollowing?
It involves starting a process in a suspended state, unmapping its original PE from memory, and mapping a new PE in its place.
50
In the simplified process hollowing example, instead of unmapping the PE, what is done to execute the shellcode?
The PE's entry point in memory is overwritten with the shellcode.
51
To find a process's image base address for hollowing, the native API _____ is used to get the PEB address.
NtQueryInformationProcess
52
After getting the image base address from the PEB, the _____ value from the DOS header is used to locate the NT header.
e_lfanew
53
Once the NT header is located in memory, the RVA of the PE's entry point is found in which specific field?
OptionalHeader->AddressOfEntryPoint.
54
What does Platform Invoke (P/Invoke) allow a C# developer to do?
It allows managed C# code to access functions in unmanaged libraries, such as the Win32 APIs in kernel32.dll.
55
In C# P/Invoke, functions from unmanaged libraries are declared with the `extern` keyword and the _____ attribute.
DllImport
56
Setting `SetLastError = true` in the `DllImport` attribute allows you to retrieve the last API error code using which .NET class and method?
The `Marshal.GetLastWin32Error()` method.
57
What is the purpose of using the `DefaultDllImportSearchPaths` attribute in a P/Invoke declaration?
It protects against DLL hijacking by forcing the application to look for the DLL in a secure location like System32.
58
Why must a developer manually define structures like `PROCESS_ACCESS_RIGHTS` when using P/Invoke?
Because managed C# code does not have access to the Windows headers (like Windows.h) where these types are originally defined.
59
In P/Invoke, what is the process of converting managed types like C# strings into the correct format for an unmanaged API called?
Marshalling.
60
To correctly marshal a C# string for a WinAPI function that expects a Unicode string (a 'W' variant), which attribute should be added to the `DllImport` declaration?
CharSet = CharSet.Unicode.