Taking hidden data with the <noscript> tag file_get_contents

Asked

Viewed 72 times

1

I would like to retrieve a CAPTCHA information from one form and display it in another using the file_get_contents.

It turns out that the page where the data is has the tag <noscript> that warns:

"Please enable javascript in your browser to the service captcha work properly."

which prevents data from being recovered with the file_get_contents.

Is there any function or other way to recover this data by emulating javascript enabled?

This is the site:

https://www2.dataprev.gov.br/sabiweb/consulta/inicio.view#sabiweb

1 answer

2


There is no "emulate a javascript enabled", except that use some Webdriver, but you do not need to emulate.

By quickly analyzing the source code captcha is generated in /sabiweb/captcha-load/, it contains the captcha value (its ID) and also the image and audio path, but you can also get only the headers, in it you will have the JSESSIONID which is the same value.

Soon, you’re making the requisition for the wrong side and I don’t think that’s even necessary, but anyway.


This would be enough to get such code by ignoring security issues:

if($captchaJS = file_get_contents('https://www2.dataprev.gov.br/sabiweb/captcha-load/')){

    preg_match('/([0-9A-Za-z\.\-_]{90,})/', $captchaJS, $achados);

    $Codigo = $achados['0'];
    $Cookie = substr($Codigo, strpos($Codigo, '_', 3) + 1);

}

So just use it:

https://www2.dataprev.gov.br/sabiweb/api/imagem?d= . $Codigo

To load the image. To upload the form use the value of $Codigo and the cookies of $Cookie.


But I guess you don’t even need it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.