发现SQL注入漏洞
昨天我收到了一封来自某人的电子邮件,称我们的网站容易受到 SQL 注入攻击。电子邮件中写道:
我尝试了一些经典的 SQL 注入 你的服务器。该网址包含 结果:
注意上面的URL,我没有公开我的实际域名,而是将其替换为 mysite.com。
任何人都可以解释一下上面的 URL 的含义吗,因为我的网站很容易受到此类 URL 的攻击,也可能受到您的网站的攻击。
如何解码该网址,那里发生了什么?
Yesterday i received an email from a guy that our site is vulnerable to SQL injection. The email said:
I tried some classic SQL injection on
your server. This URL contains the
result:
Note that in the above URL, i do not expose my actual domain and have replaced it with mysite.com.
Can any one explain what above URL means as my site is vulnerable to that sort of url and possibly to your sites too.
How to decode that url, what is happening there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题是您正在将查询字符串上的 SQL 命令连接到 SQL 命令中。
大概你的代码会说这样的话
一旦你使用该查询字符串,它就会变成
EG:他让你的管理员帐户登录信息显示在你的预览页面上。
您应该始终确保 SQL 转义从用户获得的任何输入,或者更好地使用参数化查询,服务器会处理这一点。如果不了解 SQL Server 的语言或类型,我无法真正指出您需要哪些代码来执行此操作。
The problem is that you're concatenating that SQL command on the query string into your SQL command.
Presumably your code says something like
Once you use that QueryString it becomes
EG: He's made your admin account logins show up on your preview page.
You should always make sure to SQL escape any inputs you get from the user, or even better use parametrized queries and the server will take care of that. Without knowing the language or the type of SQL server I can't really point you in the direction of what code you'd need to do that.
您可能有如下代码(我不知道 php 语法):
string sql = "select * from mytable where customerid = " + Request.QueryString("id");
现在,由于给你发邮件的人在页面的查询字符串中添加的不仅仅是 id,你的 sql 语句将类似于:
select * from mytable where customerid = 6111111661 并合并所有你不想要的表。< /code>
始终在查询中使用参数并检查用户输入!
如果可能的话尽量避免动态sql。
You probably have code that looks like (I don't know php syntax):
string sql = "select * from mytable where customerid = " + Request.QueryString("id");
Now, since the guy who mailed you added a lot more than just the id to your page's querystring, your sql statement is going to like like:
select * from mytable where customerid = 6111111661 and union all the tables that you don't want.
Always use parameters in your queries and check the user input!
Try to avoid dynamic sql if possible.
更改您的代码以像这样工作。
现在,您的代码将不会接受无效的用户 ID,并且只要您使用我概述的方法清理所有字符串,就不会有 SQL 注入问题。
Change your code to work like this.
Now your code won't accept an invalid user ID and you won't have issues with SQL injection so long as you sanitize all strings using the method I've outlined.