1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
| <?php
set_time_limit(0);// to infinity for
$ch = curl_init();
$headers[] = "Accept: */*";
$headers[] = "Connection: Keep-Alive";
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'https://example.com/login/login.php');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$co = curl_exec($ch);
$doc = new DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTML($co);
# Parse the HTML
# The @ before the method call suppresses any warnings that
# loadHTML might throw because of invalid HTML in the page.
$xpath = new DOMXPath($doc);
$val1 = $xpath->query('//input[@name="_sid"]/@value')->item(0)->nodeValue;
echo $val1;
echo '<br/>';
$field['process'] = 'login';
$field['_sid'] = $val1;
$field['email'] = 'myemail@example.com';
$field['pwd'] = '123456';
$datafield = http_build_query($field);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $datafield);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, 'https://example.com/login/myapp.php?fg_id=5568094');
$cur = curl_exec($ch);
$do = new DOMDocument(); // New dom Doc to Get URL from disponible dates
libxml_use_internal_errors(true);
$do->loadHTML($cur);
# Parse the HTML
# The @ before the method call suppresses any warnings that
# loadHTML might throw because of invalid HTML in the page.
$xpath = new DOMXPath($do);
$onClickAttrNodeList = $xpath->query('//a[@class="dispo"]/@onclick'); //array contains URL
$array = array(); // CONVERT NODE LIST OBJECT TO ARRAY
foreach($onClickAttrNodeList as $node){
$array[] = $node;
}
$x=array();
foreach($array as $node) {
for($i = 0; $i < 10; ++$i) {
$x[] = $node->nodeValue; //PARSE ALL LINK AS TABLE
}
}
$randlink = array_rand($x, 10); //get gandom link
$link = $x[$randlink[0]];
echo '<br/>';
preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $link, $match); //Get URL from the last array
echo "<pre>";
$url = $match[0];
print_r($url[0]);
echo'<br/>';
parse_str( parse_url( $url[0], PHP_URL_QUERY), $arrayurl ); // GET parametres from the URL
var_dump($arrayurl);
$fieldbook['timestamp'] = $arrayurl[0];
$fieldbook['skey'] = $arrayurl[1];
$fieldbook['process'] = $arrayurl[2];
$fieldbook['what'] = $arrayurl[3];
$fieldbook['fg_id'] = $arrayurl[4];
$fieldbook['result'] = $arrayurl[5];
$fieldbook['issuer_view'] = $arrayurl[6];
$datafieldbook = http_build_query($fieldbook);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, 'https://example.com/login/action.php');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $datafieldbook);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, 'https://example.com/login/myapp.php?fg_id=5568094');
$book = curl_exec($ch);
echo'<br/>';
echo $book;
curl_close($ch);
?> |
Partager