Code Monkey home page Code Monkey logo

cygwin-sudo's Introduction

cygwin-sudo 是一个以管理员权限运行程序的工具。它需要以管理员权限启动一个 sudo-server,然后在以普通权限运行的 shell 中即可使用 sudo 提权。

用法

  1. 编译
  • make
  • cp sudo-server.exe /usr/local/bin/
  • cp sudo.exe /usr/local/bin/
  1. 开机自动运行
  • 打开“任务计划” (Task Scheduler)
  • 新建任务
  • 在“常规”选项卡勾选“使用最高权限运行”
  • 在“触发器”选项卡添加“登录时触发”
  • 在“操作”选项卡添加“启动程序”,填写 sudo-server.exe 的路径
  1. 使用:在 cygwin 中输入 sudo command 即可以管理员权限执行此命令,直接输入 sudo 即可进入管理员权限的 shell。

技术原理

首先尝试的是 ShellExecute WinAPI(在uac.cpp中),倒是能弹出UAC对话框,不过只能用Windows的默认shell打开新窗口,无法在原cygwin窗口中输出。

目前采用类似 sshd 的方法,sudo-server 监听 12345 端口并以管理员权限运行。

sudo 启动 raw 终端模式,将命令行参数、环境变量、终端参数、窗口大小传给 sudo-server,server forkpty 并对所执行程序的输入输出做转发,这样 sudo 所在的终端看到的就是以管理员权限运行的 pty。

当窗口大小变化时,sudo 截获信号并发给 sudo-server,server 再通知 pty。

cygwin-sudo's People

Contributors

bojieli avatar

Watchers

 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.