ANTICHAT — форум по информационной безопасности, OSINT и технологиям
ANTICHAT — русскоязычное сообщество по безопасности, OSINT и программированию.
Форум ранее работал на доменах antichat.ru, antichat.com и antichat.club,
и теперь снова доступен на новом адресе —
forum.antichat.xyz.
Форум восстановлен и продолжает развитие: доступны архивные темы, добавляются новые обсуждения и материалы.
⚠️ Старые аккаунты восстановить невозможно — необходимо зарегистрироваться заново.
 |

13.04.2016, 10:26
|
|
Новичок
Регистрация: 24.11.2015
Сообщений: 17
Провел на форуме: 5795
Репутация:
0
|
|
День добрый,использую класс для работы с curl
Код:
ch = curl_init();
$this->set_httpheader(array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8','Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3','Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7'));
}
function get ($url){
$this->url = $url;
return $this->exec();
}
function post ($url, $postparams, $enctype = false){
$this->url = $url;
if (!$enctype) {
$this->postparams = $postparams;
}
else {
$this->postparams = array ();
$params = explode("&", $postparams);
for($i = 0; $i postparams[$name] = $value;
}
}
return $this->exec();
}
function set_httpget ($httpget){
$this->httpget = $httpget;
}
function set_referer ($referer){
$this->referer = $referer;
}
function set_autoreferer ($autoreferer){
$this->autoreferer = $autoreferer;
}
function set_useragent ($agent){
$this->agent = $agent;
}
function set_cookie (){
preg_match_all('/Set-Cookie: (.*?)=(.*?);/i', $this->head, $matches, PREG_SET_ORDER);
for ($i = 0; $i delete_cookie($matches[$i][1]);
} else {
$this->cookie[$matches[$i][1]] = $matches[$i][2];
}
}
}
function add_cookie ($cookie){
foreach ($cookie as $name => $value) {
$this->cookie[$name] = $value;
}
}
function delete_cookie ($name){
if (isset($this->cookie[$name]))
unset($this->cookie[$name]);
}
function get_cookie (){
return $this->cookie;
}
function clear_cookie (){
$this->cookie = array ();
}
function set_httpheader ($httpheader){
$this->httpheader = $httpheader;
}
function clear_httpheader (){
$this->httpheader = array ();
}
function set_head ($head){
$this->head = $head;
}
function set_encoding ($encoding){
$this->encoding = $encoding;
}
function set_interface ($interface){
$this->interface = $interface;
}
function set_writeheader ($writeheader){
$this->writeheader = $writeheader;
}
function set_followlocation ($followlocation){
$this->followlocation = $followlocation;
}
function set_returntransfer ($returntransfer){
$this->returntransfer = $returntransfer;
}
function set_ssl_verifypeer ($ssl_verifypeer){
$this->ssl_verifypeer = $ssl_verifypeer;
}
function set_ssl_verifyhost ($ssl_verifyhost){
$this->ssl_verifyhost = $ssl_verifyhost;
}
function set_sslcert ($sslcert) {
$this->sslcert = $sslcert;
}
function set_sslkey ($sslkey) {
$this->sslkey = $sslkey;
}
function set_cainfo ($cainfo) {
$this->cainfo = $cainfo;
}
function set_timeout ($timeout){
$this->timeout = $timeout;
}
function set_connect_time ($connect_time){
$this->connect_time = $connect_time;
}
function set_cookiefile ($cookiefile){
$this->cookiefile = $cookiefile;
}
function set_proxy ($proxy){
$this->proxy = $proxy;
}
function set_proxy_auth ($proxy_user_data){
$this->proxy_user_data = $proxy_user_data;
}
function set_verbose ($verbose){
$this->verbose = $verbose;
}
function get_error (){
return curl_errno($this->ch);
}
function get_location (){
$result = '';
if (preg_match("/Location: (.*?)\r\n/is", $this->head, $matches)) {
$result = end($matches);
}
return $result;
}
function get_http_state (){
if (curl_getinfo($this->ch, CURLINFO_HTTP_CODE) == 200) {
return true;
} else {
return false;
}
}
function get_speed_download (){
return curl_getinfo($this->ch, CURLINFO_SPEED_DOWNLOAD);
}
function get_content_type (){
return curl_getinfo($this->ch, CURLINFO_CONTENT_TYPE);
}
function get_url (){
return curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL);
}
function join_cookie() {
$tcookie = array ();
foreach ($this->cookie as $key => $value)
$tcookie[] = "$key=$value";
return join('; ', $tcookie);
}
function exec (){
curl_setopt($this->ch, CURLOPT_USERAGENT, $this->agent);
curl_setopt($this->ch, CURLOPT_AUTOREFERER, $this->autoreferer);
curl_setopt($this->ch, CURLOPT_ENCODING, $this->encoding);
curl_setopt($this->ch, CURLOPT_URL, $this->url);
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION , $this->followlocation);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER,$this->returntransfer);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, $this->ssl_verifyhost);
curl_setopt($this->ch, CURLOPT_HEADER, 1);
curl_setopt($this->ch, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, $this->connect_time);
curl_setopt($this->ch, CURLOPT_VERBOSE, $this->verbose);
curl_setopt($this->ch, CURLOPT_POST, 0);
if ($this->referer)
curl_setopt($this->ch, CURLOPT_REFERER, $this->referer);
if ($this->interface)
curl_setopt($this->ch, CURLOPT_INTERFACE, $this->interface);
if ($this->httpget)
curl_setopt($this->ch, CURLOPT_HTTPGET, $this->httpget);
if ($this->writeheader != '')
curl_setopt($this->ch, CURLOPT_WRITEHEADER, $this->writeheader);
if ($this->postparams) {
curl_setopt($this->ch, CURLOPT_POST, 1);
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->postparams);
}
if ($this->proxy)
curl_setopt($this->ch, CURLOPT_PROXY, $this->proxy);
if ($this->proxy_user_data)
curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $this->proxy_user_data);
if ($this->cookie)
curl_setopt($this->ch, CURLOPT_COOKIE, $this->join_cookie());
if (count($this->httpheader))
curl_setopt($this->ch, CURLOPT_HTTPHEADER, $this->httpheader);
if ($this->sslcert)
curl_setopt($this->ch, CURLOPT_SSLCERT, $this->sslcert);
if ($this->sslkey)
curl_setopt($this->ch, CURLOPT_SSLKEY, $this->sslkey);
if ($this->cainfo)
curl_setopt($this->ch, CURLOPT_CAINFO, $this->cainfo);
if ($this->cookiefile) {
curl_setopt($this->ch, CURLOPT_COOKIEFILE, $this->cookiefile);
curl_setopt($this->ch, CURLOPT_COOKIEJAR, $this->cookiefile);
}
$response = curl_exec($this->ch);
$this->set_head(substr($response, 0, curl_getinfo($this->ch, CURLINFO_HEADER_SIZE)));
$response = substr($response, curl_getinfo($this->ch, CURLINFO_HEADER_SIZE));
$this->set_cookie();
$this->postparams = array ();
return $response;
}
function __destruct (){
curl_close($this->ch);
}
}
?>
хочу сделать авторизацию на один сайт,но сами параметры не передаются,авторизация через multipart/form-data
при коде
Код:
get('https://letyshops.ru/user');
$pos = strpos($send,'logout');
if ($pos === false) {
$postdata=array('mail'=>'login','pass'=>'password','op'=>'');
$send=$curl->post('https://letyshops.ru/ajax/login2/ajax',$postdata);
echo 'не найдено';
print_r($send);
} else {
echo 'найдено';
}
передаётся только
Код:
POST /ajax/login2/ajax HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:23.0) Gecko/20100101 Firefox/23.0
Host: letyshops.ru
Accept-Encoding: gzip,deflate
Cookie: uid=0; old_session=MZVsUw5k9nkxKB6gKSKi-Mm8ZyM5TX2z1KeAtFLIGbA; bui=0; SSESS5288efca5cc8ebc9d12b8cd700a1566b=MZVsUw5k9nkxKB6gKSKi-Mm8ZyM5TX2z1KeAtFLIGbA
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7
Content-Length: 344
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----------------------------209c8d3994a2
весь вечер бьюсь,с другими сайтами всё нормально
|
|
|

13.04.2016, 11:02
|
|
Постоянный
Регистрация: 31.12.2011
Сообщений: 362
Провел на форуме: 137056
Репутация:
11
|
|
Сообщение от Prog-t
↑
День добрый,использую класс для работы с curl
весь вечер бьюсь,с другими сайтами всё нормально
Прогнал через фидлер - все работает, ничего не менял в коде.
|
|
|

13.04.2016, 13:40
|
|
Новичок
Регистрация: 24.11.2015
Сообщений: 17
Провел на форуме: 5795
Репутация:
0
|
|
Сообщение от blackbox
↑
Прогнал через фидлер - все работает, ничего не менял в коде.
то есть и параметры передаются?

|
|
|

13.04.2016, 14:53
|
|
Постоянный
Регистрация: 31.12.2011
Сообщений: 362
Провел на форуме: 137056
Репутация:
11
|
|
Сообщение от Prog-t
↑
то есть и параметры передаются?
да
|
|
|
|
 |
|
Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
|
|
|
|