• Publicidad

ASP.net cookie HTTPS

Todo lo relacionado con el desarrollo Web con Perl: desde CGI hasta Mojolicious

ASP.net cookie HTTPS

Notapor jimr1984 » 2015-06-09 23:05 @004

Hola. Bueno, tengo el siguiente problema por si alguien puede ayudarme.

Paso a detallar (datos falseados).

Tengo la siguiente URL: https://abcdef.com/pagina.aspx

Al hacer GET, mi código es 200 OK, y las cabeceras de respuesta son:

Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
https://abcdef.com/pagina.aspx
GET pagina.aspx HTTP/1.1
Host: abcdef.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0
Accept: text/css,*/*;q=0.1
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://abcdef.com/pagina.aspx
Cookie: ASP.NET_SessionId=1us1xo45qxwet045rw5qchis
Connection: keep-alive
If-Modified-Since: Sun, 05 Sep 1909 19:02:00 GMT
If-None-Match: "04d36e3105a1:31ee"
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4

Luego llamo a la página

GET https://abcdef.com/micodigo/js/codigo.ashx

el cual obtengo mi código (ejemplo: NuevoCódigo2).

Y las cabeceras de la respuesta son:
Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
https://abcdef.com/micodigo/js/codigo.ashx
GET /micodigo/js/codigo.ashx HTTP/1.1
Host: abcdef.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://abcdef.com/micodigo/js/codigo.ashx
Cookie: ASP.NET_SessionId=1us1xo45qxwet045rw5qchis
Connection: keep-alive
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4

Obtengo el valor NuevoCódigo2 y hago un

POST https://abcdef.com/pagina.aspx "variable=NuevoCodigo2"

y el código fue enviado satisfactoriamente (esto sería haciéndolo desde el navegador).

Tengo mi código el cual trato de hacer lo mismo pero no me funciona. Paso a detallarlo.
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!/usr/bin/perl
  2. use LWP::UserAgent;
  3. use HTTP::Cookies;
  4. use HTTP::Request::Common qw(POST);
  5.  
  6. use strict;
  7. use warnings;
  8.  
  9. # Creamos el objeto para acceder vía web
  10. my $ua = LWP::UserAgent->new(
  11.     autocheck   => 0,
  12.     ssl_opts    => {
  13.         verify_hostname => 0,
  14.         SSL_verify_mode => 'SSL_VERIFY_NONE',
  15.     },
  16.    
  17. );
  18. # Decimos dónde pondremos nuestra COOKIE.
  19. # Es un fichero normal, por lo que la colocaremos en el mismo directorio de trabajo, con un nombre determinado
  20. $ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt", autosave => 1));
  21.  
  22. # hacemos una petición  normal, con un GET.
  23. # LA COOKIE SALE DE FORMA AUTOMÁTICA
  24. my $res = $ua->request(
  25.     HTTP::Request->new(GET => 'https://abcdef.com/pagina.aspx')
  26. );
  27.  
  28. # Si todo va bien, veremos un 200 OK
  29. print $res->status_line, "\n";
  30.  
  31. my $rex = $ua->request(
  32.     HTTP::Request->new(GET => 'https://abcdef.com/micodigo/js/codigo.ashx')
  33. );
  34.  
  35. print $rex->content, "\n";
  36.  
  37. my $valor = $rex->content;
  38.  
  39. print "RESULTADO ES ".$rex->content, "\n";
  40.  
  41.  
  42.  
  43. my $query = "variable=$valor";
  44. my $url = "https://abcdef.com/pagina.aspx";
  45.  
  46. my $req = HTTP::Request->new(POST => $url);
  47. $req->content_type('application/x-www-form-urlencoded');
  48. $req->content($query);
  49.  
  50. my $response = $ua->request($req);
  51. my $content = $response->content(); # contenido de la respuesta
  52.  
  53. print "Content-type: text/html\n\n";
  54. print $content;
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4

Y esto es lo que realizo, PERO NO ME FUNCIONA.

Por favor, si pueden revisarlo y decirme qué estoy realizando mal o qué debo corregir.
Si pueden corregirme, por favor, gracias.
jimr1984
Perlero nuevo
Perlero nuevo
 
Mensajes: 123
Registrado: 2012-11-25 07:11 @341

Publicidad

Re: ASP.net cookie HTTPS

Notapor explorer » 2015-06-10 05:57 @289

Es que hay algo que no queda claro.

Cuando sacas las cabeceras de la segunda petición, dices que obtienes un NuevoCódigo2, pero yo no lo veo por ningún lado.

En el código Perl tienes escrito esto:

my $valor = $rex->content;

y luego usas ese resultado en el POST:

my $query = "variable=$valor";

El método content(), devuelve el contenido de la respuesta a la petición HTTP que hiciste. Y no sabemos qué aspecto tiene. Pero de tus palabras deducimos que debe ser el NuevoCódigo2. Lo sabes porque el print() de la línea 39 te lo saca en pantalla.

Lo que queda por sabes es si en el POST de pagina.aspx le vale con el atributo 'variable', o si necesita alguna cosa más (hay más campos en el formulario).
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14476
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Re: ASP.net cookie HTTPS

Notapor jimr1984 » 2015-06-10 08:35 @399

Estimado, lamento no haber sido más claro en mi problema. Pasaré a detallar el código de mi aplicación (obviaré el enlace) para proteger.

Detallaré el procedimiento de forma manual utilizando Firefox.

Ingreso a la página: https://abcdef.com/pagina.aspx

El código es:
Sintáxis: [ Descargar ] [ Ocultar ]
Using html4strict Syntax Highlighting
  1. <html>
  2. <head>
  3.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4.     <title>PRUEBA DE SCRIPT</title>
  5.     <link href="../css/paginas.css" rel="stylesheet" type="text/css" />
  6.     <style type="text/css">
  7.     <!--
  8.    .textogrande {font-size: 14px; font-weight:bolder;}
  9.    body {
  10.             margin-bottom: 0px;
  11.    }
  12.    -->
  13.     </style>
  14.     <script type="text/javascript">
  15.         function contador(textarea, contad, formulario)
  16.         {
  17.             var area = eval("document."+formulario+"."+textarea+".value");
  18.             var resultado = 90 - area.length;
  19.            
  20.             if(resultado >= 0)
  21.                 eval("document."+formulario+"."+contad+".value = '"+resultado+"'");
  22.             else
  23.             {
  24.                 eval("document."+formulario+"."+contad+".value = '"+0+"'");
  25.                 document.form1.txtMensaje.value = document.form1.txtMensaje.value.substring(0, 90);
  26.             }            
  27.         }
  28.         function Limpiar()
  29.         {
  30.             document.form1.txtMensaje.value = "";            
  31.             document.form1.txtNombre.value = "";            
  32.             document.form1.txtNroTelf.value = "";    
  33.             document.form1.txtCaptcha.value = "";  
  34.             document.form1.txtContador.value = 90;                                  
  35.         }
  36.     </script>
  37.     <script src="../js/SpryValidationTextField.js" type="text/javascript"></script>
  38.     <link href="../css/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
  39.    
  40.     <script type="text/javascript" src="../js/cal/calendar.js"></script>
  41.     <script type="text/javascript" src="../js/cal/calendar-setup.js"></script>
  42.     <script type="text/javascript" src="../js/cal/calendar-es.js"></script>
  43.     <style type="text/css"> @import url("../css/cal/calendar-blue.css"); </style>
  44. </head>
  45. <body>
  46.     <br /><form name="form1" method="post" action="pagina.aspx" id="form1">
  47. <div>
  48. <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
  49. <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
  50. <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEwNjcwOTQyMDUPZBYCAgEPZBYOAgEPDxYCHgdWaXNpYmxlaGRkAgMPDxYEHgtCb3JkZXJDb2xvcgqcAR4EXyFTQgIQZGQCBQ8PFgQfAQqcAR8CAhBkZAILDw8WBB8BCpwBHwICEGRkAg8PDxYEHwEKnAEfAgIQZGQCEw8PFgQfAQqcAR8CAhBkZAIZD2QWAmYPZBYCAgEPFgIeCWlubmVyaHRtbAW7ATxkaXYgY2xhc3M9J2VtaXNvcic+PHNwYW4gY2xhc3M9J3Ntc05vbWJyZSc+cHJ1ZWJhPC9zcGFuPiA8c3BhbiBjbGFzcz0nc21zVGVsZic+ICZyYXF1bzszMjg1NDY2PC9zcGFuPiA8c3BhbiBjbGFzcz0nc21zRmVjaG9yYSc+KDA5OjAyKTwvc3Bhbj4gOiA8c3BhbiBjbGFzcz0nc21zTWVuc2FqZSc+eHh4eDwvc3Bhbj48L2Rpdj5kGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQxidG5SZWZyZXNjYXLH+JXhpKWCC0t6F0vVFZAiE1x/MA==" />
  51. </div>
  52.  
  53. <script type="text/javascript">
  54. //<![CDATA[
  55. var theForm = document.forms['form1'];
  56. if (!theForm) {
  57.    theForm = document.form1;
  58. }
  59. function __doPostBack(eventTarget, eventArgument) {
  60.    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
  61.        theForm.__EVENTTARGET.value = eventTarget;
  62.        theForm.__EVENTARGUMENT.value = eventArgument;
  63.        theForm.submit();
  64.    }
  65. }
  66. //]]>
  67. </script>
  68.  
  69.  
  70. <script src="/opcion/WebResource.axd?d=mNH5rQgmWPLRoSB4bA1oBkPPN6vjRVJoKbzBAOGJGXz9y0FQjz0lHmQmk-s-jiwYELZkIfx49BB1u9mN3gvlt5Dy5N41&amp;t=635539883600023750" type="text/javascript"></script>
  71.  
  72.  
  73. <script src="/opcion/ScriptResource.axd?d=yQuQ4bTWHHXuiULg-RoWBC6VMz1DU6yQDrzxeapzHveyIahqkP_oJxhHI0DG0YzbD45-Aq9vknoylDA_Cx2HtCjqNA1BLMd4pJnq_Vk1bY3mVBLhUN3_g6ekXoVvMe7VyWPrVxHMKQqWl7aa1-YNK__aJruc8qJDLo44ztL8IGWWW9lF0&amp;t=ffffffffd84e14c6" type="text/javascript"></script>
  74. <script type="text/javascript">
  75. //<![CDATA[
  76. if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
  77. //]]>
  78. </script>
  79.  
  80. <script src="/opcion/ScriptResource.axd?d=t0zvoRZlt5igZZai50FpAmw5C9NnXcLt1fKNmFDzbKjjxnOwKfSuEim8FsTufubI10Ly8go9WaFZ_xV76R1mQVYnhdZp70evJcEUaMdUIgOribNPWthxevnlG6yUls84Z3FxXAZDZhWfyvujhFAHd6RwpXnOXQLkg7BwGyb8ycDeF-_00&amp;t=ffffffffd84e14c6" type="text/javascript"></script>
  81. <script src="/opcion/ScriptResource.axd?d=aQvkvYVzY8OqMFmuaSx477OTMKo20yxyIbFp29ZdqSbN9Lz0YhnAxMPb8UsvdW6s21LsVVhmRbih5PWR7QE1ZRgA7O3hiPo_DiVZEOQIQ8bX7KGaJxNdKd28BhlfctU97yLWL8X8E-WBDJrc3peiFNlqd-MBcwOa4E8aayXLjSIj_X0d0&amp;t=ffffffffd84e14c6" type="text/javascript"></script>
  82. <div>
  83.  
  84.         <input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="8BB75E25" />
  85.         <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWCQKlhajqBwKIgMKjDAL298rXDgKtkMGoCwKy1oITAu+Z0b0FAuG+ousKAoO4powLAt/o6qoMlOpfarFaY58EKl8vMzJEBjRVwOk=" />
  86. </div>
  87.     <table cellpadding="0" cellspacing="0" class="SMS" id="TABLE1">
  88.         <tr>
  89.             <td class="celesteK" style="width: 310px">
  90.                
  91.                     <table cellpadding="0" cellspacing="0">
  92.                         <tr>
  93.                             <td align="center" colspan="3" style="height: 24px" valign="middle">
  94.                                 </td>
  95.                         </tr>
  96.                         <tr>
  97.                             <td style="height: 24px">
  98.                                 Tu Nombre:</td>
  99.                             <td class="derecha" colspan="2" style="height: 24px">
  100.                                 <input name="txtNombre" type="text" value="prueba" maxlength="10" id="txtNombre" class="grisaseo" style="border-color:SteelBlue;width:100px;" /></td>
  101.                         </tr>
  102.                         <tr>
  103.                             <td style="height: 24px">
  104.                                 <span>Teléfono:</span></td>
  105.                             <td  class="derecha" style="height: 24px;" colspan="2"><input name="txtNroTelf" type="text" value="3285466" maxlength="8" id="txtNroTelf" class="grisaseo" style="border-color:SteelBlue;width:65px;" />
  106.                                     <span id="lbejemplo" style="font-size:7pt;font-weight:normal;">(ej. 3360000)</span></td>
  107.                         </tr>
  108.                         <tr>
  109.                             <td>
  110.                                 Escribe tu mensaje:
  111.                             </td>
  112.                             <td class="izquierda">
  113.                                 <input name="txtContador" type="text" value="90" readonly="readonly" id="txtContador" tabindex="100" class="contador" style="width:40px;" /></td>
  114.                             <td class="derecha" style="width: 40px">
  115.                                 <span class="textoscuro">&nbsp;de 90</span></td>
  116.                         </tr>
  117.                     </table>
  118.                     <div>
  119.                         <textarea name="txtMensaje" rows="5" cols="20" id="txtMensaje" class="grisaseo" onkeyup="contador('txtMensaje', 'txtContador', 'form1')" style="border-color:SteelBlue;width:288px;"></textarea><br />
  120.                         <table cellpadding="0" cellspacing="0">
  121.                             <tr>
  122.                                 <td width="165" class="centrado">
  123.                                     <div>Código de Verificación :</div>
  124.                                     <div><img id="imgCaptcha" src="../micodigo/js/codigo.ashx" style="border-width:0px;" /></div>
  125.                                     <div><input name="txtCaptcha" type="text" maxlength="4" id="txtCaptcha" class="grisaseo" style="border-color:SteelBlue;width:65px;" />&nbsp;
  126.                                          <input type="image" name="btnRefrescar" id="btnRefrescar" src="../imagenes/refresh.png" style="border-width:0px;" />
  127.                                     </div>
  128.                                 </td>
  129.                                 <td style="border-left: 1px solid #71cbff; width: 128px;" class="centrado">
  130.                                     <table id="calendario" width="100%" border="0" cellspacing="4" cellpadding="0">
  131.                                         <tr>
  132.                                             <td style="width: 149px">
  133.                                                 Programar<br />envío:
  134.                                             </td>  
  135.                                             <td>
  136.                                                 <input  type="image" src="../imagenes/calen.png" id="btnCalendario" />                                                  
  137.                                             </td>                                            
  138.                                         </tr>
  139.                                         <tr>
  140.                                             <td colspan="2" style="height: 19px">
  141.                                                 &nbsp;<input name="txtFechaHora" type="text" value="10/06/2015 09:07" maxlength="16" id="txtFechaHora" class="grisaseo" style="border-color:SteelBlue;width:119px;" />&nbsp;
  142.                                             </td>
  143.                                             <script type="text/javascript">                                                                                            
  144.                                                     Calendar.setup({
  145.                                                       inputField     :"txtFechaHora",
  146.                                                       button         :"btnCalendario",
  147.                                                       //ifFormat       :"%Y-%m-%d %H:%M",
  148.                                                       ifFormat       :"%d/%m/%Y %H:%M",
  149.                                                       showsTime      :true,
  150.                                                       timeFormat     :"24",
  151.                                                       align          :"Tr",
  152.                                                       weekNumbers    :false//,
  153.                                                       /*dateStatusFunc :    function (date) {
  154.                                                                             if ( new Date() >= date )
  155.                                                                                 return true;
  156.                                                                             else
  157.                                                                                 return false;
  158.                                                         }       */              
  159.                                                     });  
  160.                                                     //Calendar.refresh();                                                                                                                                                                                      
  161.                                             </script>
  162.                                         </tr>
  163.                                     </table>
  164.                                 </td>
  165.                             </tr>
  166.                         </table>
  167.                     </div>
  168.                     <div class="centrado">
  169.                         <input type="submit" name="btnEnviar" value="Enviar" id="btnEnviar" class="boton" />&nbsp;
  170.                         <input type= "Button" id="btnLimpiar"  class="boton" onclick="Limpiar()" value ="Limpiar" />                        
  171.                     </div>
  172.                
  173.             </td>            
  174.             <td class="colder">
  175.                 <div class="textoscuro">
  176.                 <div class="derecha"> Mensajes<br /> enviados/Recibidos</div></div>  
  177.                    
  178.                     <div>              
  179.                     <script type="text/javascript">
  180. //<![CDATA[
  181. Sys.WebForms.PageRequestManager._initialize('ScriptManager1', document.getElementById('form1'));
  182. Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tUpdatePanel1'], ['Timer1'], [], 90);
  183. //]]>
  184. </script>
  185.  
  186.                         <div id="UpdatePanel1">
  187.        
  188.                                 <div id="lbMensajes" class="bordeMensajes"><div class='emisor'><span class='smsNombre'>prueba</span> <span class='smsTelf'> &raquo;3285466</span> <span class='smsFechora'>(09:02)</span> : <span class='smsMensaje'>xxxx</span></div></div>
  189.                            
  190. </div>
  191.                      </div>
  192.                     <span id="Timer1" style="visibility:hidden;display:none;"></span>
  193.                    
  194.                 </td>
  195.         </tr>
  196.     </table>
  197.  
  198. <script type="text/javascript">
  199. //<![CDATA[
  200. Sys.Application.initialize();
  201. Sys.Application.add_init(function() {
  202.    $create(Sys.UI._Timer, {"enabled":true,"interval":30000,"uniqueID":"Timer1"}, null, null, $get("Timer1"));
  203. });
  204. //]]>
  205. </script>
  206. </form>
  207.     <script type="text/javascript">    
  208.     var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield", "integer", {validateOn:["change"], useCharacterMasking:true, isRequired:false});    
  209.     </script>
  210. </body>
  211. </html>
  212.  
Coloreado en 0.008 segundos, usando GeSHi 1.0.8.4

NOTA: codigo.ashx genera un CAPTCHA

Relleno el formulario y realizo el envio.
Y capturo las cabeceras para ver qué se está enviando.

Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
https://abcdef.com/pagina.aspx

POST pagina.aspx HTTP/1.1
Host: abcdef.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.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: https://abcdef.com/pagina.aspx
Cookie: ASP.NET_SessionId=pn1etjutwk31fgefirktdcyf
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 962
__LASTFOCUS=&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwULLTEwNjcwOTQyMDUPZBYCAgEPZBYOAgEPDxYCHgdWaXNpYmxlaGRkAgMPDxYEHgtCb3JkZXJDb2xvcgqcAR4EXyFTQgIQZGQCBQ8PFgQfAQqcAR8CAhBkZAILDw8WBB8BCo0BHwICEGRkAg8PDxYEHwEKnAEfAgIQZGQCEw8PFgQfAQqcAR8CAhBkZAIZD2QWAmYPZBYCAgEPFgIeCWlubmVyaHRtbAW7ATxkaXYgY2xhc3M9J2VtaXNvcic%2BPHNwYW4gY2xhc3M9J3Ntc05vbWJyZSc%2BcHJ1ZWJhPC9zcGFuPiA8c3BhbiBjbGFzcz0nc21zVGVsZic%2BICZyYXF1bzszMjg1NDY2PC9zcGFuPiA8c3BhbiBjbGFzcz0nc21zRmVjaG9yYSc%2BKDA5OjAyKTwvc3Bhbj4gOiA8c3BhbiBjbGFzcz0nc21zTWVuc2FqZSc%2BeHh4eDwvc3Bhbj48L2Rpdj5kGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQxidG5SZWZyZXNjYXJLc56MoYAeD8QqlGQAf6OP1aSFXA%3D%3D&__VIEWSTATEGENERATOR=8BB75E25&__EVENTVALIDATION=%2FwEWCQL9%2F%2Bf%2FAwKIgMKjDAL298rXDgKtkMGoCwKy1oITAu%2BZ0b0FAuG%2BousKAoO4powLAt%2Fo6qoMxLNGbb7RVH1U%2F9AMkMiEBrx3aWw%3D&txtNombre=prueba&txtNroTelf=3285466&txtContador=84&txtMensaje=PRUEBA&txtCaptcha=47CD&txtFechaHora=10%2F06%2F2015+09%3A07&btnEnviar=Enviar
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4

El envío se realiza satisfactorio.

El script que expliqué anteriormente fue el que realicé para realizar todo el proceso del envío.

El CAPTCHA genera una imagen PNG la cual es el código de envío. Por ese lado no hay problema puesto que descargo la imagen la guardo en la carpeta e ingreso de forma manual el código.

La diferencia entre ambos métodos sería:

Desde la web: el procedimiento normal.

Desde el script: el método sería cargar la web; capturar la sesión; descargar el captcha; guardarlo en disco; e ingresar el código del captcha; y realizar el envío.

Estoy leyendo y buscando.

Encontré esto:
https://translate.googleusercontent.com ... LseBz_u45Q

http://stackoverflow.com/questions/2632 ... to-website

http://forum.hardware.fr/hfr/Programmat ... 8823_1.htm
jimr1984
Perlero nuevo
Perlero nuevo
 
Mensajes: 123
Registrado: 2012-11-25 07:11 @341

Re: ASP.net cookie HTTPS

Notapor explorer » 2015-06-10 19:20 @847

Bueno, el problema es que el formulario tiene un montón de campos. Debes enviarlos todos.

Además, hay un JavaScript que parece que hace una validación de los campos, llamado SpryValidationTextField.js. Debes bajarlo y analizarlo por si hace algo especial.

En concreto, la función en JavaScript __doPostBack() hace un postprocesado de un par de campos, y luego hace el submit del formulario, así que esa es lo que también debes tener en cuenta. Pero lo malo es que no sabemos en dónde se llama. Esto requiere un análisis más cuidadoso.

O si has capturado toda la salida con el Firefox, identificar todos los campos que se envían por POST, y agregarles al programa. Para esto último debes averiguar el significado de todos los campos, o los que sean significativos para el servidor.
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14476
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Re: ASP.net cookie HTTPS

Notapor jimr1984 » 2015-06-10 20:36 @900

Aquí expongo el código con las URL:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!/usr/bin/perl -l
  2. #https://..................................../captcha.ashx
  3.  
  4. use strict;
  5. use warnings;
  6.  
  7.  
  8. use LWP::UserAgent;
  9. use HTTP::Cookies;
  10. use HTTP::Request;
  11. use autodie;
  12.  
  13.  
  14.  
  15.  
  16.  
  17. my $url = "https://..................../pagina.aspx";
  18. my $url2="https://............................/captcha.ashx";
  19.  
  20.  
  21. my $cookies = HTTP::Cookies->new(
  22.     file     => 'cookies.txt',
  23.     autosave => 1,
  24. );
  25.  
  26. my $http = LWP::UserAgent->new(
  27.     autocheck   => 0,
  28.     ssl_opts    => {
  29.         verify_hostname => 0,
  30.         SSL_verify_mode => 'SSL_VERIFY_NONE',
  31.     },
  32.    
  33. );
  34. $http->cookie_jar($cookies);
  35.  
  36. $http->agent("Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)");
  37.  
  38. my $response = $http->get($url) or die $!;
  39.  
  40. my $succes = $response->is_success() or die $!;
  41. my $code = $response->code() or die $!;
  42.  
  43. print $succes;
  44. print "\n";
  45. print $code;
  46. print $http->cookie_jar->as_string() . "\n";
  47. print "######################################################################################## \n";
  48. my $response2 = $http->get($url2) or die $!;
  49.  
  50. my $succes2 = $response2->is_success() or die $!;
  51. my $code2 = $response2->code() or die $!;
  52.  
  53. print $succes2;
  54. print "\n";
  55. print $code2;
  56. print $http->cookie_jar->as_string() . "\n";
  57.  
  58. open my $PNG, '>', 'captcha.png';        # abrimos en escritura
  59. binmode $PNG;                           # modo binario
  60. #print   $PNG $url_concurso;                   # escribimos la imagen
  61. print $PNG $response2->content;
  62.  
  63. close   $PNG;
  64.  
  65.  
  66. my $comando = qx(tesseract.exe captcha.png captcha);
  67. my $resultado = qx(type captcha.txt);
  68.  
  69. print "RESULTADO ES ".$resultado;
  70. chop($resultado);
  71.  
  72. #my $valor = <STDIN>;
  73. #chop($valor);
  74.  
  75. my $q ="txtNombre=JAIME&txtNroTelf=3245865&txtContador=78&txtMensaje=DESDE+LA+WEB&txtCaptcha=$resultado&txtFechaHora=10%2F06%2F2015+20%3A22&btnEnviar=Enviar&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwULLTEwNjcwOTQyMDUPZBYCAgEPZBYCAgEPDxYCHgdWaXNpYmxlaGRkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQxidG5SZWZyZXNjYXIWrHcd8YHfIv5beP7HARL%2FgGF44A%3D%3D&__VIEWSTATEGENERATOR=8BB75E25&__EVENTVALIDATION=%2FwEWCQKi%2Fdj6CAKIgMKjDAL298rXDgKtkMGoCwKy1oITAu%2BZ0b0FAuG%2BousKAoO4powLAt%2Fo6qoMkkiC9lggCxPhcJUsOfcFVHEOoWQ%3D";
  76.  
  77.  
  78.  
  79.  
  80. print "\n";
  81. print "######################################################################################## \n";
  82. print $q."\n";
  83.  
  84.  
  85. #my $ua = LWP::UserAgent->new;
  86. # $ua->agent("Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)");
  87.  
  88. my $req = HTTP::Request->new(POST => $url);
  89. #$req->content_type('application/x-www-form-urlencoded');
  90. $req->content($q);
  91.  
  92. my $response3 = $http->request($req);
  93. my $content3 = $response3->content(); #contenido de la respuesta
  94.  
  95. print "Content-type: text/html\n\n";
  96. print $content3;
  97. print "\n";
  98.  
  99. print "\n";
  100.  
  101. print $http->cookie_jar->as_string() . "\n";
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4
jimr1984
Perlero nuevo
Perlero nuevo
 
Mensajes: 123
Registrado: 2012-11-25 07:11 @341

Re: ASP.net cookie HTTPS

Notapor jimr1984 » 2015-06-11 11:15 @510

Estimado, estos son TODOS los campos que se envían por el POST en el envío.

txtNombre=JAIME&txtNroTelf=3245865&txtContador=78&txtMensaje=DESDE+LA+WEB&txtCaptcha=$resultado&txtFechaHora=10%2F06%2F2015+20%3A22&btnEnviar=Enviar&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwULLTEwNjcwOTQyMDUPZBYCAgEPZBYCAgEPDxYCHgdWaXNpYmxlaGRkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQxidG5SZWZyZXNjYXIWrHcd8YHfIv5beP7HARL%2FgGF44A%3D%3D&__VIEWSTATEGENERATOR=8BB75E25&__EVENTVALIDATION=%2FwEWCQKi%2Fdj6CAKIgMKjDAL298rXDgKtkMGoCwKy1oITAu%2BZ0b0FAuG%2BousKAoO4powLAt%2Fo6qoMkkiC9lggCxPhcJUsOfcFVHEOoWQ%3D

Valores que captura del formulario:
txtNombre=JAIME&txtNroTelf=3245865&txtContador=78&txtMensaje=DESDE+LA+WEB&txtCaptcha=$resultado&txtFechaHora=10%2F06%2F2015+20%3A22

Valores fijos:
&btnEnviar=Enviar&__EVENTTARGET=__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwULLTEwNjcwOTQyMDUPZBYCAgEPZBYCAgEPDxYCHgdWaXNpYmxlaGRkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQxidG5SZWZyZXNjYXIWrHcd8YHfIv5beP7HARL%2FgGF44A%3D%3D&__VIEWSTATEGENERATOR=8BB75E25&__EVENTVALIDATION=%2FwEWCQKi%2Fdj6CAKIgMKjDAL298rXDgKtkMGoCwKy1oITAu%2BZ0b0FAuG%2BousKAoO4powLAt%2Fo6qoMkkiC9lggCxPhcJUsOfcFVHEOoWQ%3D

¿Qué podría afectar el script Postback()? Si igual estoy pasando todos los parámetros completos e incluso he visto que ningún parámetro se modifica, por lo que la función no hace ningún cambio significativo en el submit.
jimr1984
Perlero nuevo
Perlero nuevo
 
Mensajes: 123
Registrado: 2012-11-25 07:11 @341

Re: ASP.net cookie HTTPS

Notapor jimr1984 » 2015-06-11 17:15 @760

Estimados , voy a realizar el proceso de ENVIAR EL MENSAJE desde el navegador desde el inicio
1.- cargo la pagina
2.- lleno los campos y realizo el submit envio.
3- capturo desde el inicio los headers con HTTP LIVE HEADERS plugin firefox.

1.- TAN SOLO ABRO LA PAGINA MENSAJE.aspx con un GET unica pagina para tener un trafico limpio
Sintáxis: [ Descargar ] [ Ocultar ]
  1. https://msl.portal.com/unicopin/paginas/MENSAJE.aspx 
  2.  
  3. GET /unicopin/paginas/MENSAJE.aspx HTTP/1.1 
  4. Host: msl.portal.com 
  5. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  6. Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
  7. Accept-Language: en-US,en;q=0.5 
  8. Accept-Encoding: gzip, deflate 
  9. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  10. Connection: keep-alive 
  11.  
  12. HTTP/1.1 200 OK 
  13. Date: Thu, 11 Jun 2015 21:59:23 GMT 
  14. Server: Microsoft-IIS/6.0 
  15. MicrosoftOfficeWebServer: 5.0_Pub 
  16. X-Powered-By: ASP.NET 
  17. X-AspNet-Version: 2.0.50727 
  18. Cache-Control: private 
  19. Content-Type: text/html; charset=utf-8 
  20. Content-Length: 12349 
  21. ---------------------------------------------------------- 
  22. https://msl.portal.com/unicopin/css/Spr ... tField.css 
  23.  
  24. GET /unicopin/css/SpryValidationTextField.css HTTP/1.1 
  25. Host: msl.portal.com 
  26. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  27. Accept: text/css,*/*;q=0.1 
  28. Accept-Language: en-US,en;q=0.5 
  29. Accept-Encoding: gzip, deflate 
  30. Referer: https://msl.portal.com/unicopin/paginas/MENSAJE.aspx 
  31. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  32. Connection: keep-alive 
  33. If-Modified-Since: Sun, 05 Sep 1909 19:02:00 GMT 
  34. If-None-Match: "04d36e3105a1:31ee" 
  35.  
  36. HTTP/1.1 304 Not Modified 
  37. Last-Modified: Sun, 05 Sep 1909 19:02:00 GMT 
  38. Accept-Ranges: bytes 
  39. Etag: "04d36e3105a1:31ee" 
  40. Server: Microsoft-IIS/6.0 
  41. MicrosoftOfficeWebServer: 5.0_Pub 
  42. X-Powered-By: ASP.NET 
  43. Date: Thu, 11 Jun 2015 21:59:23 GMT 
  44. ---------------------------------------------------------- 
  45. https://msl.portal.com/unicopin/css/cal ... r-blue.css 
  46.  
  47. GET /unicopin/css/cal/calendar-blue.css HTTP/1.1 
  48. Host: msl.portal.com 
  49. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  50. Accept: text/css,*/*;q=0.1 
  51. Accept-Language: en-US,en;q=0.5 
  52. Accept-Encoding: gzip, deflate 
  53. Referer: https://msl.portal.com/unicopin/paginas/MENSAJE.aspx 
  54. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  55. Connection: keep-alive 
  56. If-Modified-Since: Tue, 23 Nov 1909 13:06:00 GMT 
  57. If-None-Match: "0ece761c54e5a1:31ee" 
  58.  
  59. HTTP/1.1 304 Not Modified 
  60. Last-Modified: Tue, 23 Nov 1909 13:06:00 GMT 
  61. Accept-Ranges: bytes 
  62. Etag: "0ece761c54e5a1:31ee" 
  63. Server: Microsoft-IIS/6.0 
  64. MicrosoftOfficeWebServer: 5.0_Pub 
  65. X-Powered-By: ASP.NET 
  66. Date: Thu, 11 Jun 2015 21:59:23 GMT 
  67. ---------------------------------------------------------- 
  68. https://msl.portal.com/unicopin/imagenes/calen.png 
  69.  
  70. GET /unicopin/imagenes/calen.png HTTP/1.1 
  71. Host: msl.portal.com 
  72. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  73. Accept: image/png,image/*;q=0.8,*/*;q=0.5 
  74. Accept-Language: en-US,en;q=0.5 
  75. Accept-Encoding: gzip, deflate 
  76. Referer: https://msl.portal.com/unicopin/paginas/MENSAJE.aspx 
  77. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  78. Connection: keep-alive 
  79. If-Modified-Since: Fri, 20 Aug 1909 21:17:00 GMT 
  80. If-None-Match: "0ee303c6345a1:31ee" 
  81.  
  82. HTTP/1.1 304 Not Modified 
  83. Last-Modified: Fri, 20 Aug 1909 21:17:00 GMT 
  84. Accept-Ranges: bytes 
  85. Etag: "0ee303c6345a1:31ee" 
  86. Server: Microsoft-IIS/6.0 
  87. MicrosoftOfficeWebServer: 5.0_Pub 
  88. X-Powered-By: ASP.NET 
  89. Date: Thu, 11 Jun 2015 21:59:23 GMT 
  90. ---------------------------------------------------------- 
  91. https://msl.portal.com/unicopin/imagenes/refresh.png 
  92.  
  93. GET /unicopin/imagenes/refresh.png HTTP/1.1 
  94. Host: msl.portal.com 
  95. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  96. Accept: image/png,image/*;q=0.8,*/*;q=0.5 
  97. Accept-Language: en-US,en;q=0.5 
  98. Accept-Encoding: gzip, deflate 
  99. Referer: https://msl.portal.com/unicopin/paginas/MENSAJE.aspx 
  100. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  101. Connection: keep-alive 
  102. If-Modified-Since: Fri, 20 Aug 1909 21:17:00 GMT 
  103. If-None-Match: "0ee303c6345a1:31ee" 
  104.  
  105. HTTP/1.1 304 Not Modified 
  106. Last-Modified: Fri, 20 Aug 1909 21:17:00 GMT 
  107. Accept-Ranges: bytes 
  108. Etag: "0ee303c6345a1:31ee" 
  109. Server: Microsoft-IIS/6.0 
  110. MicrosoftOfficeWebServer: 5.0_Pub 
  111. X-Powered-By: ASP.NET 
  112. Date: Thu, 11 Jun 2015 21:59:23 GMT 
  113. ---------------------------------------------------------- 
  114. https://msl.portal.com/unicopin/imagenes/backimg.png 
  115.  
  116. GET /unicopin/imagenes/backimg.png HTTP/1.1 
  117. Host: msl.portal.com 
  118. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  119. Accept: image/png,image/*;q=0.8,*/*;q=0.5 
  120. Accept-Language: en-US,en;q=0.5 
  121. Accept-Encoding: gzip, deflate 
  122. Referer: https://msl.portal.com/unicopin/css/paginas.css 
  123. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  124. Connection: keep-alive 
  125. If-Modified-Since: Fri, 20 Aug 1909 21:17:00 GMT 
  126. If-None-Match: "0ee303c6345a1:31ee" 
  127.  
  128. HTTP/1.1 304 Not Modified 
  129. Last-Modified: Fri, 20 Aug 1909 21:17:00 GMT 
  130. Accept-Ranges: bytes 
  131. Etag: "0ee303c6345a1:31ee" 
  132. Server: Microsoft-IIS/6.0 
  133. MicrosoftOfficeWebServer: 5.0_Pub 
  134. X-Powered-By: ASP.NET 
  135. Date: Thu, 11 Jun 2015 21:59:23 GMT 
  136. ---------------------------------------------------------- 
  137. https://msl.portal.com/unicopin/imagenes/mail.png 
  138.  
  139. GET /unicopin/imagenes/mail.png HTTP/1.1 
  140. Host: msl.portal.com 
  141. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  142. Accept: image/png,image/*;q=0.8,*/*;q=0.5 
  143. Accept-Language: en-US,en;q=0.5 
  144. Accept-Encoding: gzip, deflate 
  145. Referer: https://msl.portal.com/unicopin/css/paginas.css 
  146. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  147. Connection: keep-alive 
  148. If-Modified-Since: Fri, 20 Aug 1909 21:17:00 GMT 
  149. If-None-Match: "0ee303c6345a1:31ee" 
  150.  
  151. HTTP/1.1 304 Not Modified 
  152. Last-Modified: Fri, 20 Aug 1909 21:17:00 GMT 
  153. Accept-Ranges: bytes 
  154. Etag: "0ee303c6345a1:31ee" 
  155. Server: Microsoft-IIS/6.0 
  156. MicrosoftOfficeWebServer: 5.0_Pub 
  157. X-Powered-By: ASP.NET 
  158. Date: Thu, 11 Jun 2015 21:59:23 GMT 
  159. ---------------------------------------------------------- 
  160. https://msl.portal.com/unicopin/imagene ... ptcha.ashx 
  161.  
  162. GET /unicopin/imagenes/imgcap/captcha.ashx HTTP/1.1 
  163. Host: msl.portal.com 
  164. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  165. Accept: image/png,image/*;q=0.8,*/*;q=0.5 
  166. Accept-Language: en-US,en;q=0.5 
  167. Accept-Encoding: gzip, deflate 
  168. Referer: https://msl.portal.com/unicopin/paginas/MENSAJE.aspx 
  169. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  170. Connection: keep-alive 
  171.  
  172. HTTP/1.1 200 OK 
  173. Date: Thu, 11 Jun 2015 21:59:23 GMT 
  174. Server: Microsoft-IIS/6.0 
  175. MicrosoftOfficeWebServer: 5.0_Pub 
  176. X-Powered-By: ASP.NET 
  177. X-AspNet-Version: 2.0.50727 
  178. Cache-Control: private 
  179. Content-Type: image/GIF; charset=utf-8 
  180. Content-Length: 2050 
  181. ---------------------------------------------------------- 

TODO ESO es la trama que capturo con el plugin desde que llamo a MENSAJE.aspx y carga los css,js,ect...
PROCESO A LLENAR LOS CAMPOS QUE SON : Nombre ,Telefono , Mensaje, Captcha y realizo el submit.
capturo la trama.
Sintáxis: [ Descargar ] [ Ocultar ]
  1. https://msl.portal.com/unicopin/paginas/MENSAJE.aspx 
  2.  
  3. POST /unicopin/paginas/MENSAJE.aspx HTTP/1.1 
  4. Host: msl.portal.com 
  5. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  6. Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
  7. Accept-Language: en-US,en;q=0.5 
  8. Accept-Encoding: gzip, deflate 
  9. Referer: https://msl.portal.com/unicopin/paginas/MENSAJE.aspx 
  10. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  11. Connection: keep-alive 
  12. Content-Type: application/x-www-form-urlencoded 
  13. Content-Length: 770 
  14.  
  15. __LASTFOCUS=&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwULLTEwNjcwOTQyMDUPZBYCAgEPZBYMAgEPDxYEHgdWaXNpYmxlaB4EVGV4dAVFU3UgU01TIG5vIHB1ZG8gc2VyIGVudmlhZG8sIGZhdm9yIGludGVudGUgZW4gbG9zIHByw7N4aW1vcyA1IG1pbnV0b3MuZGQCAw8PFgQeC0JvcmRlckNvbG9yCpwBHgRfIVNCAhBkZAIFDw8WBB8CCpwBHwMCEGRkAgsPDxYEHwIKnAEfAwIQZGQCDw8PFgQfAgqNAR8DAhBkZAITDw8WBB8CCpwBHwMCEGRkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQxidG5SZWZyZXNjYXKszM2s96bpSRFX%2BsRUfFeUxb5l0w%3D%3D&__VIEWSTATEGENERATOR=8BB75E25&__EVENTVALIDATION=%2FwEWCQKH9avCAQKIgMKjDAL298rXDgKtkMGoCwKy1oITAu%2BZ0b0FAuG%2BousKAoO4powLAt%2Fo6qoMlND6hYeUjxLsKiQOfb%2B%2BUDSLw%2Bk%3D&txtNombre=JAIMEIVAN&txtNroTelf=3245865&txtContador=81&txtMensaje=MIMENSAJE&txtCaptcha=34ED&txtFechaHora=11%2F06%2F2015+17%3A59&btnEnviar=Enviar 
  16.  
  17.  
  18. HTTP/1.1 200 OK 
  19. Date: Thu, 11 Jun 2015 22:14:20 GMT 
  20. Server: Microsoft-IIS/6.0 
  21. MicrosoftOfficeWebServer: 5.0_Pub 
  22. X-Powered-By: ASP.NET 
  23. X-AspNet-Version: 2.0.50727 
  24. Cache-Control: private 
  25. Content-Type: text/html; charset=utf-8 
  26. Content-Length: 13229 
  27. ---------------------------------------------------------- 
  28. https://msl.portal.com/unicopin/css/Spr ... tField.css 
  29.  
  30. GET /unicopin/css/SpryValidationTextField.css HTTP/1.1 
  31. Host: msl.portal.com 
  32. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  33. Accept: text/css,*/*;q=0.1 
  34. Accept-Language: en-US,en;q=0.5 
  35. Accept-Encoding: gzip, deflate 
  36. Referer: https://msl.portal.com/unicopin/paginas/MENSAJE.aspx 
  37. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  38. Connection: keep-alive 
  39. If-Modified-Since: Sun, 05 Sep 1909 19:02:00 GMT 
  40. If-None-Match: "04d36e3105a1:31ee" 
  41.  
  42. HTTP/1.1 304 Not Modified 
  43. Last-Modified: Sun, 05 Sep 1909 19:02:00 GMT 
  44. Accept-Ranges: bytes 
  45. Etag: "04d36e3105a1:31ee" 
  46. Server: Microsoft-IIS/6.0 
  47. MicrosoftOfficeWebServer: 5.0_Pub 
  48. X-Powered-By: ASP.NET 
  49. Date: Thu, 11 Jun 2015 22:14:22 GMT 
  50. ---------------------------------------------------------- 
  51. https://msl.portal.com/unicopin/css/cal ... r-blue.css 
  52.  
  53. GET /unicopin/css/cal/calendar-blue.css HTTP/1.1 
  54. Host: msl.portal.com 
  55. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  56. Accept: text/css,*/*;q=0.1 
  57. Accept-Language: en-US,en;q=0.5 
  58. Accept-Encoding: gzip, deflate 
  59. Referer: https://msl.portal.com/unicopin/paginas/MENSAJE.aspx 
  60. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  61. Connection: keep-alive 
  62. If-Modified-Since: Tue, 23 Nov 1909 13:06:00 GMT 
  63. If-None-Match: "0ece761c54e5a1:31ee" 
  64.  
  65. HTTP/1.1 304 Not Modified 
  66. Last-Modified: Tue, 23 Nov 1909 13:06:00 GMT 
  67. Accept-Ranges: bytes 
  68. Etag: "0ece761c54e5a1:31ee" 
  69. Server: Microsoft-IIS/6.0 
  70. MicrosoftOfficeWebServer: 5.0_Pub 
  71. X-Powered-By: ASP.NET 
  72. Date: Thu, 11 Jun 2015 22:14:22 GMT 
  73. ---------------------------------------------------------- 
  74. https://msl.portal.com/unicopin/imagene ... ptcha.ashx 
  75.  
  76. GET /unicopin/imagenes/imgcap/captcha.ashx HTTP/1.1 
  77. Host: msl.portal.com 
  78. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  79. Accept: image/png,image/*;q=0.8,*/*;q=0.5 
  80. Accept-Language: en-US,en;q=0.5 
  81. Accept-Encoding: gzip, deflate 
  82. Referer: https://msl.portal.com/unicopin/paginas/MENSAJE.aspx 
  83. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  84. Connection: keep-alive 
  85.  
  86. HTTP/1.1 200 OK 
  87. Date: Thu, 11 Jun 2015 22:14:22 GMT 
  88. Server: Microsoft-IIS/6.0 
  89. MicrosoftOfficeWebServer: 5.0_Pub 
  90. X-Powered-By: ASP.NET 
  91. X-AspNet-Version: 2.0.50727 
  92. Cache-Control: private 
  93. Content-Type: image/GIF; charset=utf-8 
  94. Content-Length: 2055 
  95. ---------------------------------------------------------- 
  96. https://msl.portal.com/unicopin/imagenes/calen.png 
  97.  
  98. GET /unicopin/imagenes/calen.png HTTP/1.1 
  99. Host: msl.portal.com 
  100. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  101. Accept: image/png,image/*;q=0.8,*/*;q=0.5 
  102. Accept-Language: en-US,en;q=0.5 
  103. Accept-Encoding: gzip, deflate 
  104. Referer: https://msl.portal.com/unicopin/paginas/MENSAJE.aspx 
  105. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  106. Connection: keep-alive 
  107. If-Modified-Since: Fri, 20 Aug 1909 21:17:00 GMT 
  108. If-None-Match: "0ee303c6345a1:31ee" 
  109.  
  110. HTTP/1.1 304 Not Modified 
  111. Last-Modified: Fri, 20 Aug 1909 21:17:00 GMT 
  112. Accept-Ranges: bytes 
  113. Etag: "0ee303c6345a1:31ee" 
  114. Server: Microsoft-IIS/6.0 
  115. MicrosoftOfficeWebServer: 5.0_Pub 
  116. X-Powered-By: ASP.NET 
  117. Date: Thu, 11 Jun 2015 22:14:22 GMT 
  118. ---------------------------------------------------------- 
  119. https://msl.portal.com/unicopin/imagenes/refresh.png 
  120.  
  121. GET /unicopin/imagenes/refresh.png HTTP/1.1 
  122. Host: msl.portal.com 
  123. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  124. Accept: image/png,image/*;q=0.8,*/*;q=0.5 
  125. Accept-Language: en-US,en;q=0.5 
  126. Accept-Encoding: gzip, deflate 
  127. Referer: https://msl.portal.com/unicopin/paginas/MENSAJE.aspx 
  128. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  129. Connection: keep-alive 
  130. If-Modified-Since: Fri, 20 Aug 1909 21:17:00 GMT 
  131. If-None-Match: "0ee303c6345a1:31ee" 
  132.  
  133. HTTP/1.1 304 Not Modified 
  134. Last-Modified: Fri, 20 Aug 1909 21:17:00 GMT 
  135. Accept-Ranges: bytes 
  136. Etag: "0ee303c6345a1:31ee" 
  137. Server: Microsoft-IIS/6.0 
  138. MicrosoftOfficeWebServer: 5.0_Pub 
  139. X-Powered-By: ASP.NET 
  140. Date: Thu, 11 Jun 2015 22:14:22 GMT 
  141. ---------------------------------------------------------- 
  142. https://msl.portal.com/unicopin/imagenes/backimg.png 
  143.  
  144. GET /unicopin/imagenes/backimg.png HTTP/1.1 
  145. Host: msl.portal.com 
  146. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  147. Accept: image/png,image/*;q=0.8,*/*;q=0.5 
  148. Accept-Language: en-US,en;q=0.5 
  149. Accept-Encoding: gzip, deflate 
  150. Referer: https://msl.portal.com/unicopin/css/paginas.css 
  151. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  152. Connection: keep-alive 
  153. If-Modified-Since: Fri, 20 Aug 1909 21:17:00 GMT 
  154. If-None-Match: "0ee303c6345a1:31ee" 
  155.  
  156. HTTP/1.1 304 Not Modified 
  157. Last-Modified: Fri, 20 Aug 1909 21:17:00 GMT 
  158. Accept-Ranges: bytes 
  159. Etag: "0ee303c6345a1:31ee" 
  160. Server: Microsoft-IIS/6.0 
  161. MicrosoftOfficeWebServer: 5.0_Pub 
  162. X-Powered-By: ASP.NET 
  163. Date: Thu, 11 Jun 2015 22:14:22 GMT 
  164. ---------------------------------------------------------- 
  165. https://msl.portal.com/unicopin/imagenes/mail.png 
  166.  
  167. GET /unicopin/imagenes/mail.png HTTP/1.1 
  168. Host: msl.portal.com 
  169. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 
  170. Accept: image/png,image/*;q=0.8,*/*;q=0.5 
  171. Accept-Language: en-US,en;q=0.5 
  172. Accept-Encoding: gzip, deflate 
  173. Referer: https://msl.portal.com/unicopin/css/paginas.css 
  174. Cookie: ASP.NET_SessionId=if2a3guz44im41airong3s55 
  175. Connection: keep-alive 
  176. If-Modified-Since: Fri, 20 Aug 1909 21:17:00 GMT 
  177. If-None-Match: "0ee303c6345a1:31ee" 
  178.  
  179. HTTP/1.1 304 Not Modified 
  180. Last-Modified: Fri, 20 Aug 1909 21:17:00 GMT 
  181. Accept-Ranges: bytes 
  182. Etag: "0ee303c6345a1:31ee" 
  183. Server: Microsoft-IIS/6.0 
  184. MicrosoftOfficeWebServer: 5.0_Pub 
  185. X-Powered-By: ASP.NET 
  186. Date: Thu, 11 Jun 2015 22:14:22 GMT 
  187. ---------------------------------------------------------- 


y el MENSAJE FUE REALIZADO. como vemos eso deberia realizar el script que realize.
jimr1984
Perlero nuevo
Perlero nuevo
 
Mensajes: 123
Registrado: 2012-11-25 07:11 @341

Re: ASP.net cookie HTTPS

Notapor explorer » 2015-06-11 17:16 @761

Pues entonces, no sé dónde está el problema.

Lo único que veo raro es en la forma en la que haces el POST, que no es la normal que recomienda el módulo HTTP::Request.
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14476
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Re: ASP.net cookie HTTPS

Notapor jimr1984 » 2015-06-11 20:59 @916

Estimado en base a las TRAZAS capturadas envío mi código:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!/usr/bin/perl -l
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6.  
  7. use LWP::UserAgent;
  8. use HTTP::Cookies;
  9. use HTTP::Request;
  10. use autodie;
  11.  
  12.  
  13.  
  14.  
  15.  
  16. my $url = "https://msl.portal.com/unicopin/paginas/MENSAJE.aspx";
  17. my $url2="https://msl.portal.com/unicopin/imagenes/imgcap/captcha.ashx";
  18.  
  19.  
  20. my $cookies = HTTP::Cookies->new(
  21.     file     => 'cookies.txt',
  22.     autosave => 1,
  23. );
  24.  
  25. my $http = LWP::UserAgent->new(
  26.     autocheck   => 0,
  27.     ssl_opts    => {
  28.         verify_hostname => 0,
  29.         SSL_verify_mode => 'SSL_VERIFY_NONE',
  30.     },
  31.    
  32. );
  33. $http->cookie_jar($cookies);
  34.  
  35. $http->agent("Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)");
  36.  
  37. my $response = $http->get($url) or die $!;
  38.  
  39. my $succes = $response->is_success() or die $!;
  40. my $code = $response->code() or die $!;
  41.  
  42. print $succes;
  43. print "\n";
  44. print $code;
  45. print $http->cookie_jar->as_string() . "\n";
  46. print "######################################################################################## \n";
  47. my $response2 = $http->get($url2) or die $!;
  48.  
  49. my $succes2 = $response2->is_success() or die $!;
  50. my $code2 = $response2->code() or die $!;
  51.  
  52. print $succes2;
  53. print "\n";
  54. print $code2;
  55. print $http->cookie_jar->as_string() . "\n";
  56.  
  57. open my $PNG, '>', 'captcha.png';        # abrimos en escritura
  58. binmode $PNG;                           # modo binario
  59. #print   $PNG $url_concurso;                   # escribimos la imagen
  60. print $PNG $response2->content;
  61.  
  62. close   $PNG;
  63.  
  64.  
  65. my $comando = qx(tesseract.exe captcha.png captcha);
  66. my $resultado = qx(type captcha.txt);
  67.  
  68. print "RESULTADO ES ".$resultado;
  69. chop($resultado);
  70.  
  71.  
  72. my $q ="txtNombre=JAIME&txtNroTelf=3245865&txtContador=78&txtMensaje=DESDE+LA+WEB&txtCaptcha=$resultado&txtFechaHora=10%2F06%2F2015+20%3A22&btnEnviar=Enviar&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwULLTEwNjcwOTQyMDUPZBYCAgEPZBYCAgEPDxYCHgdWaXNpYmxlaGRkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQxidG5SZWZyZXNjYXIWrHcd8YHfIv5beP7HARL%2FgGF44A%3D%3D&__VIEWSTATEGENERATOR=8BB75E25&__EVENTVALIDATION=%2FwEWCQKi%2Fdj6CAKIgMKjDAL298rXDgKtkMGoCwKy1oITAu%2BZ0b0FAuG%2BousKAoO4powLAt%2Fo6qoMkkiC9lggCxPhcJUsOfcFVHEOoWQ%3D";
  73.  
  74.  
  75.  
  76. print "\n";
  77. print "######################################################################################## \n";
  78. print $q."\n";
  79.  
  80.  
  81. #my $ua = LWP::UserAgent->new;
  82. # $ua->agent("Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)");
  83.  
  84. my $req = HTTP::Request->new(POST => $url);
  85. #$req->content_type('application/x-www-form-urlencoded');
  86. $req->content($q);
  87.  
  88. my $response3 = $http->request($req);
  89. my $content3 = $response3->content(); #contenido de la respuesta
  90.  
  91. print "Content-type: text/html\n\n";
  92. print $content3;
  93. print "\n";
  94.  
  95. print "\n";
  96.  
  97. print $http->cookie_jar->as_string() . "\n";
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4


y este es el POST:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. my $req = HTTP::Request->new(POST => $url);
  2. #$req->content_type('application/x-www-form-urlencoded');
  3. $req->content($q);
  4.  
  5. my $response3 = $http->request($req);
  6. my $content3 = $response3->content(); # contenido de la respuesta
  7.  
  8. print "Content-type: text/html\n\n";
  9. print $content3;
  10. print "\n";
  11.  
  12. print "\n";
  13.  
  14. print $http->cookie_jar->as_string() . "\n";
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4


Por favor, si puede decirme dónde está mi error o qué estoy haciendo mal, cómo debería realizarlo.


Saludos...
jimr1984
Perlero nuevo
Perlero nuevo
 
Mensajes: 123
Registrado: 2012-11-25 07:11 @341

Re: ASP.net cookie HTTPS

Notapor explorer » 2015-06-12 10:21 @473

Quizás el problema está en las líneas 68 y 69.
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. print "RESULTADO ES ".$resultado;
  2. chop($resultado);
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

En la línea 66 estás leyendo el resultado desde un archivo externo, pero no sabemos qué aspecto tiene. Supongo que es el código del captcha, terminado en un fin de línea.

Entonces, en la línea 68 imprimes el valor de $resultado, para comprobar que lo has leído bien. Y luego le quitas el último carácter, con chop().

Bueno, pues hay que hacer dos consideraciones: es mejor sacar el valor de resultado después de hacerle modificaciones y antes de usarlo en la consulta. Y, la segunda consideración, es que parece que estás en Windows. Y eso implica que el carácter de fin de línea en ese sistema operativo se compone de dos bytes (retorno de carro y avance de línea), en lugar de uno solo, como en Linux, UNIX y muchos otros.

Es entonces donde chop() falla: solo quita uno de los bytes.

Es más seguro usar chomp(), que elimina los caracteres de fin de línea que coincidan con los del sistema operativo.

Entonces, es mejor reescribir las líneas así:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. chomp($resultado);
  2. print "RESULTADO ES [$resultado]";
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

Añadiendo los corchetes tenemos además la seguridad de que veremos el contenido real de $resultado, incluyendo espacios en blanco o avance de línea. Te recomiendo que uses este truco en el resto de print(), para comprobar que lo que envías y recibes es lo correcto.
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14476
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Siguiente

Volver a Web

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 5 invitados