Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("functions.php");
- $tempuser = "true";
- $user = "";
- $pass = "";
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,"http://bot4school.altervista.org/test/login.php");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, "tempuser=$tempuser&user=$user&pass=$pass");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HEADER, 1);
- $server_output = curl_exec($ch);
- curl_close ($ch);
- $stuser = explode("stuser=", $server_output);
- $stuser = explode("%3D", $stuser[1]);
- $stuser = $stuser[0]."%3D";
- $stpass = explode("stpass=", $server_output);
- $stpass = explode("%3D", $stpass[1]);
- $stpass = $stpass[0]."%3D";
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,"http://bot4school.altervista.org/test/quiz.php?selectedquiz=Subnetting+demo+10+domande");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HEADER, 1);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: stuser=$stuser; stpass=$stpass;"));
- $server_output = curl_exec($ch);
- curl_close ($ch);
- for ($x=0; $x<10; $x++) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,"http://bot4school.altervista.org/test/quiz.php?q=".($x+1));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HEADER, 1);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: stuser=$stuser; stpass=$stpass; activequiz=Subnetting+demo+10+domande"));
- $server_output = curl_exec($ch);
- $domanda = explode('<div id="qdiv">', $server_output);
- $domanda = explode('</div>', $domanda[1]);
- $domanda = trim($domanda[0]);
- curl_close ($ch);
- echo "Domanda ".($x+1).": $domanda";
- if (strpos($domanda, "host valido della rete alla quale appartiene l'indirizzo") !== false) {
- // TIPO 1
- if (strpos($domanda, "/") !== false) {
- $maschera = explode("/", $domanda);
- $maschera = explode(" ", $maschera[1]);
- $maschera = $maschera[0];
- $indirizzo = explode("appartiene l'indirizzo ", $domanda);
- $indirizzo = explode("/", $indirizzo[1]);
- $indirizzo = $indirizzo[0];
- $maschera = shorthand_to_mask($maschera);
- }
- elseif (strpos($domanda, "con maschera ") !== false) {
- $maschera = explode("con maschera ", $domanda);
- $maschera = $maschera[1];
- $indirizzo = explode("appartiene l'indirizzo ", $domanda);
- $indirizzo = explode(" ", $indirizzo[1]);
- $indirizzo = $indirizzo[0];
- $maschera = elaborate_mask($maschera);
- }
- $indirizzo = elaborate_ip($indirizzo);
- if (strpos($domanda, "Inserisci il primo") !== false) {
- // TIPO 1.1
- echo " <== TIPO 1.1";
- echo " *** ".net_to_raw((first_host($indirizzo, $maschera)))." ***";
- }
- elseif (strpos($domanda, "Inserisci l'ultimo") !== false) {
- // TIPO 1.2
- echo " <== TIPO 1.2";
- echo " *** ".net_to_raw(last_host($indirizzo, $maschera))." ***";
- }
- }
- else if (strpos($domanda, "Qual è la maschera corrispondente alla shorthand") !== false) {
- //TIPO 2
- echo " <== TIPO 2";
- $shorthand = explode("alla shorthand /", $domanda);
- $shorthand = explode("?", $shorthand[1]);
- $shorthand = $shorthand[0];
- echo " *** ".mask_to_raw(shorthand_to_mask($shorthand))." ***";
- }
- else if (strpos($domanda, "Inserisci l'indirizzo di broadcast dell'IP") !== false) {
- //TIPO 3
- echo " <== TIPO 3";
- if (strpos($domanda, "/") !== false) {
- $maschera = explode("/", $domanda);
- $maschera = explode(" ", $maschera[1]);
- $maschera = $maschera[0];
- $indirizzo = explode("dell'IP ", $domanda);
- $indirizzo = explode("/", $indirizzo[1]);
- $indirizzo = $indirizzo[0];
- $maschera = shorthand_to_mask($maschera);
- }
- elseif (strpos($domanda, "con maschera ") !== false) {
- $maschera = explode("con maschera ", $domanda);
- $maschera = $maschera[1];
- $indirizzo = explode("dell'IP ", $domanda);
- $indirizzo = explode(" ", $indirizzo[1]);
- $indirizzo = $indirizzo[0];
- $maschera = elaborate_mask($maschera);
- }
- $indirizzo = elaborate_ip($indirizzo);
- echo " *** ".net_to_raw(broadcast($indirizzo, $maschera))." ***";
- }
- else if (strpos($domanda, "Inserisci l'indirizzo della subnet alla quale appartiene l'indirizzo") !== false) {
- //TIPO 4
- echo " <== TIPO 4";
- if (strpos($domanda, "/") !== false) {
- $maschera = explode("/", $domanda);
- $maschera = explode(" ", $maschera[1]);
- $maschera = $maschera[0];
- $indirizzo = explode(" alla quale appartiene l'indirizzo ", $domanda);
- $indirizzo = explode("/", $indirizzo[1]);
- $indirizzo = $indirizzo[0];
- $maschera = shorthand_to_mask($maschera);
- }
- elseif (strpos($domanda, "con maschera ") !== false) {
- $maschera = explode("con maschera ", $domanda);
- $maschera = $maschera[1];
- $indirizzo = explode(" alla quale appartiene l'indirizzo ", $domanda);
- $indirizzo = explode(" ", $indirizzo[1]);
- $indirizzo = $indirizzo[0];
- $maschera = elaborate_mask($maschera);
- }
- $indirizzo = elaborate_ip($indirizzo);
- echo " *** ".net_to_raw(find_net($indirizzo, $maschera))." ***";
- }
- echo "\n";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement