2017-05-01 3 views
0

일부 작업을 자동화해야하므로 curl을 사용하여 내 은행 계좌에 로그인하고 로그인하십시오.curl + php를 사용하는 로그인 은행 계좌

필요한 로그인 전에 일부 처리를했는데 이번에는 로그인 할 수 없어서 뭔가를 놓쳤습니다.

내가

https://pi.bnpparibas.es/login/login/jsp/ 

그것은 전에 내가 그것을로드 및 비밀번호의 법전 편찬을 찾아 로그인을 수행하므로 가상 키보드가 로그인하려는 웹 사이트입니다. 그런 다음 게시물 데이터를 보내는 두 번째 컬 호출을 수행합니다. 여기에 모든 것이 괜찮이 시점에서

// 1# Show login page and get the preview info needed to login 

$ch = curl_init("https://pi.bnpparibas.es/login/login/jsp/"); 

if(!curl_setopt($ch, CURLOPT_VERBOSE, 1)) 
    echo "error 0"; 

$curl_log = fopen("C:\\wamp64\\www\\ccm_v2\\public\\bnp_info.txt", 'a'); 

if(!curl_setopt($ch, CURLOPT_STDERR, $curl_log)) 
    echo "error 1"; 

if(!curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true)) 
    echo "error 2"; 

if (!curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2)) 
    echo "error 3"; 

if (!curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/public/pibnpparibases.crt")) 
    echo "error 4"; 

if(!curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1)) 
    echo "error 5"; 

if(!curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt')) 
    echo "error 6"; 

if (!curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt')) 
    echo "error 7"; 

if(!curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1)) 
    echo "error 8"; 


$content = curl_exec($ch); 

curl_close($ch); 

을 사용하고 코드는 내가 $ 내용을 에코 만약 내가 https://pi.bnpparibas.es/login/login/jsp/

에 입력 할 때 내가 볼 때, 나는 이제에 정보를 수집하는 페이지를 볼 수 있습니다 나중에

// --> Pre login info from loaded page 

require('libs/simple_html_dom.php'); 

$html = str_get_html($content); 


$S = $html->find("input[name=S]")[0]->attr["value"]; 
$D = $html->find("input[name=D]")[0]->attr["value"]; 
$menu = $html->find("input[name=menu]")[0]->attr["value"]; 
$MAP_ID = $html->find("input[name=MAP_ID]")[0]->attr["value"]; 
$tds = $html->find("td"); 
$password = self::convertPassword($tds, "1111"); 
$action2 = $html->find("input[name=action2]")[0]->attr["value"]; 
$decode = $html->find("input[name=decode]")[0]->attr["value"]; 
$longMaxPass = $html->find("input[name=longMaxPass]")[0]->attr["value"]; 
$usuario = "1111"; 
$NavegadorUserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0"; 
$NavegadorIdioma = "es-ES"; 
$NavegadorPlataforma = "Win32"; 

// <-- Pre login info from loaded page 

가 지금은 로그인

// 2# Perform login 

$ch = curl_init("https://pi.bnpparibas.es/sd/?LOGUSUA=1111"); 

if(!curl_setopt($ch, CURLOPT_VERBOSE, 1)) 
    echo "error 00"; 

$curl_log = fopen("C:\\wamp64\\www\\ccm_v2\\public\\bnp_info.txt", 'a'); 

if(!curl_setopt($ch, CURLOPT_STDERR, $curl_log)) 
    echo "error 11"; 

if(!curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true)) 
    echo "error 22"; 

if (!curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2)) 
    echo "error 33"; 

if (!curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/public/pibnpparibases.crt")) 
    echo "error 44"; 

if(!curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1)) 
    echo "error 55"; 

if(!curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt')) 
    echo "error 66"; 

if (!curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt')) 
    echo "error 77"; 

if(!curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1)) 
    echo "error 88"; 

if (!curl_setopt($ch, CURLOPT_POST, 1)) 
    echo "error 99"; 

if(!curl_setopt($ch, CURLOPT_POSTFIELDS, urlencode('S='.$S.'&D='.$D.'&menu='.$menu.'&MAP_ID='.$MAP_ID 
    .'&password='.$password.'&action2='.$action2.'&decode='.$decode.'&longMaxPass='.$longMaxPass 
    .'&usuario='.$usuario.'&NavegadorUserAgent='.$NavegadorUserAgent.'&NavegadorIdioma='.$NavegadorIdioma 
    .'&NavegadorPlataforma='.$NavegadorPlataforma))) 
    echo "error 1010"; 

if(!curl_setopt($ch, CURLOPT_REFERER, "https://pi.bnpparibas.es/login/login/jsp/")) 
    echo "error 1111"; 


$content = curl_exec($ch); 

curl_close($ch); 

echo $content; 

은행 ALW을 수행 게시 ays가 나를 오류 페이지로 리디렉션합니다.

자격 증명이 잘못되었을 때 잘못된 사용자/암호 메시지가 표시 될 수도 없습니다. 여기

* Trying 213.229.172.71... 
* Connected to pi.bnpparibas.es (213.229.172.71) port 443 (#0) 
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH 
    * successfully set certificate verify locations: 
* CAfile: C:\wamp64\www\ccm_v2/public/pibnpparibases.crt 
    CApath: none 
    * SSL connection using TLSv1.2/AES256-SHA256 
    * Server certificate: 
* subject: 1.3.6.1.4.1.311.60.2.1.3=FR; businessCategory=Private Organization; serialNumber=662 042 449; C=FR; postalCode=75009; ST=Paris; L=Paris; street=16 Boulevard des Italiens; O=BNP PARIBAS SA; OU=Personal Investors; CN=pi.bnpparibas.es 
     * start date: Dec 14 00:00:00 2016 GMT 
    * expire date: Dec 19 23:59:59 2017 GMT 
    * subjectAltName: host "pi.bnpparibas.es" matched cert's "pi.bnpparibas.es" 
* issuer: C=US; O=Symantec Corporation; OU=Symantec Trust Network; CN=Symantec Class 3 EV SSL CA - G3 
* SSL certificate verify ok. 
> GET /login/login/jsp/ HTTP/1.1 
Host: pi.bnpparibas.es 
Accept: */* 
Cookie: f5_cspm=1234; COOKIE_POLICY="01/05/2017 00:47:44"; JSESSIONID=9D06248AF01C57E387F726F7CEDC149C; PPIPROD=503359680.36895.0000; TS014f87e8=018d99cefd100fdb6bee5ea7604f63eeee4c2d4013c10d01838421444d70debc87a852d80a49b1f602eccde97c7c1c94d5b156b11ea1ba7de04f2b7078da17444b3933fccb; TS014f87e8_28=01d6cc56d421387b13b7197bf8b5c4edb28b338ce03d62b538da95db1c4261855897ea3ea29a1569cf5b8f2c1a2b13cab36ce3e9c5; TS014f87e8_31=01d6cc56d4a69a129dc2d1f15974d95eb216d639e13d62b538da95db1c4261855897ea3ea22052d25f884ef3de2f77a089e5e526530dfee27323a92fa147b7ea0fc4436ee0; TS01520d8b=018d99cefd07df74bddebb07c77599422ee1589bc81f104a36d7b64a9c41b1f0a8a58eb1ee31e8a0f9050e5b83d65fdab80ed6c793229bff6c17955eaa1952b249449ca6a3; idioma=ES 

< HTTP/1.1 200 OK 
< X-Powered-By: ASP.NET 
< Pragma: no-cache 
< Expires: 0 
< Cache-Control: no-cache 
< Cache-Control: no-store 
< Content-Type: text/html;charset=ISO-8859-1 
< Date: Mon, 01 May 2017 08:36:56 GMT 
* Replaced cookie f5_cspm="1234" for domain pi.bnpparibas.es, path /login/login/jsp/, expire 0 
< Set-Cookie: f5_cspm=1234; 
* Replaced cookie TS014f87e8="018d99cefd813ec246858c85a31844c11ce4f7c414eaed583445c7f528eddc9bb97ff2423d66f9a83fd70f66e6fdfad1d25345a55aa94be64e79c031f221139c5dd41fa358" for domain pi.bnpparibas.es, path /, expire 0 
< Set-Cookie: TS014f87e8=018d99cefd813ec246858c85a31844c11ce4f7c414eaed583445c7f528eddc9bb97ff2423d66f9a83fd70f66e6fdfad1d25345a55aa94be64e79c031f221139c5dd41fa358; Path=/ 
* Replaced cookie TS014f87e8_31="01d6cc56d4a69a129dc2d1f15974d95eb216d639e13d62b538da95db1c4261855897ea3ea22052d25f884ef3de2f77a089e5e526530dfee27323a92fa147b7ea0fc4436ee0" for domain pi.bnpparibas.es, path /, expire 0 
< Set-Cookie: TS014f87e8_31=01d6cc56d4a69a129dc2d1f15974d95eb216d639e13d62b538da95db1c4261855897ea3ea22052d25f884ef3de2f77a089e5e526530dfee27323a92fa147b7ea0fc4436ee0; Path=/ 
< Transfer-Encoding: chunked 
< 
* Connection #0 to host pi.bnpparibas.es left intact 
* Trying 213.229.172.71... 
* Connected to pi.bnpparibas.es (213.229.172.71) port 443 (#0) 
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH 
* successfully set certificate verify locations: 
* CAfile: C:\wamp64\www\ccm_v2/public/pibnpparibases.crt 
    CApath: none 
* SSL connection using TLSv1.2/AES256-SHA256 
* Server certificate: 
* subject: 1.3.6.1.4.1.311.60.2.1.3=FR; businessCategory=Private Organization; serialNumber=662 042 449; C=FR; postalCode=75009; ST=Paris; L=Paris; street=16 Boulevard des Italiens; O=BNP PARIBAS SA; OU=Personal Investors; CN=pi.bnpparibas.es 
* start date: Dec 14 00:00:00 2016 GMT 
* expire date: Dec 19 23:59:59 2017 GMT 
* subjectAltName: host "pi.bnpparibas.es" matched cert's "pi.bnpparibas.es" 
    * issuer: C=US; O=Symantec Corporation; OU=Symantec Trust Network; CN=Symantec Class 3 EV SSL CA - G3 
    * SSL certificate verify ok. 
> POST /sd/?LOGUSUA=1111 HTTP/1.1 
Host: pi.bnpparibas.es 
Accept: */* 
Referer: https://pi.bnpparibas.es/login/login/jsp/ 
Cookie: COOKIE_POLICY="01/05/2017 00:47:44"; JSESSIONID=9D06248AF01C57E387F726F7CEDC149C; PPIPROD=503359680.36895.0000; TS014f87e8=018d99cefd813ec246858c85a31844c11ce4f7c414eaed583445c7f528eddc9bb97ff2423d66f9a83fd70f66e6fdfad1d25345a55aa94be64e79c031f221139c5dd41fa358; TS014f87e8_28=01d6cc56d421387b13b7197bf8b5c4edb28b338ce03d62b538da95db1c4261855897ea3ea29a1569cf5b8f2c1a2b13cab36ce3e9c5; TS014f87e8_31=01d6cc56d4a69a129dc2d1f15974d95eb216d639e13d62b538da95db1c4261855897ea3ea22052d25f884ef3de2f77a089e5e526530dfee27323a92fa147b7ea0fc4436ee0; TS01520d8b=018d99cefd07df74bddebb07c77599422ee1589bc81f104a36d7b64a9c41b1f0a8a58eb1ee31e8a0f9050e5b83d65fdab80ed6c793229bff6c17955eaa1952b249449ca6a3; idioma=ES 
Content-Length: 407 
Content-Type: application/x-www-form-urlencoded 

* upload completely sent off: 407 out of 407 bytes 
< HTTP/1.1 302 Movido tempor?lmente 
< X-Powered-By: ASP.NET 
< Location: https://pi.bnpparibas.es/navegacion/error.jsp 
< Content-Length: 0 
< Date: Mon, 01 May 2017 08:36:56 GMT 
* Replaced cookie TS014f87e8="018d99cefd813ec246858c85a31844c11ce4f7c414eaed583445c7f528eddc9bb97ff2423d66f9a83fd70f66e6fdfad1d25345a55aa94be64e79c031f221139c5dd41fa358" for domain pi.bnpparibas.es, path /, expire 0 
< Set-Cookie: TS014f87e8=018d99cefd813ec246858c85a31844c11ce4f7c414eaed583445c7f528eddc9bb97ff2423d66f9a83fd70f66e6fdfad1d25345a55aa94be64e79c031f221139c5dd41fa358; Path=/ 
< 
* Connection #0 to host pi.bnpparibas.es left intact 
* Issue another request to this URL: 'https://pi.bnpparibas.es/navegacion/error.jsp' 
* Switch from POST to GET 
* Found bundle for host pi.bnpparibas.es: 0x2579b630640 [can pipeline] 
* Re-using existing connection! (#0) with host pi.bnpparibas.es 
* Connected to pi.bnpparibas.es (213.229.172.71) port 443 (#0) 
> GET /navegacion/error.jsp HTTP/1.1 
Host: pi.bnpparibas.es 
Accept: */* 
Referer: https://pi.bnpparibas.es/login/login/jsp/ 
Cookie: f5_cspm=1234; COOKIE_POLICY="01/05/2017 00:47:44"; JSESSIONID=9D06248AF01C57E387F726F7CEDC149C; PPIPROD=503359680.36895.0000; TS014f87e8=018d99cefd813ec246858c85a31844c11ce4f7c414eaed583445c7f528eddc9bb97ff2423d66f9a83fd70f66e6fdfad1d25345a55aa94be64e79c031f221139c5dd41fa358; TS014f87e8_28=01d6cc56d421387b13b7197bf8b5c4edb28b338ce03d62b538da95db1c4261855897ea3ea29a1569cf5b8f2c1a2b13cab36ce3e9c5; TS014f87e8_31=01d6cc56d4a69a129dc2d1f15974d95eb216d639e13d62b538da95db1c4261855897ea3ea22052d25f884ef3de2f77a089e5e526530dfee27323a92fa147b7ea0fc4436ee0; TS01520d8b=018d99cefd07df74bddebb07c77599422ee1589bc81f104a36d7b64a9c41b1f0a8a58eb1ee31e8a0f9050e5b83d65fdab80ed6c793229bff6c17955eaa1952b249449ca6a3; idioma=ES 

     < HTTP/1.1 200 OK 
    < X-Powered-By: ASP.NET 
    < Content-Type: text/html;charset=ISO-8859-1 
     < Date: Mon, 01 May 2017 08:36:56 GMT 
    * Replaced cookie f5_cspm="1234" for domain pi.bnpparibas.es, path /navegacion/, expire 0 
    < Set-Cookie: f5_cspm=1234; 
     * Replaced cookie TS014f87e8="018d99cefd813ec246858c85a31844c11ce4f7c414eaed583445c7f528eddc9bb97ff2423d66f9a83fd70f66e6fdfad1d25345a55aa94be64e79c031f221139c5dd41fa358" for domain pi.bnpparibas.es, path /, expire 0 
     < Set-Cookie: TS014f87e8=018d99cefd813ec246858c85a31844c11ce4f7c414eaed583445c7f528eddc9bb97ff2423d66f9a83fd70f66e6fdfad1d25345a55aa94be64e79c031f221139c5dd41fa358; Path=/ 
* Replaced cookie TS014f87e8_31="01d6cc56d4a69a129dc2d1f15974d95eb216d639e13d62b538da95db1c4261855897ea3ea22052d25f884ef3de2f77a089e5e526530dfee27323a92fa147b7ea0fc4436ee0" for domain pi.bnpparibas.es, path /, expire 0 
      < Set-Cookie: TS014f87e8_31=01d6cc56d4a69a129dc2d1f15974d95eb216d639e13d62b538da95db1c4261855897ea3ea22052d25f884ef3de2f77a089e5e526530dfee27323a92fa147b7ea0fc4436ee0; Path=/ 
< Transfer-Encoding: chunked 
       < 
* Connection #0 to host pi.bnpparibas.es left intact 

이 희망 너희들이 날 로그의이 종류를 수행하고 난 무엇을 볼 수있는 것보다 더 많은 경험을 가지고있는 cookie.txt 정보

# Netscape HTTP Cookie File 
# https://curl.haxx.se/docs/http-cookies.html 
# This file was generated by libcurl! Edit at your own risk. 

# Netscape HTTP Cookie File 
# https://curl.haxx.se/docs/http-cookies.html 
# This file was generated by libcurl! Edit at your own risk. 

     pi.bnpparibas.es FALSE / FALSE 0 PPIPROD 503359680.36895.0000 
#HttpOnly_pi.bnpparibas.es FALSE / FALSE 0 JSESSIONID 9D06248AF01C57E387F726F7CEDC149C 
    .pi.bnpparibas.es TRUE / FALSE 2483592464 COOKIE_POLICY "01/05/2017 00:47:44" 
pi.bnpparibas.es FALSE /navegacion/ FALSE 0 f5_cspm 1234 
pi.bnpparibas.es FALSE / FALSE 0 TS014f87e8 018d99cefd813ec246858c85a31844c11ce4f7c414eaed583445c7f528eddc9bb97ff2423d66f9a83fd70f66e6fdfad1d25345a55aa94be64e79c031f221139c5dd41fa358 
    .pi.bnpparibas.es TRUE / FALSE 0 TS01520d8b 018d99cefd07df74bddebb07c77599422ee1589bc81f104a36d7b64a9c41b1f0a8a58eb1ee31e8a0f9050e5b83d65fdab80ed6c793229bff6c17955eaa1952b249449ca6a3 
pi.bnpparibas.es FALSE / FALSE 0 TS014f87e8_31 01d6cc56d4a69a129dc2d1f15974d95eb216d639e13d62b538da95db1c4261855897ea3ea22052d25f884ef3de2f77a089e5e526530dfee27323a92fa147b7ea0fc4436ee0 
pi.bnpparibas.es FALSE / FALSE 0 TS014f87e8_28 01d6cc56d421387b13b7197bf8b5c4edb28b338ce03d62b538da95db1c4261855897ea3ea29a1569cf5b8f2c1a2b13cab36ce3e9c5 
    .pi.bnpparibas.es TRUE / FALSE 2483592594 idioma ES 
pi.bnpparibas.es FALSE /login/login/jsp/ FALSE 0 f5_cspm 1234 

그리고 여기 CURLOPT_STDERR 출력입니다 있어야 할 곳에 없는.

미리 감사드립니다.

답변

0

내가 발견 한 것이 발견되었습니다. 함수 http_build_query를 호출해야했습니다.

$fields = array("S" => $S, "D" => $D, "menu" => $menu, "MAP_ID" => $MAP_ID, 
"password" => $password, "action2" => $action2, "decode" => $decode, "longMaxPass" => $longMaxPass, 
"usuario" => $usuario, "NavegadorUserAgent" => $NavegadorUserAgent, "NavegadorIdioma" => $NavegadorIdioma, 
"NavegadorPlataforma" => $NavegadorPlataforma); 

$fields_string = http_build_query($fields); 

if(!curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string)) 
    echo "error 1010";