#!/usr/bin/perl -w use strict; # first command line argument is for file containing base64 content my $file = $ARGV[0]; # second command line argument is for the key to use when decoding base64 content my $key = $ARGV[1]; my $decoded = b6( ttt() ); my $fh; open($fh, '>', 'gumblar_file') || die "cant create file: $!\n"; binmode($fh); print $fh $decoded; close($fh); sub b6 { my ($t) = @_; my $d = ""; my ($c1, $c2, $c3, $e1, $e2, $e3, $e4); my $j = 0; my $k = $key; do { $e1 = index($k, substr($t, $j++, 1)); $e2 = index($k, substr($t, $j++, 1)); $e3 = index($k, substr($t, $j++, 1)); $e4 = index($k, substr($t, $j++, 1)); $c1 = ($e1 << 2) | ($e2 >> 4); $c2 = (($e2 & 15) << 4) | ($e3 >> 2); $c3 = (($e3 & 3) << 6) | $e4; $d .= chr($c1); $d .= chr($c2) if $e3 != 64; $d .= chr($c3) if $e4 != 64; } while ($j < length($t)); return $d; } sub ttt { my ($args) = @_; my $ff; my $data; open($ff, $file) || die "cant read $file because: $!\n"; while(<$ff>) { $data .= $_; } close($ff); return $data; }