Pick up content from a captcha or fill out external website form

Asked

Viewed 592 times

0

Good morning, stackoverflow people. I’m going through a problem that I don’t see the light for. I have the following situation: I’m going through a portal, and this portal, I needed to send information to the site in our matrix. So, it makes a select, in this select, is sent via Curl to the form of the other site, until then perfect, only this site has a captcha that has been catching me for a few days.

So, my principal said here, you don’t have to submit the form, you can just fill it out. I wonder if it is possible to do something of the kind, to fill out an external form with the information you need, until before was my original idea.

For example take the id and fill in the value.

$("#User_institution").val(valorQualquer) //no success do ajax.

If it is not possible to do so, I want to know if it is possible to take the captcha generated when I send the POST to Curl and send, as if it were someone filling the captcha.

Att

Request for the page that loads the data and retrieving the json

 $.ajax({
    type: 'POST',
    url: 'load-data.php?id='+id,
    dataType: 'text',
    success: function(data) {
        msg = data;
        var values = $.parseJSON(msg);
        nomeEmpresa = values[0].razao_social;
        emailEmpresa = values[0].email_comercial;
        telefone = values[0].tel_comercial;
        site = values[0].siteweb;
        rua = values[0].end_logradouro;
        numero = values[0].end_numero;
        bairro = values[0].end_bairro;
        estado = values[0].end_eatado;
        cidade = values[0].end_cidade;
        cep = values[0].end_cep;
        nomeResponsavel = values[0].nome;
    },
    error:function(e){
        console.log(e);
    },
    complete: function() {
        sendRequest(nomeEmpresa,emailEmpresa,telefone,site,rua,numero,bairro,cidade,cep,nomeResponsavel);
    }
});

Retrieving information and turning into json

if(isset($_GET['id']) && $_GET['id']) {
$id = $_GET['id'];
$Partner = new Partner();
$Cliques = new clicks();


date_default_timezone_set('America/Sao_Paulo');
$dataRegistro = date("Y-m-d H:i:s");

$Cliques->setDataRegistro($dataRegistro);
$Cliques->setIdPartner($id);

$Partner->updateContCliques($id);


echo json_encode($Partner->listaParceiro($id));


$Cliques->inserir();

}

Information to be sent

function sendRequest(nomeEmpresa,emailEmpresa,telefone,site,rua,numero,bairro,cidade,cep,nomeResponsavel) {



        var myUrl = encodeURIComponent("http://ecoprintq.com/index.php/partnerApplication/create");
        var dados = "User_full_name:"+nomeResponsavel+"&User_institution:"+nomeEmpresa+"&User_email:"+emailEmpresa+"&PartnerApplication_phone:"+telefone+"&PartnerApplication_company_website:"+site+"&PartnerApplication_support_phone:"+telefone+"&PartnerApplication_support_email:"+emailEmpresa;
        $.ajax({
            url: "webproxy.php?url=" + myUrl,
            data:dados,
            crossDomain:true,
            type: "GET",
            timeout: 30000,
            dataType: "text", // "xml", "json"

            success: function(data) {

                window.location.href = "webproxy.php?url=" + myUrl + "&" + dados;

            },
            error: function(jqXHR, textStatus, ex) {
                alert(textStatus + "," + ex + "," + jqXHR.responseText);
            }
        });


    }

Taking the ajax post and sending it to form

<?php
if (empty($_GET['url']) || preg_match('#^(http|https)://[a-z0-9]#i', $_GET['url']) === 0) {
    echo 'URL inválida';
    exit;
}

$url = $_GET['url'];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);

//pega o POST enviado via Ajax
$post = http_build_query($_POST);

//Envia o $post usando CURL
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);


$data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);

if($data === false)
{
    http_response_code(500);
    echo 'Curl error: ' . curl_error($ch);
} elseif ($httpcode !== 200) {
    http_response_code($httpcode);

} else {
    echo $data;
}

That’s what I got now

  • To complement, it is possible to "grab" the image of the captha... But not its value via a program

  • Breaking algorithms of captcha are very specific because they depend on the system that generates the images. For you to have an idea, have tried to do this here deciphering the audio, but it doesn’t seem to work anymore. Another solution is to use OCR see 'Tesseract' and see if it’s worth the effort.

No answers

Browser other questions tagged

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