elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  auto login Http post request
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: auto login Http post request  (Leído 3,637 veces)
s_azazel

Desconectado Desconectado

Mensajes: 98



Ver Perfil
auto login Http post request
« en: 27 Septiembre 2017, 17:55 pm »

Buenas tardes!!! a ver si me podeis echar una mano con esto que me esta dando dolores de cabeza jajaj

Estoy haciendo un bot que me automatice el login en un web y creo que me esta dando problemas creo que con las cookies.... os pongo un poco la info

Esta es la info que me saca el live http header:

Citar
http://www.marketglory.com/account_login/

POST /account_login/ HTTP/1.1
Host: www.marketglory.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://www.marketglory.com/
Content-Type: application/x-www-form-urlencoded
Content-Length: 120
Cookie: __cfduid=d43181c96a79c6e98ff78fb22812c11161505423004; _ga=GA1.2.845929005.1505423010; _gid=GA1.2.379722860.1505423010; __auc=1fe82af315e8234299c769495e0; __utma=105699615.845929005.1505423010.1506484770.1506526239.53; __utmz=105699615.1506484770.52.5.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); fbm_417737454961499=base_domain=.marketglory.com; __mgcid=54cee7e896aedefea74929b79eaee694; __utmc=105699615; mgapp_downloaded_app=1; mg_chat=0; ci_session=16rfh8ni4crjm18ojv902juvr5j10064; is_mobile=0; __asc=185b2e6c15ec3f6194cea6ea9f5; __utmb=105699615.7.10.1506526239; __insp_wid=370090747; __insp_slim=1506526420033; __insp_nv=true; __insp_targlpu=aHR0cDovL3d3dy5tYXJrZXRnbG9yeS5jb20vbG9nb2Zm; __insp_targlpt=UGxheSBNYXJrZXRHbG9yeSBvbmxpbmUgc3RyYXRlZ3kgZ2FtZSwgYW4gb25saW5lIGJyb3dzZXIgd2FyIGdhbWUgLSBlbmdsaXNoIGxvZ29mZg%3D%3D; fbsr_417737454961499=f2ApjIhcf-9drbzCq_yACBC5DkH8VlQYMuvMtjNJ-YE.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImNvZGUiOiJBUUMwb3d1bVRldFAyYk5iN0hWQ3Z3UllUY2hYMkhkVHFJY0xRQW5iYnVoekdZbkNVa1p4VFB1YzQwN0xDWm9SUkI3M2FjMkNyTFF0OWQzRDFGdnctS1BLQlllT015M2plQ2tLNjIyaGh5VDZaRDg2d0Nzek9YcDVYSlpnTDdCWjMybFJhVkU0YVBHWnBCdGFSZzhHNFUzUjNteXJjQWdsal9VTURub3gtZXM5aEludm5pTFJjWWRtaUptcmMycmhkLS1WYU1XNXMzRGJwQUVCcDlUX2dJVG9Rcy1ucmpSclFsMGpTVDNjblItRW82dTlkM0dxWkY4cEJoeXctQ2psb2dqUmY0N0ZGYWJUVU84R0tJS1NseVdQVUJ3R3o3V1hONm5hNmNrVWloNFozeGtwOFk2aXVtYmozNE12X0FRQTExYXh6RklFQWQzZVI3LTY5aTE2SUNsYiIsImlzc3VlZF9hdCI6MTUwNjUyNjQxOSwidXNlcl9pZCI6IjEwMTU2MDYxNTI0NTg3ODQxIn0; __insp_norec_sess=true
Connection: keep-alive
Upgrade-Insecure-Requests: 1
token=adfed48b43fa0f74ad4b2a699052f093&action=loginUser&character_name=minombre&character_password=micontraseña&button=OK: undefined

HTTP/1.1 200 OK
Date: Wed, 27 Sep 2017 15:46:09 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Refresh: 0;url=http://www.marketglory.com/account
Set-Cookie: mg_chat=0; expires=Thu, 28-Sep-2017 03:46:08 GMT; Max-Age=43200; path=/; domain=marketglory.com
X-Powered-By: PHP/7.0.23, PleskLin
Vary: Accept-Encoding
Server: cloudflare-nginx
CF-RAY: 3a4f9811b75e4322-MXP
----------------------------------------------------------

Creo que el problema son las cookies... el "token" lo he comprobado y lo he sacado del codigo funete de la web para logearse, simpre sale uno diferente
.
Lo que me extraña muchisimo es que en el post ya directamente el explorador saca unas cookies no se de donde ni de donde leerlas antes de obtener la respuesta :(

tengo este codigo:

Citar
#include <String.au3>
$sPD = ''
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", "http://www.marketglory.com", False)
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oHTTP.Send($sPD)
$oReceived = $oHTTP.ResponseText
$oStatusCode = $oHTTP.Status
;FileWrite("prueba.txt",$oReceived)

$Token = _StringBetween($oReceived,'<input type="hidden" name="token" value="','" />')


$sPD = "token="  & $Token[1] &   "&action=loginUser&character_name=miusuariol&character_password=micontraseña&button=OK: undefined"
$oHTTP.Open("POST", "http://www.marketglory.com/account_login/", False)
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oHTTP.Send($sPD)
$oReceived = $oHTTP.ResponseText
$oStatusCode = $oHTTP.Status
FileWrite("prueba.txt",$oReceived)

En vez de logearse me salta una web de login otra vez....¿alguna apreciacion???  Gracias!!!!!!


En línea

ThunderCls


Desconectado Desconectado

Mensajes: 455


Coder | Reverser | Gamer


Ver Perfil WWW
Re: auto login Http post request
« Respuesta #1 en: 30 Septiembre 2017, 03:52 am »

Pues tienes que leer las cookies de la web con tu get y cuando hagas tu post debes añadirlas al header de la peticion POST


En línea

-[ "…I can only show you the door. You're the one that has to walk through it." – Morpheus (The Matrix) ]-
http://reversec0de.wordpress.com
https://github.com/ThunderCls/
s_azazel

Desconectado Desconectado

Mensajes: 98



Ver Perfil
Re: auto login Http post request
« Respuesta #2 en: 16 Noviembre 2017, 21:14 pm »

No entiendo una cosa... con el Live http headers me salen esta cabecera :


Citar
http://www.marketglory.com/

GET / HTTP/1.1
Host: www.marketglory.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Cookie: __cfduid=d70a95ad2ed19150f0f2a8ca6581ecbd91509313021; _ga=GA1.2.2014101394.1509313024; __auc=185574f215f6a11202168dc1245; __utma=105699615.2014101394.1509313024.1510853606.1510862793.17; __utmz=105699615.1510862793.17.10.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); fbm_417737454961499=base_domain=.marketglory.com; __mgcid=690bfefc602377dc2b4eaa47a4216b45; _gid=GA1.2.1478173436.1510758245; ci_session=c9dcec4jakum8b3kek5v4atvk7v537k8; _gat=1; __asc=3934152115fc670a69e2d4e964a; __utmb=105699615.2.10.1510862793; __utmt=1; __utmt_UA-26372662-69=1; fbsr_417737454961499=G8rYBZ4nNAZDOKaTGeRotrQTznSuizMFj4Tj8JTfUd4.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImNvZGUiOiJBUUJHU29waXI3X2stMlFRWGlKODF0ek8wY1BzTW9uQTVIMzVES3pGMVJRY0FWOS1jSHVfRW1TN2sxZHlSYmU3ZmhGV29zcU44VUhseHJYb1I5VmstcDIwR0RDVG5fYzZ5T3JnLTNwZTliQ1Y2M3BtUlNJZkdUSTVZZEktTnBtWHdZcXktT2xUblpxQ21HZFkzMDRQQWE0Z0JzSUM5bXBfNjAyMEJpQTlMajJLZHE2Y01XdXljTnNfeGY4dTJzTFlhajJCSUU5TDRXalpvc0RXT0puOTB5c3RWTUhOMTlkT29XY0hfZGRXdEpJbU9FS3Y0dVFpOVhjcUtZNnJJZ1pLSlpUd3RsLXhaUE9sRkFCQS1waGU3TllWbGlfc1NsOHliQlM0ZkdUWTlaNDZOMGlGdlk4M0Y5ajJsTVdrcVJzR3hwM3JlWDVOOXgwMTBlXzkteVBDeUtUQyIsImlzc3VlZF9hdCI6MTUxMDg2Mjc5MSwidXNlcl9pZCI6IjEwMTU2MDYxNTI0NTg3ODQxIn0; __insp_wid=370090747; __insp_slim=1510862801135; __insp_nv=true; __insp_targlpu=aHR0cDovL3d3dy5tYXJrZXRnbG9yeS5jb20vc3RyYXRlZ3lnYW1lL2dyZXl3b2xm; __insp_targlpt=UGxheSBNYXJrZXRHbG9yeSBvbmxpbmUgc3RyYXRlZ3kgZ2FtZSwgYW4gb25saW5lIGJyb3dzZXIgd2FyIGdhbWUgZW5nbGlzaCBob21lcGFnZQ%3D%3D; __insp_norec_sess=true
Connection: keep-alive
Upgrade-Insecure-Requests: 1

y usando este codigo de autoit:

Citar
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET", "http://www.marketglory.com", False)

 $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0")
 $oHTTP.SetRequestHeader("Referer", "http://www.marketglory.com")

$oHTTP.Send()
$HeaderResponses = $oHTTP.GetAllResponseHeaders()

FileWrite("prueba1.txt",$HeaderResponses)

me sale esto totalmente diferente

Citar
Cache-Control: no-store, no-cache, must-revalidate
Connection: keep-alive
Date: Thu, 16 Nov 2017 20:13:04 GMT
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Server: cloudflare-nginx
Set-Cookie: __cfduid=df38d78553fa40dc20c6774cc3bf3bc171510863184; expires=Fri, 16-Nov-18 20:13:04 GMT; path=/; domain=.marketglory.com; HttpOnly
Set-Cookie: ci_session=dmsalptsp4pashmsm67liu2vau8egk72; expires=Fri, 17-Nov-2017 02:13:03 GMT; Max-Age=21600; path=/; HttpOnly
Vary: Accept-Encoding
X-Powered-By: PHP/7.0.25
X-Powered-By: PleskLin
CF-RAY: 3bed1bd660266121-BCN

Sabesi por que puede ser??? me estoy volviendo loco intentando hacer un autologin :(

Mil gracias!!!

En línea

ThunderCls


Desconectado Desconectado

Mensajes: 455


Coder | Reverser | Gamer


Ver Perfil WWW
Re: auto login Http post request
« Respuesta #3 en: 17 Noviembre 2017, 18:23 pm »

Estoy casi seguro que tu problema no es de cookies. Que data estas enviando en tu peticion POST?. Si te fijas en una peticion de ejemplo:

token=421dee8bdaa13308cf679d8b21b4897d&action=loginUser&character_name=myusername&character_password=mypassword&button=OK

te daras cuenta que la peticion POST debe incluir el token y el resto de elementos esperados, de otra forma te dara un bad response. Por lo que pude ver el token no esta en el header asi que supongo que estara como campo oculto en el html de la pagina de login, por lo que tendrias que leer el html, buscar el campo "token" y añadirlo a tu peticion POST ademas como dije antes del resto de variables esperadas
Saludos

EDIT: No habia leido bien el resto de tu primer mensaje, pero como dije antes no creo que sea error de cookies ya que no hay al parecer ninguna variable tipo csrf, etc. Puedes poner el codigo/status devuelto del response?
« Última modificación: 17 Noviembre 2017, 19:41 pm por ThunderCls » En línea

-[ "…I can only show you the door. You're the one that has to walk through it." – Morpheus (The Matrix) ]-
http://reversec0de.wordpress.com
https://github.com/ThunderCls/
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
visual basic 6 HTTP request
Programación Visual Basic
markx 6 8,012 Último mensaje 29 Agosto 2007, 20:23 pm
por markx
Como ver un request HTTP? « 1 2 3 »
Desarrollo Web
Vaagish 22 10,974 Último mensaje 12 Febrero 2014, 00:44 am
por Vaagish
Forward http/s request.
Hacking
xustyx 4 3,232 Último mensaje 30 Julio 2014, 18:47 pm
por xustyx
Duda sobre http request
Dudas Generales
gelvez16 5 3,215 Último mensaje 28 Noviembre 2014, 07:12 am
por engel lex
Duda Post Request y Request Headers
Desarrollo Web
0xFer 0 2,191 Último mensaje 22 Mayo 2017, 05:15 am
por 0xFer
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines