Request.UserHostAddress.ToString() 可以被欺骗吗? ASP.NET 4.0-IIS 7.5
我使用此方法获取访问者 IP Request.UserHostAddress.ToString()
它是否有可能被欺骗或用于 SQL 注入。有哪些风险和可能性。谢谢。
ASP.NET 4.0、C# 4.0、IIS 7.5
I am getting the visitors ip with this method Request.UserHostAddress.ToString()
Are there any chance that it can be spoofed or used for sql injection. What are the risks and possibilities. thank you.
asp.net 4.0 , c# 4.0 , IIS 7.5
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不。IP 来自网络服务器的套接字。它不能被欺骗(对于多个请求)。如果IP被欺骗,客户端只能向服务器发送请求,而永远看不到回复。
我看不出它如何在 SQL 注入中使用,即使它是直接在 SQL 语句中使用的。即使它是假的,它也是一个 IP 地址,并且不可能是 SQL 代码。
摘要:
欺骗:如果用户必须在您的网站中导航(进行多次寻呼)。那么他的IP需要是正确的(不是欺骗的)。
注入:用户不能将任何值放入 UserHostAddress:它需要是一个 IP 地址,因此如果注入到 SQL 语句中不会造成损害。
No. The IP is from the socket with the web server. It can not be spoofed (for more then one request). If the IP was spoofed, the client could only send a request to the server and would never see the reply.
I can not see how it can be used in a SQL injection, even if it was used directly in your SQL statement. It is an IP-address even if it was fake, and could not be SQL code.
Summary:
Spoofing: If the user has to navigate in your site (make more then one page-call). Then his IP needs to be correct (not spoofed).
Injection: The user can not put just any value into UserHostAddress: it needs to be an IP-address, and therefore can not be harmful if injected into your SQL statement.
IP 地址本身可能会被欺骗,但可能性极低。
它不能用于 SQL 注入。
The IP address itself can be spoofed, but extremely unlikely.
It cannot be used for SQL injection.