Giter Club home page Giter Club logo

windows-exploitation's Introduction

Windows exploitation

Types of Bugs

Uninitialized Stack Variable

  • References a local variable or buffer, which wasn’t previously properly initialized.
  • Usually mitigated by compiler warnings/errors, informing about potential security flaws present in the source code.
  • Challenge: how can one control the trash bytes present on the ring-0 stack, from within a ring-3 perspective?
  • How to exploit:
    • Find the kernel stack init address: !thread.
    • Find the offset of our callback from this init address
    • Spray the Kernel Stack with User controlled input from the user mode using NtMapUserPhysicalPages trick.

Null-Pointer Dereference

  • Happens when the value of the pointer is NULL, and is used by the application to point to a valid memory area.
  • How to exploit:
    • Map the NULL page in user space.
    • Place a fake data structure in it which will cause our shell code to be executed.
    • Trigger the dereference bug.

Symbolic links

  • Leverages two fundamental concepts in Windows:
    • object manager symbolic links.
    • NTFS junctions/mount points.
  • Requirements for exploitation:
    • A high privileged process writing to user controlled files or directories: C:\PownMe\Link.ex.
    • Reading permission to the referenced directory C:\Windows\System32\sysprep\ and writing permissions to the directory where the junction will be stored C:\PownMe.
    • directory where the junction will be stored must be empty: C:\PownMe before the reparse point is defined.
  • How to find them:
    • launch process monitor and filter by the process you are targeting.
    • look for CreateFile operations by the SYSTEM process.
    • then check if the target directory has the right access for the everyone group or username.

Payloads

Token Stealing Payload

  • The general algorithm for the token stealing shellcode is:
    • Save the drivers registers so we can restore them later and avoid crashing it.
    • Find the _KPRCB struct by looking in the fs segment register
    • Find the _KTHREAD structure corresponding to the current thread by indexing into_KPRCB.
    • Find the _EPROCESS structure corresponding to the current process by indexing into_KTHREAD.
    • Look for the _EPROCESS structure corresponding to the process with PID=4 (UniqueProcessId = 4) by walking the doubly linked list of all_EPROCESS structures that the_EPROCRESS structure contains a references to, this is the "System" process that always has SID ( Security Identifier) = NT AUTHORITY\SYSTEM SID.
    • Retrieve the address of the Token of that process.
    • Look for the _EPROCESS structure corresponding to the process we want to escalate (our process).
    • Replace the Token of the target process with the Token of the "System" process.
    • Clean up our stack and reset our registers before returning.

Mitigations

SMEP (Supervisor Mode Execution Prevention)

  • Introduced in 2011 in Intel processors based on the Ivy Bridge architecture and enabled by default since Windows 8.0.
  • SMEP restricts executing code that lies in usermode to be executed with Ring-0 privileges, attempts result in a crash. This basically prevents EoP exploits that rely on executing a usermode payload from ever executing it.
  • The SMEP bit is bit 20 of the CR4 register.
  • SMEP's goal is to block kernel exploit which:
    • Prepares a shellcode in user memory
    • Redirects execution to the prepared payload, by exploiting a kernel/driver security flaw.

SMEP Bypass

  • Craft a rop chain to disable SMEP (not possible with win10 vbs)
  • Modifying nt!MmUserProbeAddress
  • Windows Reserve Objects

windows-exploitation's People

Contributors

lordnoteworthy 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

windows-exploitation's Issues

[tag: just a thank you word]

Hello!

some context

I don't know how to tag a issue as (not a issue)

the Thank you word!

Thanks for making this repo! I always open issues saying 'thank you' to repos I find useful, and this repo I have used quite a lot, as well as your other repos! (but of course I cant make a issue all the time saying thank you <- of course not);

I myself know it's kinda difficult to do everything like, check grammar, and update repos, keep them maintained and stuff; and to me it's important (for me) to show my appreciation to people who really make useful repos (repos like this one!)

Your way of writing content is also very readable, no unnecessary parts - or stuff.

So, respect to you!

Why I make this issue

  • Why I make these 'thank you' issues is because of the..

Lack of positive feedback: part in the github-community-guidelines

Users are far more likely to reach out when they have a complaint. If everything works great, they tend to stay silent.

So, to avoid that I make issues like this one ^_^

Anyway, with that said - Please have a great continuing Friday on you!

Wishes from Sweden! Keep up the marvelous work, Really!
//Will.

this issue* can be closed, as it's just a appreciation post;

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.