WargamesMY CTF 2018: You Math Bro?
Challenge required to answer 30 questions within 40 seconds and clearly requires some form of automation.
Program also throws occasional extra text, make accommodations for it.
1 |
print("y u eval bro");exit(); |
Let’s write a script.
Solution:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#!/usr/bin/perl use IO::Socket::INET; use bigint; $| = 1; my ($socket,$client_socket); $socket = IO::Socket::INET->new ( PeerAddr => "206.189.93.101", PeerPort => "4343", Type => SOCK_STREAM, Proto => "tcp", ) or die "ERROR no socket created :( $!\n"; #Initial keyword expected by server to begin my $start = "start"; print $socket $start . "\n"; my $html = ""; my $buffer = ""; while ( my $line = <$socket> ) { print $line; chomp $line; #Replace 'x' with '*' for multiplication $line =~ tr/x/*/; #Regex capture expression to evaluate if ( $line =~ /(\w.*\s\[.*])\s(\d.*\d)(.*)$/){ my $result = eval($2); print $socket $result . "\n"; } } |
Flag : wgmy{d0_you_ev3n_m4th_br0}