Giter VIP home page Giter VIP logo

wsudo's Introduction

wsudo: Proof of concept sudo for Windows

โš  Not production ready!

This project is in the very early stages. It may have bugs and security holes. Use at your own risk!

What does it look like?

A terminal. Or two terminals currently. See this short demo.

How to build/run?

Currently the only dependencies are spdlog, fmt, and the Windows SDK. I use vcpkg to install these. The project builds with CMake - I use the Ninja generator but the VS one is probably fine. After making sure your spdlog and fmt work, do:

...\wsudo> mkdir build
...\wsudo> cd build
...\wsudo> cmake -G Ninja ..
...\wsudo> cmake --build .

This will produce two binaries in bin\Debug. To try it, start TokenServer.exe in an admin console; then in a separate unelevated console run wsudo.exe <program> <args>. Currently you need to provide the full path to the program. It will ask for your password, but this is not yet implemented so the password is always password. To see the difference in elevation status, try wsudo.exe C:\Windows\System32\whoami.exe /groups and look for the Mandatory Label section.

What makes this one different?

It uses a token server, which can be run as a system service, to remotely reassign the primary token for an interactive process. A process you create with the wsudo.exe command inherits the environment as if you just called the target command itself, but it starts elevated with no UAC involvement.

How?

There are three ways to create an elevated process:

  1. Request elevation with UAC.
  2. Be an executable signed by the Windows Publisher.
  3. Be an elevated process.

The system will automatically start services elevated, but they have their own environment, which is not very useful for command line purposes. However, there's a trick - you can start a regular restricted process suspended in your own session and notify the service, which uses NtSetInformationProcess to change the remote process token to an elevated one before it starts.

I originally created a remote process in the service, but setting up the environment is tricky and requires digging through undocumented parts of the PEB. With this method, the system sets up all the inheritance correctly, and we only need one undocumented call to elevate the process.

It may be possible to achieve this without any undocumented APIs by creating the process in the server and using PROC_THREAD_ATTRIBUTE_PARENT_PROCESS.

What features are missing?

Most of them. Here are the big ones:

  • Create a token for the client user instead of just duplicating the server's token.
  • Cache the users' tokens for a while after a successful authentication (note: should be per-session).
  • Implement Windows service functionality for the server.
  • Create some type of "sudoers" config file or registry key and enforce permissions.
  • Improve the client's command line handling - shouldn't have to type the full path to an exe.
  • Improve error handling and write tests.

Other ideas

  • Options to set user and privileges.
  • PowerShell wrapper cmdlets.
  • Integration with WSL sudo.
  • COM elevation.
  • Session selection.

Additional resources

wsudo's People

Contributors

parkovski 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

wsudo's Issues

Implement sessions

Like sudo, after authenticating the password shouldn't be required for a while.

  • Sessions should be indexed by the user's SID and session - if LOCALDOMAIN\alice is authenticated in the physical machine session, this should not automatically grant access to her login via remote desktop or ssh (or should it?).
  • Sessions should expire when the machine sleeps.
  • The client should check for an active session before prompting for credentials.

WSL integration

Being able to elevate a WSL session as root and a Windows session with an admin token at the same time would be very convenient.

Configuration (sudoers or registry equivalent)

  • What format should be used? JSON, sudoers, registry, other?
  • Strict permissions need to be enforced here.
  • How should it be edited? Actually allow editing, or just provide client commands (wsudo --config ...)?
  • What overlap is there between sudoers and wsudo config? Which Windows-specific features should be supported?

License

Hi @parkovski.
I've read the readme and it looks trully impresive.
I thought it was impossible to overwrite the token of a another process.
I wonder If I could grab some ideas and incorporate them into gsudo.
The problem is that gsudo is MIT license and wsudo is GPL-3.0.
Could you please authorize me to read your code, transform the token overwritting logic into gsudo (C#) and release under MIT?
I would add your name (is it Parker Snell?) as part of the license file.

Thanks, and great work!

Customize user and privileges

We shouldn't just blindly allow anyone to do this. Giving an administrator their own token is very different from giving them a SYSTEM or TrustedInstaller token.

Re-ACL child processes

Currently they're accessible by anyone. When started through UAC, the owner is the Administrators group.

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.