#!/usr/bin/perl use IO::Socket; my $welcome_msg = <<"EOT"; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ _ _ 95 _________ ______ ______ _ _ _____ ______ ______ \\ \\ / / | | | | | \\ | | | | | | | | | | | | | | \\ \\ | | >|--|< | | | | | | | |__| | | | | |--| | | | | | | | | |---- /_/ \\_\\ |_| |_| |_| |_| |_| |_|____ |_| |_| _|_|_ |_| |_| |_|____ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ EOT $|=1; $lis = IO::Socket::INET->new (LocalPort => 3002, Type => SOCK_STREAM, Reuse=> 1, Listen => 1000) or die "Error #1 $@\n"; sub x0 { my ($str, $key) = @_; my $enc_str = ''; for my $char (split //, $str){ my $decode = chop $key; $enc_str .= chr(ord($char) ^ ord($decode)); $key = $decode . $key; } $enc_str =~ s/(.)/sprintf("%x",ord($1))/eg; return $enc_str; } while($c = $lis->accept()){ if($pid=fork){ next; }else{ unless (defined $pid) {die "Threads problem $! \n";} $flag=""; print $c $welcome_msg."\n\n"; $authenticated=0; $str2auth=int(rand(20)); print $str2auth; $password = <$c>; chomp($password); if($password eq $str2auth){ $authenticated=1; print $c "\nPassword : \n"; $str=<$c>; chomp($str); $str=~s/X/XX/g; $encoded = x0($str,$str2auth); $encoded =~ tr/!-~/P-~!-O/; my $dd=""; for($i=0;$i<=length($encoded);$i++){ $dd.=hex(ord(substr($encoded,$i,1))+$str2auth); } for($i=0;$i<=$str2auth;$i++){ $pos=hex(chr(ord(substr($encoded,$i,1)+$str2auth))); $dd=~s/2/$pos/g; } if(substr($dd,25,5).substr($dd,35,5).substr($dd,45,5).substr($dd,52,20).substr($dd,80,20) eq '7887487897986588789686597878864878865859865898659687897'){ print $c $flag."\r\n"; } } close $c; exit; } exit; } close $lis;