Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Overovani identity uzivatele</title>
- </head>
- <body>
- <?php
- function getMac($ip = false) {
- static $arp;
- if (!$ip)
- return (false);
- if (!isset ($arp))
- $arp = file ("/proc/net/arp");
- foreach ($arp AS $radka) {
- $radka = ereg_replace (" +", " ", $radka);
- $data = explode (" ", trim ($radka));
- if (trim ($data[0]) == $ip)
- return $data[3];
- }
- return (false);
- }
- function overLogin($user, $pass) {
- if ($user!="" && $pass!="") {
- $soubor = fopen("/root/scripts/users.aut","r");
- while (!feof($soubor)) {
- $radek=fgets($soubor);
- $data=explode(" ",trim ($radek));
- if($user==$data[0] && $pass==$data[1] ) {
- fclose($soubor);
- return $data[2];
- }
- }
- fclose($soubor);
- return 0;
- }
- }
- function overIPaMac($ip, $mac) {
- if ($ip!="" && $mac!="") {
- $soubor = fopen("/root/scripts/users.mac","r");
- while (!feof($soubor)) {
- $radek=fgets($soubor);
- $data=explode(" ",trim ($radek));
- if($ip==$data[2] && $mac==$data[3]) {
- return 1;
- } else if($ip==$data[2] && $mac!=$data[3]) {
- return 2;
- } else if($ip!=$data[2] && $mac==$data[3]) {
- return 3;
- } else if($ip!=$data[2] && $mac!=$data[3]) {
- return 0;
- }
- }
- fclose($soubor);
- }
- return 0;
- }
- function vypisForm() {
- echo "<form action=\"$_SERVER[PHP_SELF]\" method=\"post\">
- Zadejte prihlasovaci udaje: <br />
- Uzivatelske jmeno: <input type=\"text\" name=\"acc\" /> <br />
- Heslo: <input type=\"password\" name=\"pass\" /> <br />
- <input type=\"hidden\" name=\"sended\" value=\"yes\" />
- <input type=\"submit\" value=\"Odeslat\" />
- </form>";
- }
- $ip = getenv('REMOTE_ADDR');
- $mac = getMac($ip);
- $volba = overIPaMac($ip, $mac);
- if ($volba == 0) {
- if (!isset($_POST['sended'])) {
- vypisForm();
- } else {
- $acc = $_POST['acc'];
- $pass = $_POST['pass'];
- $hrs = overLogin($acc,$pass);
- echo "overeni proti souboru acc a pass \n<br />";
- if ($hrs == 24) {
- exec('sudo /root/scripts/itbadd.sh '.$ip.' '.$mac.' '.$acc.' '.$pass);
- echo("Vase IP je $ip \n<br />");
- echo("Vas Mac je $mac \n<br />");
- echo("Pro tyto hodnoty byla pridana vyjimka na firewallu. Na 24 hodin.");
- echo("Tyto hodnoty si zapamatujte, mohou byti potreba v budoucnu.");
- } else {
- echo("Spatne prihlasovaci udaje \n<br />");
- vypisForm();
- }
- }
- } else if ($volba == 1) {
- echo("Tato IP je na firewallu registrovana - internet je dostupny!");
- } else if ($volba == 2) {
- echo("Tato IP je na firewallu registrovana pro jinou MAC adresu");
- } else if ($volba == 3) {
- echo("Pro tuto MAC adresu je registrovana jina IP adresy - zmente si nastaveni IP");
- }
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment