Menu

Topic-icon Whitelist "Your current IP is:"

  • WorkingZombie
  • WorkingZombie's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
2 years 5 months ago #5376 by WorkingZombie
Replied by WorkingZombie on topic Whitelist "Your current IP is:"
We ran the snippet manually and it shows the correct IP address. See attachment.
in file: plugins/system/securitycheckpro/securitycheckpro.php

/* Obtiene la IP remota que realiza las peticiones */
        public function get_ip(){
                // Inicializamos las variables
                $clientIpAddress = 'Not set';
                $ip_valid = false;

                if (isset($_SERVER) && $_SERVER) {
                        $clientIpAddress = $_SERVER;
                        $result_ip_address = explode(', ',$clientIpAddress);
                        $clientIpAddress = $result_ip_address[0];
                        echo "Forwarded<br>";
                } else {
                        if ( isset($_SERVER) ) {
                                $clientIpAddress = $_SERVER;
                                echo "Remote Ad<br>";
                        }
                }
                $ip_valid = filter_var($clientIpAddress, FILTER_VALIDATE_IP);

                // Si la ip no es v▒lida intentamos extraer la direcci▒n IP remota
                if ( !$ip_valid ) {
                        if ( isset($_SERVER) ) {
                                $clientIpAddress = $_SERVER;
                        }

                        $ip_valid = filter_var($clientIpAddress, FILTER_VALIDATE_IP);
                        // Si la ip no es v▒lida entonces devolvemos 'Not set'
                        if ( !$ip_valid ) {
                                $clientIpAddress = 'Not set';
                        }
                }

                // Devolvemos el resultado
                echo "Client IP: " . $clientIpAddress;
                return $clientIpAddress;
        }
Attachments:

Please Log in or Create an account to join the conversation.

More
2 years 5 months ago #5377 by Jose
Replied by Jose on topic Whitelist "Your current IP is:"
I assume you have not the latest version of SCP (3.0.0) because I have changed that code precisely to add the ability to avoid proxies (the old method can by bypassed using some tricks). Anyway the code in that page is not the same of that function because one (the old) returns the X-Forwarded header, that is a header using when you use proxies. This way you get the real ip instead the proxy IP. But this method to determine the IP is dangerous, so I changed it. The new method only relies in the IP returned by the other header, that can't be spoofed.

Regards,
Jose

Please Log in or Create an account to join the conversation.

Time to create page: 0.074 seconds
Powered by Kunena Forum

Login or Sign In