Security Override - Programming 4::5
















#!/usr/bin/perl

use strict;
use warnings;
use v5.14.2;
use LWP::UserAgent;
use HTTP::Cookies;
use CGI;
use WWW::Mechanize;
use HTML::TokeParser;
use HTML::TreeBuilder;
use File::Temp;
use URI::file;
use WWW::Mechanize::TreeBuilder;
use HTML::Parser;
use HTML::TagParser;
use Math::Round;
use POSIX qw/floor/;


my $browser = LWP::UserAgent->new;
$browser->default_header('cookie','fusion_visited=yes; _ga=GA1.2.295753280.1415196559; PHPSESSID=09bc1dd98752875f4d0ba54dcf921997; _gat=1; fusion_user=17026.140eeff22ac6169bbf2bc84f64b8b218; fusion_lastvisit=1419003317');

my $req = HTTP::Request->new(GET => 'http://securityoverride.org/challenges/programming/4/index.php');
my $res = $browser->request($req);

# write the data to disk
my $fh = File::Temp->new;
print $fh $res->content;
$fh->close;

my $parser = HTML::TagParser->new($fh->filename);
my @list = $parser->getElementsByTagName('code');

my $word = '';
my $text = '';

foreach my $elem ( @list ) {
my $tagname = $elem->tagName;
    my $attr = $elem->attributes;
    $text = $elem->innerText;
    $word = $text;
    #say $text;
}

say $text;
say $text*sqrt(5);

my $risultato =  floor($text*sqrt(5));
say $risultato;


#my @treparole = split(',', $text);
#@treparole = sort @treparole;

#say $stringarimanente;
#my $stringainversa = scalar reverse $stringarimanente;
#say $stringainversa;
#my $stringarisultato = $firstchar.$stringainversa;
#say $stringarisultato;


my $url = 'http://securityoverride.org/challenges/programming/4/index.php';
my $parameter = ([ 'string' => $risultato, 'submitbutton' => '12 seconds to Submit', 'CSRF_TOKEN' => "<?php echo \$_SESSION[\'CSRF_TOKEN\'];?>" ]);
my $response = $browser->post($url, $parameter);
#say $response->content;

##################################################################################################

#!/usr/bin/perl

use strict;
use warnings;
use v5.14.2;
use LWP::UserAgent;
use HTTP::Cookies;
use CGI;
use WWW::Mechanize;
use HTML::TokeParser;
use HTML::TreeBuilder;
use File::Temp;
use URI::file;
use WWW::Mechanize::TreeBuilder;
use HTML::Parser;
use HTML::TagParser;
use Math::Round;
use POSIX qw/floor/;


my $browser = LWP::UserAgent->new;
$browser->default_header('cookie','fusion_visited=yes; _ga=GA1.2.295753280.1415196559; PHPSESSID=09bc1dd98752875f4d0ba54dcf921997; _gat=1; fusion_user=17026.140eeff22ac6169bbf2bc84f64b8b218; fusion_lastvisit=1419003317');

my $req = HTTP::Request->new(GET => 'http://securityoverride.org/challenges/programming/5/index.php');
my $res = $browser->request($req);

# write the data to disk
my $fh = File::Temp->new;
print $fh $res->content;
$fh->close;

my $parser = HTML::TagParser->new($fh->filename);
my @list = $parser->getElementsByTagName('code');

my $word = '';
my $text = '';

foreach my $elem ( @list ) {
my $tagname = $elem->tagName;
    my $attr = $elem->attributes;
    $text = $elem->innerText;
    $word = $text;
    #say $text;
}

say $text;

my @chars = split("", $text);
my $i=0;
my $j=0;
my $k=1;
my %hash = ();
my @risultato = ();

for ($i=0; $i<250; $i++) {
print $chars[$i];
if ((($i+1) % 50)==0) {
print "\n";
}
}

$i=0;


my $r=0;

for ($i=0; $i<250; $i++) {
#say $k;

if ($chars[$i] eq '@') {
say $chars[$i];
say $k;
say $j;
$hash{$k}.=$j;

$risultato[$r]=$k."-".$j.",";

$r++;

}
$j++;
if ((($i+1) % 50)==0) {
$j = 0;
$k++;
}


}

my $risultatofinale ='';

#foreach my $key (keys %hash) {
# $risultato .= $key."-".$hash{$key}.",";
#
#}

foreach my $indice (@risultato) {
$risultatofinale .= $indice;

}


my $size = length($risultatofinale);

my $risfinale = substr($risultatofinale,0, $size-1);

say $risfinale;

my $url = 'http://securityoverride.org/challenges/programming/5/index.php';
my $parameter = ([ 'string' => $risfinale, 'submitbutton' => '12 seconds to Submit', 'CSRF_TOKEN' => "<?php echo \$_SESSION[\'CSRF_TOKEN\'];?>" ]);
my $response = $browser->post($url, $parameter);
#say $response->content;




Categories: Share

Leave a Reply