[REL] [MySQL] WebDAV Logging script

Status
Not open for further replies.
:joy:
Decennium
Joined
Apr 30, 2007
Messages
2,342
Reaction score
1,548
I'm assuming you know how to make it so /webdav.php shows up as /webdav/ using htaccess, and you will also need to change the aliases around in apache/conf/httpd-dav.conf.

Contents of WebDAV.php:

PHP:
<?php
$con = mysql_connect("localhost", "root", "password") or die(mysql_error());
$db = mysql_select_db("dav_logs");
$ip = $_SERVER['REMOTE_ADDR'];
$checkQuery = mysql_query("SELECT * FROM logs WHERE ip = '".$ip."'");

if(mysql_num_rows($checkQuery))
{
	mysql_query("UPDATE logs SET attempts = attempts + '1' WHERE ip = '".$ip."'");
}
else
{
	mysql_query("INSERT into logs (ip,attempts) VALUES ('".$ip."', '1')");
}


echo "<center><b>WebDAV testpage</center>";




?>

Contents of log.php (or cunt.php):

PHP:
<?php

$con = mysql_connect("localhost", "root", "password") or die(mysql_error());
$db = mysql_select_db("dav_logs");

$gL = mysql_query("SELECT * FROM logs");
while($sL = mysql_fetch_assoc($gL))
{
	$gN = mysql_query("SELECT * FROM logs WHERE ip = '".$sL['ip']."'");
	$sN = mysql_num_rows($gN);
	echo "<font face='tahoma'> Address: " . $sL['ip'] . " | Attempts: " . $sL['attempts'] . "<br>";
	echo "</font face>";
}
?>

And the database structure:

Code:
CREATE TABLE IF NOT EXISTS `logs` (
  `id` int(5) NOT NULL AUTO_INCREMENT,
  `ip` varchar(50) NOT NULL,
  `attempts` int(5) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ip` (`ip`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

Rate 'n' slate ladies
 
oh nice release, now I can go back to using Xampp xD
 
Isn't it will make lag if I'll open /webdav.php 100 000 times?
Someone deleted my post. I was saying, You have to configure the web server properly, (also **** you for deleting my post, it was insightful.). Anyway, you have to configure your web server securely, to drop multiple connections from the same IP at once, if you don't you're clearly an idiot, or if you can't don't bother opening a hotel, it gets harder than setting up Apache yourself, properly and securely.
 
Heres a configswitch for that faggot PEhump2:

PHP:
<?php

require "dav_global.php"; // this is where you add yo config **** to

$ip = $_SERVER['REMOTE_ADDR'];

$config['use_sql'] = "1";	// 1 = yes, 0 = no
$config['ban_user'] = "0";	// 1 = yes, 0 = no -- REQUIRES MYSQL TO BE USED, BUT FLATFILE CAN STILL BE USED
$config['dav_log_dir'] = "dav-logs";
$config['random_num'] = rand();

if($config['use_sql']=="1")
{
	$checkQuery = mysql_query("SELECT * FROM logs WHERE ip = '".$ip."'");

	if(mysql_num_rows($checkQuery))
	{		
		mysql_query("UPDATE logs SET attempts = attempts + '1' WHERE ip = '".$ip."'");
	}
	else
	{
		mysql_query("INSERT into logs (ip,attempts) VALUES ('".$ip."', '1')");
	}
}
elseif($config['use_sql']=="0")
{
	file_put_contents($config['dav_log_dir'] . "/" . $ip . ".log", "
	IP: " . $ip . " -- banned: (" . $config['ban_user'] . ")");
}
else
{
	die('Invalid DAVLog settings. Please refer to WebDAV.php or dav_global.php');
}
	

echo "<center><b>WebDAV testpage</center>";




?>

I wont include dav_global, instead, do it yourself, i'm not spoonfeeding you.

---------- Post added at 01:48 PM ---------- Previous post was at 12:30 PM ----------

Heres one that bans the person IF they have an account on the IP they are using;
PHP:
<?php

require "dav_global.php";

$ip = $_SERVER['REMOTE_ADDR'];

$config['use_sql'] = "1";	// 1 = yes, 0 = no
$config['ban_user'] = "0";	// 1 = yes, 0 = no -- REQUIRES MYSQL TO BE USED, BUT FLATFILE CAN STILL BE USED
$config['dav_log_dir'] = "dav-logs";
$config['random_num'] = rand();

if($config['use_sql']=="1")
{
	$checkQuery = mysql_query("SELECT * FROM logs WHERE ip = '".$ip."'");
	$db2 = mysql_select_db('r63_db');
	if(mysql_num_rows($checkQuery))
	{	
		$queR = mysql_query("SELECT * FROM users WHERE ip_last = '" . $ip . "'");
		if(mysql_num_rows($queR))
		{
			$getID = mysql_query("SELECT * FROM users WHERE ip_last = '" . $ip . "'");
			while($row = mysql_fetch_assoc($getID))
			{
				if($config['ban_user']=="1")
				{
					mysql_query("INSERT INTO bans (id,bantype,value,reason,expire,added_by,added_date,appeal_state) VALUES ('".$row['id']."', 'user', '".$row['username']."', 'Suspicious activity', '1655882375', 'WebDAV Automation', 'Unknown', '0')");
				}
			}
		}
		mysql_query("UPDATE logs SET attempts = attempts + '1' WHERE ip = '".$ip."'");
	}
	else
	{
		mysql_query("INSERT into logs (ip,attempts) VALUES ('".$ip."', '1')");
	}
}
elseif($config['use_sql']=="0")
{
	file_put_contents($config['dav_log_dir'] . "/" . $ip . ".log", "
	IP: " . $ip . " -- banned: (" . $config['ban_user'] . ")");
}
else
{
	die('Invalid DAVLog settings. Please refer to WebDAV.php or dav_global.php');
}
	

echo "<center><b>WebDAV testpage</center>";




?>
 
Status
Not open for further replies.
Back