<jupyter_start><jupyter_text>T1055.012 - Process Injection: Process HollowingAdversaries may inject malicious code into suspended and hollowed processes in order to evade process-based defenses. Process hollowing is a method of executing arbitrary code in the address space of a separate live process.  Process hollowing is commonly performed by creating a process in a suspended state then unmapping/hollowing its memory, which can then be replaced with malicious code. A victim process can be created with native Windows API calls such as CreateProcess, which includes a flag to suspend the processes primary thread. At this point the process can be unmapped using APIs calls such as ZwUnmapViewOfSection or NtUnmapViewOfSection  before being written to, realigned to the injected code, and resumed via VirtualAllocEx, WriteProcessMemory, SetThreadContext, then ResumeThread respectively.(Citation: Leitch Hollowing)(Citation: Endgame Process Injection July 2017)This is very similar to [Thread Local Storage](https://attack.mitre.org/techniques/T1055/005) but creates a new process rather than targeting an existing process. This behavior will likely not result in elevated privileges since the injected process was spawned from (and thus inherits the security context) of the injecting process. However, execution via process hollowing may also evade detection from security products since the execution is masked under a legitimate process.   Atomic Tests<jupyter_code>#Import the Module before running the tests.
# Checkout Jupyter Notebook at https://github.com/cyb3rbuff/TheAtomicPlaybook to run PS scripts.
Import-Module /Users/0x6c/AtomicRedTeam/atomics/invoke-atomicredteam/Invoke-AtomicRedTeam.psd1 - Force<jupyter_output><empty_output><jupyter_text>Atomic Test 1 - Process Hollowing using PowerShellThis test uses PowerShell to create a Hollow from a PE on disk with explorer as the parent.Credit to FuzzySecurity (https://github.com/FuzzySecurity/PowerShell-Suite/blob/master/Start-Hollow.ps1)**Supported Platforms:** windows Attack Commands: Run with `powershell````powershell. $PathToAtomicsFolder\T1055.012\src\Start-Hollow.ps1$ppid=Get-Process explorer | select -expand idStart-Hollow -Sponsor "C:\Windows\System32\calc.exe" -Hollow "C:\Windows\System32\cmd.exe" -ParentPID $ppid -Verbose```<jupyter_code>Invoke-AtomicTest T1055.012 -TestNumbers 1<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.060960334029227556, 'fraction_numerical': 0.01837160751565762, 'mean_word_length': 5.944927536231884, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '626336', 'license': 'MIT', 'n_tokens_mistral': 675, 'n_tokens_neox': 614, 'n_words': 261, 'path': 'playbook/tactics/privilege-escalation/T1055.012.ipynb', 'repo_name': 'haresudhan/The-AtomicPlaybook', 'size': '2395'}