Git Product home page Git Product logo

windows-dll-hijacking's Introduction

Windows DLL Hijacking

Background

This repo contains all scripts used to find relative path DLL Hijacking candidates on Windows 10 (version 1909), as described in this blog post.

Approach

The approach taken consists of two phases:

  1. The first phase is about identifying which DLLs may be vulnerable to hijacking;
  2. The second phase is about confirming which ones actually do.

Each phase is explained in more detail in the README files of their associated subfolders in this repo.

Used approach, taken from the blog post.

Used approach,taken from the blog post.

Contents

Item Description
1_finding_candidates/ Files for Phase 1, which will result in a CSV file with all possible DLL hijack candidates.
2_compiling_dlls/ Files for Phase 2, which will result in a set of files identifying confirmed DLL hijack candidates.
dll_hijacking_candidates.csv A CSV file with all identified relative path DLL Hijacking candidates on Windows 10 (version 1909).
possible_windows_dll_hijacking.yml Sigma rule identifying DLL loads of files in the list of DLL Hijack candidates from a folder other than their expected locations.
REAMDE.md This file.

windows-dll-hijacking's People

Contributors

wietze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

windows-dll-hijacking's Issues

issue with generate_dlls.py

Hey there Wietze,

having some issue here with the python script used to compile the DLLs via docker. see image below... not sure as to why its doing this. any help would be greatly appreciated! Thanks

image

Problem with run_procmon_scan.ps1

The latest version of procmon does not load the generated PMC filters correctly. Go to archive.org and download an older version of procmon. I am using procmon 3.53 and it works fine.
Thanks wietze

Unable to compile dll files

Hi,

I attempted to test this on my system for learning purposes but for some reason I am not able to build the evil DLL's
As you already are aware the docker image is offline but I attempted to compile one of the files manually.

Any suggestions or clarification why the below will fail?

Compile command:"

$ x86_64-w64-mingw32-gcc -shared -mwindows -o winmm.dll winmm.dll.c winmm.dll.def

Errors:

winmm.dll.c:64:7: error: conflicting types for ‘mmioSeek’; have ‘void *()’
   64 | VOID *mmioSeek(){ generate_fingerprint(__func__); }
      |       ^~~~~~~~
In file included from /usr/share/mingw-w64/include/mmsystem.h:26,
                 from /usr/share/mingw-w64/include/windows.h:86,
                 from winmm.dll.c:1:
/usr/share/mingw-w64/include/mmiscapi.h:222:22: note: previous declaration of ‘mmioSeek’ with type ‘LONG(struct HMMIO__ *, LONG,  int)’ {aka ‘long int(struct HMMIO__ *, long int,  int)’}
  222 | WINMMAPI LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, int iOrigin);
      |                      ^~~~~~~~
winmm.dll.c:65:7: error: conflicting types for ‘midiInGetID’; have ‘void *()’
   65 | VOID *midiInGetID(){ generate_fingerprint(__func__); }
      |       ^~~~~~~~~~~
In file included from /usr/share/mingw-w64/include/mmsystem.h:29:
/usr/share/mingw-w64/include/mmeapi.h:609:26: note: previous declaration of ‘midiInGetID’ with type ‘MMRESULT(struct HMIDIIN__ *, UINT *)’ {aka ‘unsigned int(struct HMIDIIN__ *, unsigned int *)’}
  609 | WINMMAPI MMRESULT WINAPI midiInGetID(HMIDIIN hmi, LPUINT puDeviceID);
      |                          ^~~~~~~~~~~
winmm.dll.c:66:7: error: conflicting types for ‘mciFreeCommandResource’; have ‘void *()’
   66 | VOID *mciFreeCommandResource(){ generate_fingerprint(__func__); }
      |       ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/share/mingw-w64/include/mmsystem.h:23:
/usr/share/mingw-w64/include/mciapi.h:868:18: note: previous declaration of ‘mciFreeCommandResource’ with type ‘WINBOOL(UINT)’ {aka ‘int(unsigned int)’}
  868 | WINBOOL APIENTRY mciFreeCommandResource(UINT wTable);
      |                  ^~~~~~~~~~~~~~~~~~~~~~
winmm.dll.c:67:7: error: conflicting types for ‘midiInGetErrorTextW’; have ‘void *()’
   67 | VOID *midiInGetErrorTextW(){ generate_fingerprint(__func__); }
      |       ^~~~~~~~~~~~~~~~~~~
/usr/share/mingw-w64/include/mmeapi.h:598:26: note: previous declaration of ‘midiInGetErrorTextW’ with type ‘MMRESULT(MMRESULT,  WCHAR *, UINT)’ {aka ‘unsigned int(unsigned int,  short unsigned int *, unsigned int)’}
  598 | WINMMAPI MMRESULT WINAPI midiInGetErrorTextW(MMRESULT mmrError, LPWSTR pszText, UINT cchText);

Filtering out SysWOW64

Many thanks for these resources! In the SIGMA rule possible_windows_dll_hijacking.yml this path should/could be filtered out: C:\Windows\SysWOW64\

That is:

    filter:
        EventID: 7
        ImageLoaded:
            - "C:\\Windows\\WinSxS\\*"
            - "C:\\Windows\\System32\\*"
            - "C:\\Windows\\SysWOW64\\*"

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.