-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Readme.md. Added support for CMD commands
- Loading branch information
Gerardo Grignoli
committed
Nov 7, 2019
1 parent
8c4bc66
commit 9c23bfb
Showing
7 changed files
with
63 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace gsudo | ||
{ | ||
class CommandInterceptor | ||
{ | ||
static readonly HashSet<string> CMD_COMMANDS = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "ASSOC", "ATTRIB", "BREAK", "BCDEDIT", "CACLS", "CALL", "CD", "CHCP", "CHDIR", "CHKDSK", "CHKNTFS", "CLS", "CMD", "COLOR", "COMP", "COMPACT", "CONVERT", "COPY", "DATE", "DEL", "DIR", "DISKPART", "DOSKEY", "DRIVERQUERY", "ECHO", "ENDLOCAL", "ERASE", "EXIT", "FC", "FIND", "FINDSTR", "FOR", "FORMAT", "FSUTIL", "FTYPE", "GOTO", "GPRESULT", "GRAFTABL", "HELP", "ICACLS", "IF", "LABEL", "MD", "MKDIR", "MKLINK", "MODE", "MORE", "MOVE", "OPENFILES", "PATH", "PAUSE", "POPD", "PRINT", "PROMPT", "PUSHD", "RD", "RECOVER", "REM", "REN", "RENAME", "REPLACE", "RMDIR", "ROBOCOPY", "SET", "SETLOCAL", "SC", "SCHTASKS", "SHIFT", "SHUTDOWN", "SORT", "START", "SUBST", "SYSTEMINFO", "TASKLIST", "TASKKILL", "TIME", "TITLE", "TREE", "TYPE", "VER", "VERIFY", "VOL", "XCOPY", "WMIC" }; | ||
internal string[] AugmentCommand(string[] args) | ||
{ | ||
if (args.Length == 0) return new string[] { Environment.GetEnvironmentVariable("COMSPEC"), "/k" }; | ||
|
||
if (CMD_COMMANDS.Contains(args[0])) | ||
return new string[] | ||
{ Environment.GetEnvironmentVariable("COMSPEC"), "/c" } | ||
.Concat(args).ToArray(); | ||
|
||
return args; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# gsudo - a sudo for Windows | ||
|
||
gsudo is a `sudo` for Windows that tries to bring a similar user-experience as *nix sudo. | ||
|
||
When you call gsudo for the first time, it launches itself elevated in `service mode`. This will open the Windows UAC pop-up. The requested command is then ran by the elevated service and streamed to the user-level console. The service stays running for 1 minute in case you need to elevate again, and then shutdowns. Calls to gsudo before such time-out, will not show the UAC pop-up. | ||
|
||
```gsudo``` | ||
Opens an elevated CMD in the current console. | ||
|
||
```gsudo [command] [arguments]``` | ||
Executes the specified command, elevated, and returns. | ||
|
||
![gsudo demo](demo.gif) | ||
|
||
## Features | ||
|
||
- Elevated commands are shown in the user-level console, as `*nix sudo` does, instead of opening the command in a new window. | ||
- Does not shows the UAC pop-up every time. | ||
- Suport for CMD commands as `*nix sudo` does, like `gsudo copy SomeOrigin SomeDestination` instead of `gsudo cmd /c copy SomeOrigin SomeDestination` | ||
|
||
# Known issues | ||
|
||
- This project was made in a few hours. It is more of a Proof of concept at this point. Logging, argument parsing, configurability, are in the backlog. | ||
- Windows legacy Console is very limited, which explains some of the issues, and `gsudo` still does not support ConPTY. | ||
- When you spawn an elevated cmd, the `<TAB>` key auto complete doesn't work as expected. | ||
- Elevating git-bash does not work. But Powershell and Cmd does. Under investigation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters