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 142 143 144 145 146 147 148 149 150
| <?php
set_time_limit(0);// to infinity for
$ch = curl_init();
$url1 = 'https://fr.example.com/tn/TUN/login.php';
$url2 = 'https://fr.example.com/tn/TUN/action.php';
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url1);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'C:\AppServ\www\curl\cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'C:\AppServ\www\curl\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_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'C:\AppServ\www\curl\cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'C:\AppServ\www\curl\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://fr.example.com/tn/TUN/myapp.php?fg_id=5622739');
$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
preg_match('#var secret_id = (.*)\;#Us', $cur, $out); // Pregmatch Secret ID from javascript CODE
$secret_id = json_decode($out[1]); // Get secret ID
$array = array(); // CONVERT NODE LIST OBJECT TO ARRAY
foreach($onClickAttrNodeList as $node){
$array[] = $node;
}
$x=array();
foreach($array as $node) {
for($i = 0; $i < 20; ++$i) {
$x[] = $node->nodeValue; //PARSE ALL LINK AS TABLE
}
}
$randlink = array_rand($x, 20); //get gandom link
$link = $x[$randlink[0]];
echo '<br/>';
echo '<br/>';
echo $secret_id;
echo '<br/>';
echo '<br/>';
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 ); // avoir les parametres pour poster
var_dump($arrayurl);
echo'<br/>';
echo'<br/>';
echo $arrayurl[fg_id];
echo $arrayurl[fg_id];
echo'<br/>';
echo'<br/>';
// dans cette partie du code je n arrive pas a faire le POST
$fieldbook['f_id'] = '';
$fieldbook['fg_id'] = $arrayurl[fg_id];
$fieldbook['what'] = $arrayurl[what];
$fieldbook['result'] = $arrayurl[result];
$fieldbook['as_u_id'] = '';
$fieldbook['_sid'] = $secret_id;
$fieldbook['timestamp'] = $arrayurl[timestamp];
$fieldbook['skey'] = $arrayurl[skey];
$fieldbook['process'] = $arrayurl[process];
$fieldbook['reloader_timestamp'] = '1540935836428';
$bookrdv = http_build_query($fieldbook);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url2);
curl_setopt($ch, CURLOPT_REFERER, "https://fr.example.com/tn/TUN/myapp.php?fg_id=5622739");
curl_setopt($ch, CURLOPT_COOKIEFILE, 'C:\AppServ\www\curl\cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'C:\AppServ\www\curl\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, $bookrdv);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, 'https://fr.example.com/tn/TUN/myapp.php?fg_id=5622739');
$book = curl_exec($ch);
echo $book;
curl_close($ch);
?> |
Partager