Created
May 17, 2015 11:17
-
-
Save ThinkChaos/193fc0c349e16c8c9a17 to your computer and use it in GitHub Desktop.
Perl Netsoul Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Run as: | |
# perl ns.pl | |
use Digest::MD5 qw(md5_hex); | |
use IO::Socket; | |
my $USER = ''; | |
my $PASS = ''; | |
print "Connecting to server\n"; | |
my $sock = IO::Socket::INET->new('ns-server.epita.fr:4242'); | |
print "Waiting for server\n"; | |
my @data = split(' ', $sock->getline); | |
print $data; | |
print "\n"; | |
my ($auth_hash, $my_host, $my_port) = @data[2..4]; | |
print 'auth_ag: '; | |
$r = $sock->send("auth_ag ext_user none none\n"); | |
if (! defined $r) { | |
print "\n"; | |
die "Couldn't send data\n"; | |
} | |
if ($sock->getline != "rep 002 -- cmd end\n") { | |
die "Bad response: auth_ag"; | |
} | |
print "OK\n"; | |
my $my_hash = md5_hex("$auth_hash-$my_host/$my_port$PASS"); | |
$r = $sock->send("ext_user_log $USER $my_hash bijour bijour\n"); | |
if (! defined $r) { | |
print "\n"; | |
die "Couldn't send data: ext_user_log"; | |
} | |
if ($sock->getline != "rep 002 -- cmd end\n") { | |
print "\n"; | |
die "Bad response: ext_user_log"; | |
} | |
print "OK\n"; | |
print "Connected as $USER\n"; | |
while (1) { | |
$data = $sock->getline; | |
print $data; | |
print "\n"; | |
if ($data == "ping\n") { | |
$sock->send("pong\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment