N3agu / Akame-Loader

Akame is an open-source, UD shellcode loader written in C++17.
MIT License
19 stars 6 forks source link
aes-encryption cpp cryptography fud shellcode shellcode-loader

Akame Loader

An open source, UD (3/71) shellcode loader written in C++

Details

Icon: https://icon-icons.com/icon/Halloween-eye/109170 Name Details
Name Akame Loader
Author N3agu
Language C++
Platform Windows
Version 1.1
License MIT
Libraries kernel32, advapi32, crypt32
Encryption AES256
Build Release

! If you change the encryption method and want to keep your executable UD for a longer period of time, don't use VirusTotal / AntiScan.me / any other site that distributes to security vendors.

How does it work?

  1. Uses WINAPI WinMain so it doesn't popup any console window
  2. Checks the current hard disk, if the size is under 100GB it closes itself
  3. Sleeps for 10000ms (10s)
  4. Checks if any tickcount-related function was manipulated by a sandbox (by checking the hashes and comparing the time slept with the time elapsed on the machine), if something seems wrong, it closes itself
  5. Stores the IV, the encryption Key, and the encrypted payload as buffers
  6. Allocates a memory buffer for the payload
  7. Decrypts the payload (AES256) and closes itself if something doesn't work correctly
  8. Copies the payload to a new buffer
  9. Marks the memory space as executable (This is not done during the first allocation because it's suspicious to create a memory space which is ReadWriteExecute)
  10. Executes the payload

How to build?

1. Generate shellcode

2. Encrypt your shellcode with encrypt.exe

3. Copy the output and paste it under the "payload" comment

4. Change the resources

5. Build the project

6. Add a certificate to your executable
! Change "Akame.exe" to your executable and AkameCert/AkameCA to whatever you want

7. Listen for incomming connections

Video POC

Platform: Windows 10 x64
Antivirus: Windows Defender 24/10/2022

! 720p because I can't upload video files bigger than 10MB on github
! Blackscreens in the video caused by UAC

VirusTotal Scan (3/71 security vendors and no sandboxes on 24/10/2022)

I uploaded the loader to Virus Total because I don't want this to be used for malicious purposes!
The shellcode used was generated with metasploit (payload: windows/x64/meterpreter/reverse_tcp) and encrypted by \resources\encrypt.exe.
The loader was build with VS22 and signed with a sha1 certificate

File Scan
File Details

Link: https://www.virustotal.com/gui/file/68e6a25457093584a043ed3f721be9bc9b6456edd792cb4e30054e85bdc4119f
! Attention, the reason the loader gets a lot of detections now is because Virus Total distributes samples, this is completely normal. With simple code obfuscation / small changes you can obtain a new, FUD payload, don't be script kiddies / pasters, learn how to code, stay safe!

What should be added to make it better?

! The provided code is a set of parameters used with LLVM's obfuscation passes, here's a list of each parameter and what it does, parameters taken directly from ollvm-17 repository.

After that you only need to compile your solution and you will get a fairly large executable but with various flattening, encryption, substitution applied. Here's what you should get on analyzing the control flow graph with IDA:

Properties

File

Hashes

Table of Imports

- ADVAPI32.dll: 9 functions CryptAcquireContextW, 194
CryptCreateHash, 196
CryptDecrypt, 197
CryptDeriveKey, 198
CryptDestroyHash, 199
CryptDestroyKey, 200
CryptHashData, 217
CryptReleaseContext, 220
CryptSetKeyParam, 222
- KERNEL32.dll: 72 functions CloseHandle, 137
CreateFileW, 206
CreateThread, 245
DeleteCriticalSection, 276
DeviceIoControl, 292
EnterCriticalSection, 312
ExitProcess, 359
FindClose, 382
FindFirstFileExW, 388
FindNextFileW, 405
FlushFileBuffers, 424
FreeEnvironmentStringsW, 435
FreeLibrary, 436
GetACP, 443
GetCommandLineA, 479
GetCommandLineW, 480
GetConsoleMode, 517
GetConsoleOutputCP, 521
GetCPInfo, 458
GetCurrentProcess, 544
GetCurrentProcessId, 545
GetCurrentThreadId, 549
GetEnvironmentStringsW, 577
GetFileType, 600
GetLastError, 618
GetModuleFileNameW, 637
GetModuleHandleExW, 640
GetModuleHandleW, 641
GetOEMCP, 673
GetProcAddress, 696
GetProcessHeap, 702
GetStartupInfoW, 730
GetStdHandle, 732
GetStringTypeW, 737
GetSystemTimeAsFileTime, 755
GetTickCount64, 786
HeapAlloc, 849
HeapFree, 853
HeapReAlloc, 856
HeapSize, 858
InitializeCriticalSectionAndSpinCount, 875
InitializeSListHead, 879
IsDebuggerPresent, 901
IsProcessorFeaturePresent, 908
IsValidCodePage, 914
LCMapStringW, 952
LeaveCriticalSection, 964
LoadLibraryExW, 970
MultiByteToWideChar, 1014
QueryPerformanceCounter, 1106
RaiseException, 1128
RtlCaptureContext, 1237
RtlLookupFunctionEntry, 1244
RtlUnwindEx, 1250
RtlVirtualUnwind, 1251
SetFilePointerEx, 1331
SetLastError, 1345
SetStdHandle, 1371
SetUnhandledExceptionFilter, 1407
Sleep, 1423
TerminateProcess, 1438
TlsAlloc, 1456
TlsFree, 1457
TlsGetValue, 1458
TlsSetValue, 1459
UnhandledExceptionFilter, 1472
VirtualAlloc, 1497
VirtualProtect, 1503
WaitForSingleObject, 1514
WideCharToMultiByte, 1553
WriteConsoleW, 1572
WriteFile, 1573

License

MIT License

Copyright (c) 2024 N3agu

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Disclaimer

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.