• Stars
    star
    137
  • Rank 266,121 (Top 6 %)
  • Language
    Nim
  • Created over 2 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tool for converting SysWhispers3 syscalls for use with Nim projects
             %              ..%%%%%#               %/.                  
           /%%%%%,.%%%%%%%%%%%%%%%%%%%%%%%%%%%%.%%%%%%                  
       . #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%.               
  %%*.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ,%%         
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%.         
    #%%%%%%%%%%%%%%.                         %%%%%%%%%%%%%%%%           
      %%%%%%%(                                     %%%%%%%%%            
    &   %%#                                           .%%  ..           
     &&.                          .                     . #&            
      &&&&.               . %&&&&&&&&.                 &&&&             
       &&&&&&&.. .   . (&&&&&&&&&&&&&&&&&%. .     .&&&&&&&              
       .%&&&&&&&&&&&&&&&&&&&&& ____  &&&&&&&&&&&&&&&&&&&&& 
         #&&&&&&&&&&&&&&&&&&& |___ \  &&&&&&&&&&&&&&&&&&&
           ,&&&&&&&&&&&&&&&&&   __) | &&&&&&&&&&&&&&&&&
               &&&&&&&&&&&&&&  |__ <  &&&&&&&&&&&&&&
                   &&&&&&&&&&  ___) | &&&&&&&&&&
                          %&& |____/  &&.       
                        NimlineWhispers3
                    Editor: @klezVirus 2022
                    Original: @ajpc500 2021

NimlineWhispers3

As with the original NimlineWhispers2, this project parses the SysWhispers header file output to include function return types and arguments in the outputted inline assembly. Everything is then output into a single Nim file including an emit block with the SysWhispers3 methods, plus the defined functions.

NOTE: NimlineWhispers 1 can be found here. NOTE: NimlineWhispers 2 can be found here.

How do I set this up?

  • Clone this repository including the SysWhispers3 sub module.
    • git clone --recurse-submodules https://github.com/klezVirus/NimlineWhispers3.git
  • Update which functions you required in functions.txt.
  • Run python3 NimlineWhispers3.py (additional flags listed below) to generate the inline assembly (syscalls.nim) file - example in the repo.
  • Add include syscalls to your Nim project.

An example of integrating NimlineWhispers[2-3] output with your project can be seen in this repo.

Randomised Function Names (same functionality as NW1)

To evade detection based on the presence of function names in our Nim executables (as outlined in @ShitSecure's blog here), NimlineWhispers2 can be run with a --randomise flag, as follows:

python3 .\NimlineWhispers2.py --randomise --nobanner
[i] Function filter file "functions.txt" contains 6 functions.

[i] Using SysWhispers2 to generate asm stubs...
Complete! Files written to:
        nimlinewhispers.h
        nimlinewhispers.c
        nimlinewhispersstubs.asm

[i] Found return types for 6 functions.

[i] Producing randomised function mapping...
        NtResumeThread -> vWhUCQWffAEdMboE
        NtAllocateVirtualMemory -> SIitcDuyPGMirHPr
        NtClose -> uWZzTmdnlNmvteiL
        NtCreateThreadEx -> PDoWbNOwYbDDAcmW
        NtOpenProcess -> vWfwKlChxKZOutiX
        NtWriteVirtualMemory -> wItyVDPJWcFUqTNK

[+] Success! Outputted to syscalls.nim

For ease of integration, the mapping shown in the command-line is added as a comment in the outputted syscalls.nim file (just above the functions and below the SW2 methods). As below (including the first function to demonstrate the output):

...

# NtResumeThread -> vWhUCQWffAEdMboE
# NtAllocateVirtualMemory -> SIitcDuyPGMirHPr
# NtClose -> uWZzTmdnlNmvteiL
# NtCreateThreadEx -> PDoWbNOwYbDDAcmW
# NtOpenProcess -> vWfwKlChxKZOutiX
# NtWriteVirtualMemory -> wItyVDPJWcFUqTNK

proc vWhUCQWffAEdMboE*(ThreadHandle: HANDLE, PreviousSuspendCount: PULONG): NTSTATUS {.asmNoStackFrame.} =
    asm """
	mov [rsp +8], rcx 
...

Notably your function definitions such as the below will need to be updated with the randomised names too.

EXTERN_C NTSTATUS NtOpenProcess(
	OUT PHANDLE ProcessHandle,
	IN ACCESS_MASK DesiredAccess,
	IN POBJECT_ATTRIBUTES ObjectAttributes,
	IN PCLIENT_ID ClientId OPTIONAL);

Should become:

EXTERN_C NTSTATUS sjGfpzWwEqIMryMW(
	OUT PHANDLE ProcessHandle,
	IN ACCESS_MASK DesiredAccess,
	IN POBJECT_ATTRIBUTES ObjectAttributes,
	IN PCLIENT_ID ClientId OPTIONAL);

syscalls_rand.nim is included as an example output of this randomisation function.

Instructing SysWhispers3

To modify the behaviour of SysWhispers3, pass the arguments to the subparser sw in NimlineWhispers3:

usage: NimlineWhispers3.py sw [-h] [-a {x86,x64,all}] [-c {msvc,mingw,all}] [-m {embedded,egg_hunter,jumper,jumper_randomized}] [--int2eh] [--wow64] [-v] [--sw-debug]
                                                                                                                                                                      
optional arguments:                                                                                                                                                   
  -h, --help            show this help message and exit                                                                                                               
  -a {x86,x64,all}, --arch {x86,x64,all}                                                                                                                              
                        Architecture                                                                                                                                  
  -c {msvc,mingw,all}, --compiler {msvc,mingw,all}                                                                                                                    
                        Compiler                                                                                                                                      
  -m {embedded,egg_hunter,jumper,jumper_randomized}, --method {embedded,egg_hunter,jumper,jumper_randomized}                                                          
                        Syscall recovery method
  --int2eh              Use the old `int 2eh` instruction in place of `syscall`
  --wow64               Add support for WoW64, to run x86 on x64
  -v, --verbose         Enable debug output
  --sw-debug            Enable syscall debug (insert software breakpoint)

So, to use the "jumper" method, as an example, just use the following command line:

python NimlineWhispers3.py sw -m jumper

Limitations

  • Egg insertion is not yet fully supported (issue with bytes definition)
  • 32-bits is not yet tested, and may cause issues

Credits

More Repositories

1

inceptor

Template-Driven AV/EDR Evasion Framework
Assembly
1,561
star
2

SysWhispers3

SysWhispers on Steroids - AV/EDR evasion via direct system calls.
Python
1,256
star
3

CVE-2021-40444

CVE-2021-40444 - Fully Weaponized Microsoft Office Word RCE Exploit
HTML
795
star
4

CheeseTools

Self-developed tools for Lateral Movement/Code Execution
C#
683
star
5

SilentMoonwalk

PoC Implementation of a fully dynamic call stack spoofer
C++
665
star
6

chameleon

PowerShell Script Obfuscator
Python
485
star
7

vortex

VPN Overall Reconnaissance, Testing, Enumeration and eXploitation Toolkit
Python
419
star
8

CandyPotato

Pure C++, weaponized, fully automated implementation of RottenPotatoNG
C++
298
star
9

DriverJack

Hijacking valid driver services to load arbitrary (signed) drivers abusing native symbolic links and NT paths
C++
246
star
10

SharpSelfDelete

C# implementation of the research by @jonaslyk and the drafted PoC from @LloydLabs
C#
147
star
11

RpcProxyInvoke

Simple POC library to execute arbitrary calls proxying them via NdrServerCall2 or similar
C++
100
star
12

klezVirus.github.io

CyberSec Blog
JavaScript
96
star
13

SharpLdapRelayScan

C# Port of LdapRelayScan
C#
77
star
14

koppeling-p

Adaptive DLL hijacking / dynamic export forwarding - EAT preserve
Python
66
star
15

DCKFinder

Dangling COM Keys Finder
C++
14
star
16

deser-node

NodeJS Deserialization Payload Generator
JavaScript
9
star
17

codegrepper

Pure python, self-contained, silly implementation of a SAST tool
Python
8
star
18

mapt-run

Simple script to setup a local hosted network for Mobile Application Penetration Testing
Shell
8
star
19

faceless

Faceless - Simple Tool for Text-File Anonymization
Python
7
star
20

msf-revhttp-gen

Little utility to facilitate Metasploit Reverse HTTP Payloads
Shell
7
star
21

nmap-report

A simple tool that can be use to extract usful information from a nmap scan
Shell
7
star
22

CryptoCheck

NIST-CAVS Extended - Encryption Auto Testing Toolkit
Python
4
star
23

deser-py

Python Deserialization Payload Generator
Python
4
star
24

deser-ruby

Ruby Deserialization Payload Generator
Ruby
4
star
25

nx_reporter

Rapid7 Nexpose template-based report generator
Python
4
star
26

muts-opt-encoder

Independent implementation of the optimized SUB-Encoder
Python
4
star
27

klezVirus

Temporary unavailable...
3
star
28

php-ipfinder

A simple tool to enumerate various info on a set of IP addresses
PHP
2
star
29

cves

Public Advisories Redirector
1
star
30

cors-security-remove

JavaScript
1
star
31

Posts

Offensive Security Certifications Reviews
1
star
32

oldrivrs

some old drivers and misc crap from a while ago
C
1
star