如何发现sql注入漏洞?
有没有办法发现SQL注入漏洞?
注意:我问的是如何在您控制的服务器上找到它们,以便您可以修复它们。我不是问如何在别人的服务器上检测它们以利用它们。
有没有一种方法可以找到每次出现的 mysql_query()
而无需打开每个页面并执行 ctrl+f
操作?
Is there a way to find SQL injection vulnerabilities?
Note: I am asking how to find them on a server you are in control of so you can fix them. I am not asking about how to detect them on someone else's server to exploit them.
Is there a way to find every occurance of mysql_query()
without opening every page and doing a ctrl+f
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
使用 Linux,您可以使用
grep
实用程序。/dir/containing/files
:包含 PHP 文件的目录,例如 /home/user/domains/example.com/public_html-type f
:搜索文件仅(不是目录)-name '*.php'
仅匹配以.php
结尾的文件。如果您也想匹配其他文件,例如.inc
,请使用以下文件:-name '*.php' -o -name '*.inc'
(匹配*.php 或 *.inc)|xargs grep
使用找到的文件内容进行搜索--color=auto
突出显示找到的部分"mysql_query"< /code> 你的搜索词
Using linux, you can use the
grep
utility./dir/containing/files
: The directory containing your PHP files, for example, /home/user/domains/example.com/public_html-type f
: search for files only (not directories)-name '*.php'
match files ending with.php
only. If you'ld like to match other files too, like.inc
use this instead:-name '*.php' -o -name '*.inc'
(matches *.php OR *.inc)|xargs grep
use the contents of the found files for searching--color=auto
highlights the found part"mysql_query"
your search terms不,没有简单的方法。如果有的话,也不是万无一失的。
话虽如此,您应该查看这个问题/答案线程并应用它们。
要搜索
mysql_query()
,您可以使用文本编辑器的在文件中搜索功能。我使用 Notepad++ 并且它有search-in-files
它可以在具有特定扩展名(在您的情况下为 .php)文件的目录和子目录中搜索类似mysql_query
的任何字符串。Notepad++ 的屏幕截图教程位于此处。
No, there is no simple way. And if there is, it is NOT fool-proof.
That being said, you should look into this question/answer thread and apply them.
For searching
mysql_query()
, you can use your text-editor's search in files feature. I use Notepad++ and it hassearch-in-files
which can search for any string likemysql_query
in a directory and subdirectory with specific extension (.php in your case) files.A tutorial with screenshot for Notepad++ is here.
有一个用 python 编写的开源项目,名为 w3af,除其他外,它还用于查找 SQL 注入问题。
从页面下载它,然后在启动时选择 fast_scan 配置文件,并在目标上输入您的 URL(可能类似于 http: //localhost:8080(如果您在本地运行)并运行应用程序。
如果它发现任何 SQL 注入问题,它会通知您。
此步骤可以在检查所有
mysql_query
调用以检查一切正常后完成。There's an open source project made in python called w3af which is used, among other things, to find SQL injection problems.
Download it from the page and then when you start it select the fast_scan profile and on the Target enter your URL (it could be something like http://localhost:8080 if you are running locally) and run the application.
In case it can find any sql injection problem it will let you know.
This step can be done after checking all your
mysql_query
calls to check everything is working fine.到目前为止,查找 SQL 注入漏洞的最佳方法是使用 Fuzzer,例如 Acunetix ($) NTOSpider( $$$), Wapitit(开源,很好),W3AF(开源,不是很好。 )。
确保 dispaly_errors=On。这些工具通过插入不良数据(如
'"
)并查看是否显示错误来检测 sql 注入。它们还通过注入需要很长时间的查询(如' sleep(30))来检测 sql 注入 - -
查看请求是否花费超过 30 秒。By far the best way to find SQL Injection Vulnerablites is by using a Fuzzer such as Acunetix ($) NTOSpider($$$), Wapitit(open source, very good), W3AF(open source, not very good.).
Make sure dispaly_errors=On. These tools detect sql injection by inserting bad data like
'"
and seeing if an error is displayed. They also detect sql injection by injecting queries that take a long time like' sleep(30)--
to see if the request takes more than 30 seconds.如果您想进行搜索,请尝试一下 Red Gate 出色的 SQL 搜索 工具(它是免费的) !)但它仅适用于 SQL Server。
If you want to search give Red Gate's excellent SQL Search tool a try (its free!) but it's only for SQL Server though.