Documentation
¶
Overview ¶
Package memshell 内存马注入载荷生成。
方案:Tomcat 7-9(javax 命名空间)Filter 型内存马——JSP 注入器 + JDK 动态代理 + 反射注册 StandardContext。全程无需在目标机或本地编译 Java(无需 javac):
- 经既有 WebShell 连接把注入器 JSP 写入 webapp 路径;
- 请求一次注入器(?su=<密码>)完成 Filter 注册(URL 模式 /*);
- 删除注入器 JSP——内存 Filter 仍在,落盘痕迹消失(无文件驻留);
- 此后任意路径 ?pass=<密码>&cmd=<命令> 即执行命令回显,与平台 webshell 连接协议(pass+cmdParam)完全一致,可直接注册为 ws_* 连接。
兼容性:Tomcat 7/8/9 + JDK 7+。Tomcat 10(jakarta.*)不适用。 治理:仅限已获得明确授权的测试场景;注入/清理全量审计。
Index ¶
Constants ¶
const TriggerParam = "su"
TriggerParam 注入器触发参数(首请求携带 ?su=<密码> 完成注册)。
Variables ¶
This section is empty.
Functions ¶
func SupportsRemover ¶
SupportsRemover 该类型是否有配套卸载器(当前仅 Tomcat Filter 家族)。
Types ¶
type DeployPlan ¶
type DeployPlan struct {
Session session.Session
Payload Payload
DropPath string
TriggerURL string
ExtraFiles map[string]string // e.g. php .user.ini
Register bool
}
DeployPlan is a pure description of a memory-shell deployment. The host must provide the actual file write, trigger request and cleanup.
type DeployResult ¶
type Deployer ¶
type Deployer interface {
Deploy(ctx context.Context, plan DeployPlan) (*DeployResult, error)
Remove(ctx context.Context, plan DeployPlan) (*DeployResult, error)
}
Deployer is the host boundary for memory-shell deployment/removal. This module ships no default deployer.
type Kind ¶
type Kind string
Kind 内存马类型。
const ( // KindTomcatFilter Tomcat 7-9(javax)Filter 型(动态代理 + 反射注册,免编译)。 KindTomcatFilter Kind = "jsp-tomcat-filter" // KindTomcatFilterJakarta Tomcat 10/11(jakarta 命名空间)Filter 型。 KindTomcatFilterJakarta Kind = "jsp-tomcat-filter-jakarta" // KindTomcatValve Tomcat Valve 型(JSP 内嵌 Valve 子类 + Pipeline 注册)。 KindTomcatValve Kind = "jsp-tomcat-valve" // KindTomcatServlet Tomcat Servlet 型(Servlet 接口动态代理 + StandardWrapper 注册)。 KindTomcatServlet Kind = "jsp-tomcat-servlet" // KindSpringController Spring MVC Controller 型(代理 + registerSingleton + registerHandler)。 KindSpringController Kind = "jsp-spring-controller" // KindAspxHttpModule ASP.NET HttpModule 型(HttpApplication.RegisterModule)。 KindAspxHttpModule Kind = "aspx-httpmodule" // KindPhpUserIni PHP 准无文件持久化(payload + .user.ini auto_prepend)。 // 严格说是文件驻留(两枚),但不在 web 可解析入口,适合 PHP 场景长期驻留。 KindPhpUserIni Kind = "php-user-ini" )
type Options ¶
Options 生成参数;FilterName 空则随机(低噪音)。 Mapping 注册路径/映射(servlet 型的 URL、spring 型的 handler 路径),空值随机低噪音。
type Payload ¶
type Payload struct {
Content []byte
Kind Kind
Password string
FilterName string
SHA256 string
TemplateID string
// Mapping 注册路径(servlet/spring 型有值,供回显与注册连接用)。
Mapping string
// ExtraFiles kind 附属文件(如 php-user-ini 的 .user.ini),随注入器一并写入同目录。
ExtraFiles map[string]string
// Triggerless true = 无需 ?su= 触发请求,落盘即生效(php-user-ini)。
Triggerless bool
}
Payload 生成结果。
func GenerateRemover ¶
GenerateRemover 生成内存马卸载器 JSP(与注入器同触发协议:GET ?<TriggerParam>=<密码>)。 语义:按 FilterName 从 StandardContext 移除 FilterDef/FilterMap 并剔除 filterConfigs, 与注入器的反射注册路径对称;仅支持 jsp-tomcat-filter(Tomcat 7-9)。
type ProbeInput ¶
type ProbeInput struct {
TargetURL string
StatusCode int
Server string
PoweredBy string
NotFoundBody string // body of a 404 probe, used to distinguish javax/jakarta
}
ProbeInput is the host-collected response data used for memory-shell selection. The host performs the HTTP request; this package only classifies.
type ProbeResult ¶
type ProbeResult struct {
TargetURL string `json:"target_url"`
StatusCode int `json:"status_code"`
Server string `json:"server,omitempty"`
PoweredBy string `json:"powered_by,omitempty"`
Family string `json:"family"` // tomcat | tomcat-jakarta | iis | php | unknown
Suggest []Kind `json:"suggest"`
Detail []string `json:"detail"`
}
func Probe ¶
func Probe(in ProbeInput) ProbeResult
Probe classifies the container/runtime and suggests memory-shell kinds.