2017-05-01 13 views
0

Ich benutze Curl zu laden und loggen in meinem Bankkonto, weil ich einige Aufgabe automatisieren muss.Login Bankkonto mit curl + php

Ich habe ein wenig Verschrottung gemacht, bevor das Login erforderlich war, aber ich muss dieses Mal etwas verpassen, weil ich mich nicht einloggen kann.

Dies ist die Website I

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

Es verfügt über eine virtuelle Tastatur anmelden möge so vor der Login ich es laden durchführen und die Kodifizierung des Passwortes finden. Dann mache ich einen zweiten Anruf, bei dem ich die Postdaten sende. Hier ist der Code ich benutze

// 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); 

An dieser Stelle alles in Ordnung ist, wenn ich $ content echo kann ich die Seite sehen, wie ich sehe, wenn ich eintrete in https://pi.bnpparibas.es/login/login/jsp/

Jetzt sammle ich die Informationen zu poste es später

// --> 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 

Jetzt habe ich den Login-

// 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; 

die Bank ALW durchführen ays leitet mich auf die Fehlerseite

https://pi.bnpparibas.es/navegacion/error.jsp 

ich nicht einmal die falsche Benutzer/Passwort-Nachricht erhalten können, die oben zeigt, wenn Sie Ihre Anmeldeinformationen sind falsch. Hier

ist die cookie.txt info

# 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 

Und hier die CURLOPT_STDERR Ausgang

* 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 

Hoffentlich euch mehr Erfahrung haben als ich diese Art der Protokollierung durchführen und sehen, was ich bin fehlt.

Vielen Dank im Voraus

Antwort

0

Gefunden, was mir fehlte. Ich musste die Funktion 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"; 
aufrufen