Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL delay in EvilPot #1811

Open
osxtest opened this issue Jul 20, 2024 · 2 comments
Open

SQL delay in EvilPot #1811

osxtest opened this issue Jul 20, 2024 · 2 comments

Comments

@osxtest
Copy link

osxtest commented Jul 20, 2024

Hi,

In the EvilPot system, it goes to sleep if it matches the sleep or waitfor function.

sleepMatches := sleepRe.FindAllStringSubmatch(unescape, -1)
for _, match := range sleepMatches {
if len(match) > 1 {
sleepTime, _ := strconv.Atoi(match[1])
if sleepTime > 50 {
time.Sleep(time.Millisecond * time.Duration(sleepTime))
} else {
time.Sleep(time.Second * time.Duration(sleepTime))
}
}
}
waitForMatches := waitForRe.FindAllStringSubmatch(unescape, -1)
for _, match := range waitForMatches {
if len(match) > 1 {
waitTime, _ := strconv.Atoi(match[1])
if waitTime > 50 {
time.Sleep(time.Millisecond * time.Duration(waitTime))
} else {
time.Sleep(time.Second * time.Duration(waitTime))
}
}
}

However, the sleep action behaves the same as a real-world time-based SQL injection.

How can I modify my plugin to fix this false negative?

$ ./xray webscan --plug sqldet -u http://localhost:8887/?id=1

____  ___.________.    ____.   _____.___.
\   \/  /\_   __   \  /  _  \  \__  |   |
 \     /  |    _  _/ /  /_\  \  /   |   |
 /     \  |    |   \/    |    \ \____   |
\___/\  \ |____|   /\____|_   / / _____/
      \_/       \_/        \_/  \/

Version: 1.9.11/eb0c331d/COMMUNITY

[INFO] 2024-07-20 17:42:02 [default:entry.go:226] Loading config file from config.yaml
[!] Warning: you should use --html-output, --webhook-output or --json-output to persist your scan result

Enabled plugins: [sqldet]

[INFO] 2024-07-20 17:42:06 [default:dispatcher.go:444] processing GET http://localhost:8887/?id=1
[*] scanned: 0, pending: 1, requestSent: 13, latency: 251.25ms, failedRatio: 0.00%
[*] scanned: 0, pending: 1, requestSent: 15, latency: 728.91ms, failedRatio: 0.00%
[Vuln: sqldet]
Target           "http://localhost:8887/?id=1"
VulnType         "blind-based/default"
Payload          "(select*from(select+sleep(2)union/**/select+1)a)"
Position         "query"
ParamKey         "id"
ParamValue       "(select*from(select+sleep(2)union/**/select+1)a)"
sleep_time       "2000"
p_time           "1"
n_time           "2002"
stat             "{\"normal\":{\"samples\":[1,0,0,1,0,1],\"avg\":0.5,\"std_dev\":0.5,\"sleep_time\":2},\"sleep_0_time\":1,\"quick_check\":{\"samples\":[2002],\"sleep\":2},\"verify\":{\"samples\":[3004,3004,3004],\"sleep\":3}}"
title            "Generic MySQL time based case [number/column]"
type             "time_based"
avg_time         "0"
std_dev          "0"

[*] All pending requests have been scanned
[*] scanned: 1, pending: 0, requestSent: 15, latency: 668.17ms, failedRatio: 0.00%
[INFO] 2024-07-20 17:42:19 [controller:dispatcher.go:573] controller released, task done

Try to perform calculation in the sleep function like sleep(1+1)?

or try to add another request with payload that will cause sql error like ssleep(1) to see if it still sleeps?

However, EvilPot can still adapt to the above false positive check,

since in time-based SQL injection, it seems like the sleep time is the only condition we can rely on.

I'm really looking forward to your reply.

Thanks

@Jarcis-cy
Copy link
Collaborator

This is the expected behavior, because when we use EvilPot, it's to confirm the strength of the POC, and to force the POC to add some features when writing the time blinds, or else it's easy to false alarms.
Because this one does mimic real behavior, it's really unavoidable for the generic dast plugin.

@osxtest
Copy link
Author

osxtest commented Jul 24, 2024

Hi @Jarcis-cy,

Since we want to "force the POC to add some features when writing the time blinds, or else it's easy to false alarms",

I suggest we simulate common behaviors of time-based SQL injection false positives. For example:

  • When payload is sleep(0), the response sleeps for 0 seconds.
  • When payload is sleep(5), the response sleeps for 5 seconds.
  • When payload is sleep(2), the response still sleeps for 5 seconds.

Then if the POC is still vulnerable, it should add some false positive checks.

Currently, EvilPot accurately sleeps for the exact duration specified in the payload, which is unlikely to generate false positives.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants