Logowanie do banku

0

Witam,

Od pewnego czasu próbuje napisać program logujący się do mojego konta w banku i metodą parsowania pobrania informacji o historii przelewów.
Logowanie do banku odbywa się dwuetapowo:

Etap 1 - wysłanie loginu:

<form name="LoginAliasForm" method="POST" action="/hades/do/LoginAlias" onsubmit="return submitFormByEnter(this);" style="padding-top: 30px;" target="_top"><div><input type="hidden" name="org.apache.struts.taglib.html.TOKEN" value="5397281cc8648a839f07284960de9da1"></div>
				<table id="contentTable" class="tbl output" cellspacing="0" style="width: 330px; border-bottom: none;">
				<tbody>
					<tr class="strong">
						<td id="idContent" style="width: 76px; text-align: right; padding-right: 7px;">Identyfikator</td>
        				<td>
        				<div style="display: inline; vertical-align:middle;">
        					<input id="inputContent" type="text" name="p_alias" style="width:200px; height: 20px; vertical-align: middle;" tabindex="1" autocomplete="off" maxlength="20">
							<div id="login" class="help-ico" style="">&nbsp;</div>
							<div dojoType="cib.Tooltip" connectId="login" style="display: none">Jako identyfikator wprowadź numer kartoteki klienta CIF.<br/> Numer ten znajdziesz na dokumentach i umowach otrzymanych z Banku podczas zakładania rachunku.</div>
						</div>
        				</td>
        			</tr>
        			<tr>
        				<td colspan="2">&nbsp;</td>
        			</tr>
        			<tr>
						<td colspan="2">
        				<div class="toolbar" id="buttonTr">
        				
        				<a href="#" class="button" style="margin-right: 33px; display: inline;" onclick="submitForm(document.forms['LoginAliasForm']);" >		
        				<span tabindex="2">Dalej</span></a>
        				</div>
       					</td>
       				</tr>
        		</tbody>
        		</table>	
        		</form>

Zatem wysyłam do strony: "https://xxxxxxx.pl/hades/do/BANKLOGIN" metodą POST:

org.apache.struts.taglib.html.TOKEN=5397281cc8648a839f07284960de9da1&p_alias=12345678900987654321

W odpowiedzi otrzymuję kod źródłowy strony z prośbą o podanie hasła.

Etap 2 - wysyłanie hasła:

<form name="MaskLoginForm" method="POST" action="/hades/do/MaskLogin" style="height: 185px;"><div><input type="hidden" name="org.apache.struts.taglib.html.TOKEN" value="206241eef26f89d362b9c30e29194fa9"></div>
				<input type="hidden" name="p_mask" value="ffe5ffff16fff41848d160954dff">
				<input type="hidden" name="p_passmasked_bis" value="">
					<META http-equiv=Content-type content="text/html; charset=UTF-8"><META http-equiv=Expires content=-1>						
				<div style="float: left; display: inline; padding-top: 35px; padding-left: 40px;">
					<img id="pshImg" width="125" height="80"
					 onerror="javascript:loadPhsImgOnError();";
					 onload="this.style.visibility=''"
				 	title="Name" style="border: none;visibility:hidden"/>
				 	
				</div>

				<div id="contentTextDiv" style="float: left; display: inline; width: 0px; margin-left: 40px; padding-top: 15px;">
    			<table class="tbl output" cellspacing="0" style="text-align: center; border-bottom: none; width: 543px">
    			<colgroup>
					<col style="width: 15%;"/>
					<col />
				</colgroup>
    			<tbody>
    			<tr>
        			<td colspan="2"></td>
    			</tr>
    			<tr style="height: 30px">
    				<td class="strong">Identyfikator</td>
    				<td>12345678900987654321</td>
    			</tr>
    			<tr>
    				<td  class="strong">Hasło</td>
    				<td>
						<div style="display: inline"><input type="password" id="PASSFIELD1" name="PASSFIELD1" class="logField" AUTOCOMPLETE="off" maxlength="1" onKeyUp="next(this, event);"><input type="password" id="PASSFIELD2" name="PASSFIELD2" class="logFieldInactive" readonly="true" AUTOCOMPLETE="off" maxlength="1" value="&#183;"><input type="password" id="PASSFIELD3" name="PASSFIELD3" class="logField" AUTOCOMPLETE="off" maxlength="1" onKeyUp="next(this, event);"><input type="password" id="PASSFIELD4" name="PASSFIELD4" class="logField" AUTOCOMPLETE="off" maxlength="1" onKeyUp="next(this, event);"><input type="password" id="PASSFIELD5" name="PASSFIELD5" class="logFieldInactive" readonly="true" AUTOCOMPLETE="off" maxlength="1" value="&#183;"><input type="password" id="PASSFIELD6" name="PASSFIELD6" class="logField" AUTOCOMPLETE="off" maxlength="1" onKeyUp="next(this, event);"><input type="password" id="PASSFIELD7" name="PASSFIELD7" class="logFieldInactive" readonly="true" AUTOCOMPLETE="off" maxlength="1" value="&#183;"><input type="password" id="PASSFIELD8" name="PASSFIELD8" class="logFieldInactive" readonly="true" AUTOCOMPLETE="off" maxlength="1" value="&#183;"><input type="password" id="PASSFIELD9" name="PASSFIELD9" class="logFieldInactive" readonly="true" AUTOCOMPLETE="off" maxlength="1" value="&#183;"><input type="password" id="PASSFIELD10" name="PASSFIELD10" class="logFieldInactive" readonly="true" AUTOCOMPLETE="off" maxlength="1" value="&#183;"><input type="password" id="PASSFIELD11" name="PASSFIELD11" class="logFieldInactive" readonly="true" AUTOCOMPLETE="off" maxlength="1" value="&#183;"><input type="password" id="PASSFIELD12" name="PASSFIELD12" class="logFieldInactive" readonly="true" AUTOCOMPLETE="off" maxlength="1" value="&#183;"><input type="password" id="PASSFIELD13" name="PASSFIELD13" class="logFieldInactive" readonly="true" AUTOCOMPLETE="off" maxlength="1" value="&#183;"><input type="password" id="PASSFIELD14" name="PASSFIELD14" class="logField" AUTOCOMPLETE="off" maxlength="1" onKeyUp="next(this, event);"><a href="javascript:openMaskPopup('../ver/pl/maskKeyboard.html','keyb', 270, 50,'no','no')" style="display:inline;padding-bottom:3px;vertical-align:middle;" class="icon"><img src="../img/klawiatura.gif" alt="" width="20" height="16" border="0" title=""></a><div id="login" class="help-ico" style="padding-left: 6px; vertical-align: middle;">&nbsp;</div><div dojoType="cib.Tooltip" connectId="login" style="display: none">Podczas logowania w kolejne aktywne pola wpisz odpowiadające im znaki z hasła<br/>np. jeśli Twoje hasło to "Name", a aktywne jest pierwsze i piąte pole<br/> to należy wpisać litery: "A" oraz "r".<br/>Ze względów bezpieczeństwa system wymaga wprowadzenia wybranych znaków z hasła,<br/> w związku z tym nawet jeśli ktoś podejrzy wpisywane przez Ciebie znaki<br/> i tak nie uda mu się zalogować na Twoje konto,<br/> bo system za każdym razem wymaga innych znaków.<br/>Zalecamy korzystanie z klawiatury ekranowej podczas wpisywania hasła.</div><br /><div class="logFieldNumber1"><label for="PASSFIELD1">1</label></div><div class="logFieldNumber1"><label for="PASSFIELD2">2</label></div><div class="logFieldNumber1"><label for="PASSFIELD3">3</label></div><div class="logFieldNumber1"><label for="PASSFIELD4">4</label></div><div class="logFieldNumber1"><label for="PASSFIELD5">5</label></div><div class="logFieldNumber1"><label for="PASSFIELD6">6</label></div><div class="logFieldNumber1"><label for="PASSFIELD7">7</label></div><div class="logFieldNumber1"><label for="PASSFIELD8">8</label></div><div class="logFieldNumber1"><label for="PASSFIELD9">9</label></div><div class="logFieldNumber2"><label for="PASSFIELD10">10</label></div><div class="logFieldNumber2"><label for="PASSFIELD11">11</label></div><div class="logFieldNumber2"><label for="PASSFIELD12">12</label></div><div class="logFieldNumber2"><label for="PASSFIELD13">13</label></div><div class="logFieldNumber2"><label for="PASSFIELD14">14</label></div></div>
    				</td>
    			</tr>
    			<tr>
        			<td colspan="2"><div>&nbsp;</div></td>
    			</tr>
        		<tr>
					<td colspan="2">
        				<div class="toolbar">
										<a href="/hades/do/Login" style="float: left">
										    <span tabindex="1">Powrót</span>
										 </a>
	        				<a href="http://xxxxxxx.pl/pl/o_banku/pytania_i_odpowiedzi/bankowosc_elektroniczna/bankowosc_internetowa/co_mam_zrobic_jesli_zapomnialem" target="_blank" style="float: left">
	        				<span tabindex="2">Zapomniałem hasła</span></a>
	        				<a href="#" class="button" onclick="submitForm(document.forms['MaskLoginForm']);" id="submitButton"  style="margin-right: 100px;">
	        				<span tabindex="3">Zaloguj</span></a>
	        				<a href="#" class="button cancel" onclick="resetForm(document.forms['MaskLoginForm']);" style="margin-right: 5px;">
	        				<span tabindex="2">Wyczyść</span></a>
        				</div>
       				</td>
       			</tr>
       			</tbody>
    			</table>
    			</div>
    			<div style="clear: both"></div>
    			</form>

W odpowiedzi POST do strony: "https://xxxxxxxx.pl/hades/do/MaskLogin" wysyłam:

org.apache.struts.taglib.html.TOKEN=e6e9720036c7cf00e698c81c4cb48f9c&p_mask=ff4fffffc287b680ffffffc0ff&p_passmasked_bis=&PASSFIELD1=X&PASSFIELD2=&PASSFIELD3=X&PASSFIELD4=X&PASSFIELD5=&PASSFIELD6=&PASSFIELD7=&PASSFIELD8=&PASSFIELD9=X&PASSFIELD10=X&PASSFIELD11=X&PASSFIELD12=&PASSFIELD13=X

Powyżej odpowiedź z innego zapytania stąd różnice. Próbowałem również w wyłączone pola wpisywać: "·".

Problem polega na tym, że w odpowiedzi na powyższą odpowiedź otrzymuję ponowną prośbę o hasło. Po zalogowaniu się do banku z pomocą przeglądarki nie ma informacji o nieudanej próbie logowania (nie ma żadnej informacji).

Moje pytanie brzmi, co robię źle?

Pozdrawiam,
Hiob.

0

Co robisz źle? Nie napisałeś do banku z pytaniem, czy udostępniają jakieś API, bo chciałbyś zrobić to i to. A zamiast tego próbujesz sam coś "hackować".

0

To śmierdzi phisingiem.

0

Być może brakuje ci czegoś w headerze, być może jakiegoś innego parametru.
Prawdopodobnie bank się zabezpiecza aby tego typu rzeczy nie robić.

0

Witam,

Juhas:
Niestety mój bank nie udostępnia darmowego API dla aplikacji zewnętrznych.

Error91:
Myślisz, że szukał bym pomocy na otwartym i popularnym forum? Raczej chcę napisać prostą aplikację, która ułatwi mojej żonie hobbystyczną pracę.

Dam1an:
Tak konstruuję nagłówek:

ASCIIEncoding encoding = new ASCIIEncoding();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
String result = "";

byte[] dataBytes = encoding.GetBytes(data);

request.Method = "POST";
request.AllowAutoRedirect = false;
request.ContentLength = data.Length;
request.ContentType = "application/x-www-form-urlencoded";

if (this.Cookie != null)
    request.CookieContainer = this.Cookie;

request.Credentials = CredentialCache.DefaultCredentials;
request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version10;
request.Referer = url;
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36 OPR/45.0.2552.812";

using (Stream requestStream = request.GetRequestStream())
{
    requestStream.Write(dataBytes, 0, dataBytes.Length);
}

using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
    using (StreamReader responseStream = new StreamReader(response.GetResponseStream()))
    {
        foreach (Cookie cookie in response.Cookies)
        {
            this.Cookie.Add(cookie);
        }

        result = responseStream.ReadToEnd();
    }
}

return (result);

I na koniec:

public CookieContainer Cookie;

Może ktoś znajdzie jakiś błąd?

0
error91 napisał(a):

To śmierdzi phisingiem.

Jak usłyszymy o polskim phishingu/malwarze na Alior Bank to będziemy wiedzieć gdzie szukać ;).

Juhas napisał(a):

Co robisz źle? Nie napisałeś do banku z pytaniem, czy udostępniają jakieś API, bo chciałbyś zrobić to i to. A zamiast tego próbujesz sam coś "hackować".

Mają API, ale dla przedsiębiorców i nie za darmo. Natomiast wygodniejsze API (raczej darmowe), będą musiały wprowadzić wszystkie banki dzięki dyrektywie PSD2, która w polskiej ustawie będzie wdrożona jako "Polish API".

1 użytkowników online, w tym zalogowanych: 0, gości: 1