Giter VIP home page Giter VIP logo

wsl-sudo's Introduction

Sudo for WSL

What is this?

This tool allows you to run applications in windows elevated user mode from a non-elevated wsl shell.

It has full terminal support, so you can run interactive applications like vim or a shell through it.

Requirements

wsl-sudo requires Python >= 3.5. It should be preinstalled on any modern linux distribution.

How to setup

Clone this repository or just download wsl-sudo.py.

You can test if the script works by running python3 wsl-sudo.py net.exe sessions and comparing the output with just running net.exe sessions.

For convenience, you might want to add an alias to this script, eg:

alias wudo="python3 /path-to-wsl-sudo/wsl-sudo.py"

Usage examples

$ wudo vim /mnt/c/Windows/System32/Drivers/etc/hosts
$ wudo cp foo.txt /mnt/c/Program Files/
$ wudo cmd  # open elevated standard command prompt
$ wudo bash  # open elevated shell
$ wudo regedit

Note that it will open an UAC prompt every time it is run, so if you want to run multiple commands in succession, you should open an elevated shell (see example above) and run your commands from there

How it works

When run, wsl-sudo uses powershell to run a second process in elevated mode. For security reasons, Windows prevents most kinds of communication between elevated and non-elevated processes. So, the elevated process connects to the non-elevated process via TCP for communication. To prevent other processes from interfering with this connection, it's secured with a random password.

The elevated process will then run the given command and exchange input and output with the original process via the TCP connection. The command is run in a pty, so it acts as if running in an ordinary terminal. Therefore, you can run interactive console-based programs like vim or less.

Related Projects

wsl-sudo's People

Contributors

chronial avatar nu774 avatar weinhold avatar dtmdl avatar

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.