Getip () vulnerability code (for proud programmers)

Source: Internet
Author: User

Some time ago, when I was reading py, I went to this friend's blog. When I went to my blog today to see what information was updated, I saw that he sent an IP address. Because I am engaged in web security, I have seen many getip vulnerabilities and the code is copied online. Sure enough, I found a similar vulnerability in this Code.

<? Php/*** get the user's real IP Address */function getIP () {static $ realip; if (isset ($ _ SERVER )) {if (isset ($ _ SERVER ["HTTP_X_FORWARDED_FOR"]) {$ realip = $ _ SERVER ["HTTP_X_FORWARDED_FOR"];} else if (isset ($ _ SERVER ["HTTP_CLIENT_IP"]) {$ realip = $ _ SERVER ["HTTP_CLIENT_IP"];} else {$ realip = $ _ SERVER ["REMOTE_ADDR"] ;}} else {if (getenv ("HTTP_X_FORWARDED_FOR") {$ realip = getenv ("HTTP_X_FORWARDED_FOR ");} else if (getenv ("HTTP_CLIENT_IP") {$ realip = getenv ("HTTP_CLIENT_IP");} else {$ realip = getenv ("REMOTE_ADDR ");}} return $ realip ;}

 

A huge copy of the world's code... HTTP_X_FORWARDED_FOR HTTP_CLIENT_IP can be forged. If SQL injection is not displayed in the background, SQL injection and xss can be performed in the background.
Why is the title of this article dedicated to proud programmers. Because programmers are arrogant, the program he wrote has a bug. When someone asks a programmer, the programmer will immediately think, fuck, will this dumb use my program? I also said that my program has bugs. When I asked the program for the second time, the programmer thought, "is it my own problem. This is the case for many programmers. Don't worry about it. Thank you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.