Guest User

Untitled

a guest
Mar 14th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.83 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Overovani identity uzivatele</title>
  4. </head>
  5. <body>
  6. <?php
  7. function getMac($ip = false) {
  8.   static $arp;
  9.  
  10.   if (!$ip)
  11.     return (false);
  12.  
  13.   if (!isset ($arp))
  14.     $arp = file ("/proc/net/arp");
  15.  
  16.   foreach ($arp AS $radka) {
  17.     $radka = ereg_replace (" +", " ", $radka);
  18.    
  19.     $data = explode (" ", trim ($radka));
  20.    
  21.     if (trim ($data[0]) == $ip)
  22.       return $data[3];
  23.   }
  24.   return (false);
  25. }
  26. function overLogin($user, $pass) {
  27.   if ($user!="" && $pass!="") {
  28.     $soubor = fopen("/root/scripts/users.aut","r");
  29.     while (!feof($soubor)) {
  30.       $radek=fgets($soubor);
  31.       $data=explode(" ",trim ($radek));
  32.       if($user==$data[0] && $pass==$data[1] ) {
  33.         fclose($soubor);
  34.         return $data[2];
  35.       }
  36.     }  
  37.     fclose($soubor);
  38.     return 0;
  39.   }
  40. }
  41. function overIPaMac($ip, $mac) {
  42.   if ($ip!="" && $mac!="") {
  43.     $soubor = fopen("/root/scripts/users.mac","r");
  44.     while (!feof($soubor)) {
  45.       $radek=fgets($soubor);
  46.       $data=explode(" ",trim ($radek));
  47.       if($ip==$data[2] && $mac==$data[3]) {
  48.         return 1;
  49.       } else if($ip==$data[2] && $mac!=$data[3]) {
  50.         return 2;
  51.       } else if($ip!=$data[2] && $mac==$data[3]) {
  52.         return 3;
  53.       } else if($ip!=$data[2] && $mac!=$data[3]) {
  54.         return 0;
  55.       }    
  56.      
  57.     }
  58.     fclose($soubor);
  59.   }
  60.   return 0;  
  61. }
  62.  
  63. function vypisForm() {
  64.   echo "<form action=\"$_SERVER[PHP_SELF]\" method=\"post\">
  65.    Zadejte prihlasovaci udaje: <br />
  66.    Uzivatelske jmeno: <input type=\"text\" name=\"acc\" /> <br />
  67.    Heslo: <input type=\"password\" name=\"pass\" /> <br />
  68.    <input type=\"hidden\" name=\"sended\" value=\"yes\" />
  69.    <input type=\"submit\" value=\"Odeslat\" />
  70.    </form>";
  71.  
  72. }
  73.  
  74.  
  75. $ip = getenv('REMOTE_ADDR');
  76. $mac = getMac($ip);
  77. $volba = overIPaMac($ip, $mac);
  78. if ($volba == 0) {
  79.   if (!isset($_POST['sended'])) {
  80.     vypisForm();
  81.   } else {
  82.     $acc = $_POST['acc'];
  83.     $pass = $_POST['pass'];
  84.     $hrs = overLogin($acc,$pass);
  85.     echo "overeni proti souboru acc a pass \n<br />";
  86.     if ($hrs == 24) {
  87.       exec('sudo /root/scripts/itbadd.sh '.$ip.' '.$mac.' '.$acc.' '.$pass);
  88.  
  89.       echo("Vase IP je $ip \n<br />");
  90.       echo("Vas Mac je $mac \n<br />");
  91.       echo("Pro tyto hodnoty byla pridana vyjimka na firewallu. Na 24 hodin.");
  92.       echo("Tyto hodnoty si zapamatujte, mohou byti potreba v budoucnu.");
  93.     } else {
  94.       echo("Spatne prihlasovaci udaje \n<br />");
  95.       vypisForm();
  96.     }
  97.   }
  98. } else if ($volba == 1) {
  99.   echo("Tato IP je na firewallu registrovana - internet je dostupny!");
  100. } else if ($volba == 2) {
  101.   echo("Tato IP je na firewallu registrovana pro jinou MAC adresu");
  102. } else if ($volba == 3) {
  103.   echo("Pro tuto MAC adresu je registrovana jina IP adresy - zmente si nastaveni IP");
  104. }
  105.  
  106.  
  107. ?>
  108. </body>
  109. </html>
Add Comment
Please, Sign In to add comment