ProxyPeeper v0.02a (w/ Database Support) 12-31-2012, 08:23 AM
#1
So this is version 0.02 haha Not much input on my last version, but ill post this here any ways
Its had very simple testing. Every thing *appears* to function for me. Thanks for checking it out.
pp.schema.sql
proxypeeper.php
pp.isproxy.function.php
pp.mysql.function.php
Its had very simple testing. Every thing *appears* to function for me. Thanks for checking it out.
pp.schema.sql
PHP Code:
CREATE TABLE pp_ipaddr (id int(6) NOT NULL auto_increment,ipaddr VARCHAR(45) NOT NULL,status TINYINT NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))
proxypeeper.php
PHP Code:
<?php
#
# ProxyPeeper
# Version 0.02a
# Dec. 31 / 2012
#
# Written by Geoff Ellis
# geoff[@]undergroundsystems.co
#
# Check to see if user is accessing site
# through an open proxy and check/record
# data to a database
#
@include 'pp.mysql.function.php';
@include 'pp.isproxy.function.php';
$ip = $_SERVER['REMOTE_ADDR'];
if(pp_checkip($ip) == 2) {
if(pp_isproxy() == 1) {
pp_addip($ip, 1);
die("Banned");
}
elseif(pp_isproxy == 0) {
pp_addip($ip, 0);
}
}
elseif(pp_checkip($ip) == 1) {
die("Banned");
}
?>pp.isproxy.function.php
PHP Code:
<?php
#
# ProxyPeeper
# Version 0.02a
# Dec. 31 / 2012
#
# Written by Geoff Ellis
# geoff[@]undergroundsystems.co
#
# pp.isproxy.function.php
# Check to see if user is accessing site
# through an open proxy.
#
function pp_isproxy() {
# Specify ports here you would like to check
# Do not add too many otherwise it will
# significantly decrease page loading times
$ports = array(80, 1080, 3128, 8080);
$ip = $_SERVER['REMOTE_ADDR'];
$success = 0;
foreach ($ports as $port) {
$attempt = @fsockopen($ip, $port,$errno,$errstr,$timeout=5);
if (is_resource($attempt)) {
$success = $success + 1;
if ($success >= 0) {
# Return: Is Proxy
return 1;
fclose($attempt);
}
else {
# Return: Is NOT Proxy
return 0;
fclose($attempt);
}
}
else {
# Return: Is NOT Proxy
return 0;
fclose($attempt);
}
}
}
?>pp.mysql.function.php
PHP Code:
<?php
#
# ProxyPeeper
# Version 0.02a
# Dec. 31 / 2012
#
# Written by Geoff Ellis
# geoff[@]undergroundsystems.co
#
# pp.mysql.function.php
# Check database to determine if users IP exists
# And or if it is banned/allowed
# Add IP if users IP does not exist
#
function pp_sqlconnect() {
# Specify database connection data here
$db_username = "";
$db_password = "";
$db_database = "";
$db_server = "localhost";
@mysql_connect($db_server, $db_username, $db_password);
@mysql_select_db($db_database);
}
function pp_addip($ip, $status) {
pp_sqlconnect();
$query = "INSERT INTO pp_ipaddr VALUES ('','$ip','$status')";
@mysql_query($query);
@mysql_close();
}
function pp_checkip($ip) {
pp_sqlconnect();
$query="SELECT * FROM pp_ipaddr WHERE ipaddr='$ip'";
$result=@mysql_query($query);
if(@mysql_num_rows($result) != 0) {
$data=@mysql_fetch_row($result);
if($data[2] == 1) {
return 1;
}
elseif($data[2] == 0) {
return 0;
}
}
else {
return 2;
}
@mysql_close();
}
?>


![[+]](https://sinister.li/images/modern/collapse_collapsed.png)


![[Image: 2YpkRjy.png]](http://i.imgur.com/2YpkRjy.png)