Code Monkey home page Code Monkey logo

hunt-weird-syscalls's Introduction

Hunt-Weird-Syscalls

This is a ETW based POC to monitor for abnormal syscalls.

For now, the syscalls NtOpenThread and NtSetContextThread are monitored to identify IOCs indicating both direct and indirect syscalls.

Description

This project uses ETW, more precisely kernel based ETW providers, to monitor for IOCs.
ETW providers sitting in the kernel can effectively be leveraged, as the calltraces of emitted events contain the usermode address from where the syscall was conducted.

This allows monitoring IOCs indicating direct and indirect syscalls, a technique often leveraged by threat actors:

1: A syscall was conducted from an untrusted module (=direct syscall)
2: The used syscall stub in ntdll does not match the conducted syscall (=indirect syscall)

This project uses the Provider: Microsoft-Windows-Kernel-Audit-API-Calls to monitor for OpenThread and SetContextThread events triggered by the syscalls NtSetContextThread or NtOpenThread respectively.
Calltraces are enabled, using the flag EVENT_ENABLE_PROPERTY_STACK_TRACE.

This is a POC, and only monitors two specific syscalls. It is of course possible to use other kernel based providers to enhance telemetry.

Tests

This project contains two sample programs using direct and indirect syscalls created using the amazing SysWhispers3. They were generated as follows:

python3 syswhispers.py -a x64 -m jumper_randomized --functions NtSetContextThread
python3 syswhispers.py -a x64 -m embedded --functions NtSetContextThread

Upon execution, abnormal syscalls should be identified:

Identification of Abnormal Syscalls

Tested on 10.0.19044.

Credits

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.