如何自动测试网站的 SQL 注入漏洞

发布于 2024-10-24 10:10:43 字数 589 浏览 5 评论 0原文

这是一个基本计划。我很高兴能够取得任何类似成功的成果,这是一个 Uni 项目。伪代码很棒。

  1. 抓取网站。
  2. 在每个页面上搜索表单。
  3. 提交每份表格而不填写详细信息将导致失败。
  4. 在表单的第一个字段中填写“--”。
  5. 提交表格并将响应与失败(由 3 引出)进行比较。
  6. 如果响应(由 5 引发)不同(与失败),则假设存在漏洞。
  7. 如果相同(响应 = 失败),则返回到 4,但移至下一个字段。
  8. 如果没有更多字段,请移至另一页。

...

但是,6. 显然既是应用程序的关键部分又是错误的。例如,页面可能会像这样响应

Error: '-- is not a valid user name.

在第 4 阶段中的位置。响应是

Error:  is not a valid user name.

Error: username must be a minimum of 6 characters.

Here's a basic plan. I'm happy to produce anything resembling success, it's a Uni project. Pseudo code is great.

  1. Spider the site.
  2. Search for forms on each page.
  3. Submit each form without filling in the details to elicit a guaranteed fail.
  4. Fill in the first field on the form with '-- .
  5. Submit the form and compare the response to the fail (elicited by 3).
  6. If response (elicited by 5) is different (than fail) then assume vulnerability.
  7. If same (response = fail) then return to 4. but move to the next field.
  8. If no more fields remain, move to another page.

...

However, 6. is clearly both the critical part of the application and wrong. For example, a page might respond like this

Error: '-- is not a valid user name.

Where in stage 4. the response was

Error:  is not a valid user name.

Or

Error: username must be a minimum of 6 characters.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怪我鬧 2024-10-31 10:10:43

看起来在 (4) 处,您想首先尝试发送一些良性值,以便您可以看到在正常情况下返回的页面类型。

例如,生成一个随机的三字母“用户名”并提交。您可能会收到类似“错误:bfw 不是有效的用户名”的响应。或“错误:用户名太短”。

完成此操作后,您可以发送尝试 SQL 注入的字符串,看看结果是否有本质上的不同。因此,如果您发送 '-- 并获得与发送随机良性“用户名”时相同的结果,则它可能不易受到攻击。另一方面,如果您收到的响应不同,并且包含类似“警告,您的 SQL 第 1 行有错误...”之类的文本,那么它可能容易受到攻击。 (不过,它不必发出警告让您断定它容易受到攻击。即使是通用错误页面,如果它与您从良性数据获得的响应有很大不同,也可能表明存在漏洞。)

It seems like at (4), you want to try sending some benign values first so you can see what type of page is returned under normal conditions.

For example, generate a random three-letter "user name" and submit it. You'll probably get a response like "Error: bfw is not a valid user name". or "Error: username too short".

Once you've done that, you can send your string attempting SQL injection and see if the result is qualitatively different. So if you send '-- and get the same result as you did when you sent your random benign "username", it's probably not vulnerable. On the other hand, if you get a response back that's different and includes text like "Warning, you have an error in your SQL at line 1..." then it's probably vulnerable. (It doesn't have to spit out warnings for you to conclude it's vulnerable, though. Even a generic error page might indicate vulnerability if it's substantially different to the response you got from your benign data.)

难以启齿的温柔 2024-10-31 10:10:43

Justin Clarke 的“SQL 注入攻击和防御”。

提供了许多测试来发现和确认 SQL 注入漏洞,这是我对第 65 页的总结。

错误触发

“发送 ''-- 并期望接收错误。”

错误消息或 500 服务器错误表明存在漏洞。整齐地包含 ''-- 的响应(如用户 ''-- 不可用)密码...)可能不容易受到攻击,除非它是堆栈跟踪。

始终为 true 条件

“发送 1' 或 '1'='11') 或 ('1'='1 并期望收到 当响应代码为 200 并且响应中未收到攻击字符串时,可以假定站点

存在漏洞。包含单词“error”或攻击字符串的页面表明存在抵抗力,就像500.

没有条件

“发送 value” 或 '1'='2value') 或 ('1'='2 并期望易受攻击的应用程序就好像它只收到一样进行响应。"

始终为 false 条件

"1' 和 '1'='21' ) 和 ('1'='2。如果成功,则不会从表中返回任何行。"

Microsoft SQL Server 连接

"1' 或 'ab'='a '+'b1') 或 ('ab'='a'+'b。如果成功,则返回相同
信息作为始终为真的条件"

MySQL 连接

"1' 或 'ab'='a' 'b1') 或 ('ab'=' a' 'b 如果成功,则返回相同的结果。
信息作为始终为真的条件"

Oracle 连接

"1' 或 'ab'='a'||'b1') 或 ('ab' ='a'||'b 如果成功,则返回相同的结果。
信息作为始终真实的条件”

本书中包含了更多示例。

"SQL Injection Attacks and Defense" by Justin Clarke.

Offers a number of tests to discover and confirm SQL injection vulnerabilities, here's my summary of page 65.

Error triggering

"Send ' or '-- and expect to receive an error."

An error message or 500 server error indicates vulnerability. Responses tidily containing ' or '-- (as in user ' or '-- is not available with that password...) probably aren't vulnerable unless its a stack-trace.

Always true condition

"Send 1' or '1'='1 or 1') or ('1'='1 and expect to receive every entry in the database."

A site can be assumed to be vulnerable when the response code is 200 and the attack string is not received in the response. Pages containing the word 'error' or the attack string indicate resistance, as does a 500.

No condition

"Send value' or '1'='2 or value') or ('1'='2 and expect a vulnerable app to respond as though it had only received value."

Always false condition

"1' and '1'='2 or 1') and ('1'='2. If successful, it returns no rows from the table."

Microsoft SQL Server concatenation

"1' or 'ab'='a'+'b or 1') or ('ab'='a'+'b. If successful, it returns the same
information as an always true condition"

MySQL concatenation

"1' or 'ab'='a' 'b or 1') or ('ab'='a' 'b. If successful, it returns the same
information as an always true condition"

Oracle concatenation

"1' or 'ab'='a'||'b or 1') or ('ab'='a'||'b. If successful, it returns the same
information as an always true condition"

Further examples are included throughout the book.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文