Advertisement
Guest User

Untitled

a guest
Nov 12th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.93 KB | None | 0 0
  1. <?php
  2. include("functions.php");
  3.  
  4. $tempuser = "true";
  5. $user = "";
  6. $pass = "";
  7.  
  8. $ch = curl_init();
  9. curl_setopt($ch, CURLOPT_URL,"http://bot4school.altervista.org/test/login.php");
  10. curl_setopt($ch, CURLOPT_POST, 1);
  11. curl_setopt($ch, CURLOPT_POSTFIELDS, "tempuser=$tempuser&user=$user&pass=$pass");
  12. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  13. curl_setopt($ch, CURLOPT_HEADER, 1);
  14. $server_output = curl_exec($ch);
  15. curl_close ($ch);
  16.  
  17. $stuser = explode("stuser=", $server_output);
  18. $stuser = explode("%3D", $stuser[1]);
  19. $stuser = $stuser[0]."%3D";
  20.  
  21. $stpass = explode("stpass=", $server_output);
  22. $stpass = explode("%3D", $stpass[1]);
  23. $stpass = $stpass[0]."%3D";
  24.  
  25. $ch = curl_init();
  26. curl_setopt($ch, CURLOPT_URL,"http://bot4school.altervista.org/test/quiz.php?selectedquiz=Subnetting+demo+10+domande");
  27. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  28. curl_setopt($ch, CURLOPT_HEADER, 1);
  29. curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: stuser=$stuser; stpass=$stpass;"));
  30. $server_output = curl_exec($ch);
  31. curl_close ($ch);
  32.  
  33. for ($x=0;  $x<10; $x++) {
  34.     $ch = curl_init();
  35.     curl_setopt($ch, CURLOPT_URL,"http://bot4school.altervista.org/test/quiz.php?q=".($x+1));
  36.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  37.     curl_setopt($ch, CURLOPT_HEADER, 1);   
  38.     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: stuser=$stuser; stpass=$stpass; activequiz=Subnetting+demo+10+domande"));
  39.     $server_output = curl_exec($ch);   
  40.     $domanda = explode('<div id="qdiv">', $server_output);
  41.     $domanda = explode('</div>', $domanda[1]);
  42.     $domanda = trim($domanda[0]);  
  43.     curl_close ($ch);
  44.     echo "Domanda ".($x+1).": $domanda";
  45.    
  46.     if (strpos($domanda, "host valido della rete alla quale appartiene l'indirizzo") !== false) {
  47.         // TIPO 1
  48.         if (strpos($domanda, "/") !== false) {
  49.             $maschera = explode("/", $domanda);
  50.             $maschera = explode(" ", $maschera[1]);
  51.             $maschera = $maschera[0];
  52.             $indirizzo = explode("appartiene l'indirizzo ", $domanda);
  53.             $indirizzo = explode("/", $indirizzo[1]);
  54.             $indirizzo = $indirizzo[0];
  55.             $maschera = shorthand_to_mask($maschera);
  56.         }
  57.         elseif (strpos($domanda, "con maschera ") !== false) {
  58.             $maschera = explode("con maschera ", $domanda);
  59.             $maschera = $maschera[1];
  60.             $indirizzo = explode("appartiene l'indirizzo ", $domanda);
  61.             $indirizzo = explode(" ", $indirizzo[1]);
  62.             $indirizzo = $indirizzo[0];
  63.             $maschera = elaborate_mask($maschera);
  64.         }
  65.         $indirizzo = elaborate_ip($indirizzo);
  66.         if (strpos($domanda, "Inserisci il primo") !== false) {
  67.             // TIPO 1.1
  68.             echo " <== TIPO 1.1";
  69.             echo " *** ".net_to_raw((first_host($indirizzo, $maschera)))." ***";
  70.         }
  71.         elseif (strpos($domanda, "Inserisci l'ultimo") !== false) {
  72.             // TIPO 1.2
  73.             echo " <== TIPO 1.2";
  74.             echo " *** ".net_to_raw(last_host($indirizzo, $maschera))." ***";
  75.         }      
  76.     }
  77.     else if (strpos($domanda, "Qual &egrave; la maschera corrispondente alla shorthand") !== false) {
  78.         //TIPO 2
  79.         echo " <== TIPO 2";
  80.         $shorthand = explode("alla shorthand /", $domanda);
  81.         $shorthand = explode("?", $shorthand[1]);
  82.         $shorthand = $shorthand[0];
  83.         echo " *** ".mask_to_raw(shorthand_to_mask($shorthand))." ***";
  84.     }
  85.     else if (strpos($domanda, "Inserisci l'indirizzo di broadcast dell'IP") !== false) {
  86.         //TIPO 3
  87.         echo " <== TIPO 3";
  88.         if (strpos($domanda, "/") !== false) {
  89.             $maschera = explode("/", $domanda);
  90.             $maschera = explode(" ", $maschera[1]);
  91.             $maschera = $maschera[0];
  92.             $indirizzo = explode("dell'IP ", $domanda);
  93.             $indirizzo = explode("/", $indirizzo[1]);
  94.             $indirizzo = $indirizzo[0];
  95.             $maschera = shorthand_to_mask($maschera);
  96.         }
  97.         elseif (strpos($domanda, "con maschera ") !== false) {
  98.             $maschera = explode("con maschera ", $domanda);
  99.             $maschera = $maschera[1];
  100.             $indirizzo = explode("dell'IP ", $domanda);
  101.             $indirizzo = explode(" ", $indirizzo[1]);
  102.             $indirizzo = $indirizzo[0];
  103.             $maschera = elaborate_mask($maschera);
  104.         }
  105.         $indirizzo = elaborate_ip($indirizzo);
  106.         echo " *** ".net_to_raw(broadcast($indirizzo, $maschera))." ***";
  107.     }
  108.     else if (strpos($domanda, "Inserisci l'indirizzo della subnet alla quale appartiene l'indirizzo") !== false) {
  109.         //TIPO 4
  110.         echo " <== TIPO 4";
  111.         if (strpos($domanda, "/") !== false) {
  112.             $maschera = explode("/", $domanda);
  113.             $maschera = explode(" ", $maschera[1]);
  114.             $maschera = $maschera[0];
  115.             $indirizzo = explode(" alla quale appartiene l'indirizzo ", $domanda);
  116.             $indirizzo = explode("/", $indirizzo[1]);
  117.             $indirizzo = $indirizzo[0];
  118.             $maschera = shorthand_to_mask($maschera);
  119.         }
  120.         elseif (strpos($domanda, "con maschera ") !== false) {
  121.             $maschera = explode("con maschera ", $domanda);
  122.             $maschera = $maschera[1];
  123.             $indirizzo = explode(" alla quale appartiene l'indirizzo ", $domanda);
  124.             $indirizzo = explode(" ", $indirizzo[1]);
  125.             $indirizzo = $indirizzo[0];
  126.             $maschera = elaborate_mask($maschera);
  127.         }
  128.         $indirizzo = elaborate_ip($indirizzo);
  129.         echo " *** ".net_to_raw(find_net($indirizzo, $maschera))." ***";
  130.     }
  131.    
  132.     echo "\n";
  133.    
  134. }
  135.  
  136. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement