|
|
|
Bandwidth Statics capture tool
Give Apache execude rights to IPTABLES with VISUDO.
apache ALL=(ALL) NOPASSWD: /sbin/iptables
MySQL Database Table
| CREATE TABLE `bandwidth`
(
`uid` INTEGER (11) NOT NULL AUTO_INCREMENT ,
`packets` bigint (20),
`bytes` bigint (20),
`chain` varchar (50),
`date` datetime,
PRIMARY KEY (uid)
) TYPE=MyISAM | |
| <?php
$x=1000;
?>
<html>
<script language=javascript>
var count = 0;
var running = true;
function doRewrite() {
if (running) {
count++;
setTimeout("doRewrite()", 1000);
location.reload();
}
}
</script>
<body onLoad="setTimeout('doRewrite()', <? echo $x; ?>)">
</html>
<?php
// MySQL Connection
$con = mysql_connect("localhost","root","va654422") or die("Kan niet connecten.");
$db = mysql_select_db("stats");
// -v -x -L INPUT
$output = exec("sudo iptables -v -x -L INPUT", $in);
echo $in[0];
$input = explode(' ', $in[0]);
echo "<pre>";
echo "Incomming: ".$input[4]." Packets.";
echo "<br>Incomming: ".$input[6]." Bytes.";
echo "</pre>";
// -v -x -L OUTPUT
$output = exec("sudo iptables -v -x -L OUTPUT", $out);
echo $out[0];
$output = explode(' ', $out[0]);
echo "<pre>";
echo "Outgoing: ".$output[4]." Packets.";
echo "<br>Outgoing: ".$output[6]." Bytes.";
echo "</pre>";
// -v -x -L FORWARD
$output = exec("sudo iptables -v -x -L FORWARD", $for);
echo $for[0];
$forward = explode(' ', $for[0]);
echo "<pre>";
echo "Forwarded: ".$forward[4]." Packets.";
echo "<br>Forwarded: ".$forward[6]." Bytes.";
echo "</pre>";
//-t nat -xv -L PREROUTING
$output = exec("sudo iptables -t nat -xv -L PREROUTING", $pre);
echo $pre[0];
$prerouted = explode(' ', $pre[0]);
echo "<pre>";
echo "Prerouting: ".$prerouted[4]." Packets.";
echo "<br>Prerouting: ".$prerouted[6]." Bytes.";
echo "</pre>";
//-t nat -xv -L POSTROUTING
$output = exec("sudo iptables -t nat -xv -L POSTROUTING", $post);
echo $post[0];
$postrouted = explode(' ', $post[0]);
echo "<pre>";
echo "Postrouting: ".$postrouted[4]." Packets.";
echo "<br>Postrouting: ".$postrouted[6]." Bytes.";
echo "</pre>";
// Totaal Input
$query = mysql_query("SELECT SUM(bytes) AS TotalInput, Count(date) AS aantalDagen FROM bandwidth WHERE chain='INPUT'");
while($record = mysql_fetch_object($query)){
$kb = $record->TotalInput / 1048576;
echo "<b>Totaal Binnenkomend: ".number_format($kb,2,",",".")." Mb. in ".$record->aantalDagen." dag(en).";
}
// Totaal Uitgaand
$query = mysql_query("SELECT SUM(bytes) AS TotalOutput, Count(date) AS aantalDagen FROM bandwidth WHERE chain='OUTPUT'");
while($record = mysql_fetch_object($query)){
$kb = $record->TotalOutput / 1048576;
echo "<br><b>Totaal Uitgaand: ".number_format($kb,2,",",".")." Mb. in ".$record->aantalDagen." dag(en).";
}
// Totaal Forwarded
$query = mysql_query("SELECT SUM(bytes) AS TotalForward, Count(date) AS aantalDagen FROM bandwidth WHERE chain='FORWARD'");
while($record = mysql_fetch_object($query)){
$kb = $record->TotalForward / 1048576;
echo "<br><b>Totaal Forward: ".number_format($kb,2,",",".")." Mb. in ".$record->aantalDagen." dag(en).";
}
// Totaal Prerouting
$query = mysql_query("SELECT SUM(bytes) AS TotalPrerouting, Count(date) AS aantalDagen FROM bandwidth WHERE chain='PREROUTING'");
while($record = mysql_fetch_object($query)){
$kb = $record->TotalPrerouting / 1048576;
echo "<br><b>Totaal Prerouting: ".number_format($kb,2,",",".")." Mb. in ".$record->aantalDagen." dag(en).";
}
// Totaal Postrouting
$query = mysql_query("SELECT SUM(bytes) AS TotalPostrouting, Count(date) AS aantalDagen FROM bandwidth WHERE chain='POSTROUTING'");
while($record = mysql_fetch_object($query)){
$kb = $record->TotalPostrouting / 1048576;
echo "<br><b>Totaal Postrouting: ".number_format($kb,2,",",".")." Mb. in ".$record->aantalDagen." dag(en).";
}
mysql_close($con);
?> | | |
|
| A damaged image generator (class) for validating text.
CAPTCHA - Completely Automated Public Turing test to tell Computers and Humans Apart Categories : PHP, PHP Classes, Security, GD image library, Security | | | A PHP function to encrypt and decrypt a number or string or a combination of the two. Categories : PHP, Encryption, Security | | | Dollar Serial Number Validator Categories : PHP, Security, Algorithms | | | MD5 secured login Categories : PHP, Java Script, Authentication, Security | | | Simple Password example Categories : PHP, Authentication, Security, HTTP | | | Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip Categories : Email, Network, PHP, PHP Classes | | | Encoding data using PGP via PHP's proc_* functions Categories : Cryptography, Security, Email, PHP, PGP | | | A very simple PHP single password cookie based login without usernames. Categories : PHP, Cookies, Security, Beginner Guides | | | PHP4 HTTP Compression Speeds up the Web Categories : PHP, Zlib, HTML and PHP, HTTP, Network | | | WebServerSpy checks which kind of Webserver is running, Apache, Netscape, Fasttrack, IIS, HTTP-Header, HTTP 1.0, GET, spy, WWW Categories : HTTP, Network, Apache, PHP, Web Servers | | | Easily Grant Temporary SSH Access to yourself when in remote location Categories : PHP, Linux, Cron, Security | | | Secure URL $_GET Categories : PHP, Data Validation, Security | | | Examines the user's computer for open Netbus (the trojan horse) port and reports the conclusion to the user. Categories : Network, PHP | | | SHA: Implementation of the Secure Hash Algorithm in pure PHP. This is a secure one-way function that can be used to perform challenge
response login algorithms over an insecure connection. Categories : Algorithms, PHP, Security | | | A simple PHP login script that you can modify to suite your needs. It use a session to store data in a session file submited by the page. Categories : PHP, Sessions, Security, Authentication | |
|
|
|