[mohaa] Rcon Perl Script

[-SF-]Shockwave shockwave at clanshortfuse.com
Thu Oct 24 07:08:46 EDT 2002


Hey guys,

The administration tool I developed will allow remote login and execution of
game server commands and a whole lot more, but it doesn't have built-in
encryption.  I could add a username/password capability to it for better
security if encryption isn't a concern and I believe that this would
accomplish the same thing because I don't think rcon is encrypted either.
The only reasons I haven't added this and a web interface to the tool are
because (1) the tool is already Internet accessible by using an SSH capable
client to connect to the game server which will provide encryption
protection, and (2) nobody mentioned a web interface when I asked for
suggestions.  If this is something you would find useful, I'd be happy to
take a crack at it.  Just give me an idea of what functionality you need.


Shockwave

----- Original Message -----
From: "DocSeuss" <docseuss4977 at hotmail.com>
To: <mohaa at icculus.org>
Sent: Thursday, October 24, 2002 2:34 AM
Subject: Re: [mohaa] Rcon Perl Script


> I'm not absouluty sure that MOH will allow you to remote rcon in, and
based
> on the 5 mins I looked at it, if you can your rcon challenge packet may be
> wrong. I didn't look at your script but used this old one I use to figure
> out which packet msgs get which responses.
>
> Print "this a test<br>";
>
> $serverip = "193.126.109.33";
> $serverport = "12203";
> $cmd="\xff\xff\xff\xff\x02getstatus\n";
> $serverdata = "";
>
>
> $fp = fsockopen("udp://".$serverip, $serverport, $errno, $errstr, 1);
> if (!$fp) {
>  Print "didn't work";
> } else {
>  socket_set_blocking($fp, true);
>  fwrite($fp, $cmd, strlen($cmd));
>  do {
>   $serverdata.=fgetc($fp);
>   $severdatalen++;
>   $socketstatus=socket_get_status($fp);
>  } while ($socketstatus["unread_bytes"]);
>  fclose($fp);
>  print $serverdata;
> }
>
> on running it with the about  packet msg($cmd)  on your server I get the
> following output:
>
> ÿÿÿÿstatusResponse
> \cheats\0\fs_game\realismo/ckr\deathmatch\1\version\Medal of Honor Allied
> Assault 1.11 linux-i386 Jul 23
>
2002\username\None\skill\1\dmflags\0\fraglimit\100\timelimit\15\protocol\8\m
> apname\obj/hanger_se\sv_hostname\KO Clan Fight
>
Ring\sv_maxclients\24\sv_maxRate\0\sv_minPing\0\sv_maxPing\200\sv_floodProte
> ct\1\sv_maplist\obj/obj_team1 obj/obj_team2 obj/obj_team4 obj/hanger_se
> obj/obj_lastcastle2
>
obj/stlo\g_gametype\4\g_gametypestring\Objective-Match\sv_fps\20\sv_allowDow
>
nload\0\Administrator\Rivotti\Email\rivotti at netcabo.pt\URL\www.ko-clan.com\L
> ocation\Portugal\Connection\1
>
Mbit\sv_friction\4\sv_stopspeed\100\sv_waterfriction\1\sv_waterspeed\400\sv_
>
cinematic\0\g_forceready\1\g_allowjointime\1\g_forcerespawn\1\g_maxintermiss
> ion\15\roundlimit\5\nomonsters\0\g_obj_alliedtext1\- Destroy V2 Rocket
> \g_obj_axistext1\- Defend the V2 Rocket\g_scoreboardpic\hanger_se
>
> but with the challenge rcon packet in your script it just times out which
is
> typical if you send a packet that the server doesn't respond to.
>
> if you do find a packetmsg that will allow you to remote rcon in, please
> share.
>                      DocSeuss
>
>
> ----- Original Message -----
> From: "André Rivotti Casimiro" <rivotti at netcabo.pt>
> To: <mohaa at icculus.org>
> Sent: Thursday, October 24, 2002 1:07 AM
> Subject: [mohaa] Rcon Perl Script
>
>
> > Hi all,
> >
> > I'm trying to write a perl script that connects to a mohaa server and
> > executes simple commands and return text. I need this because I'm
> developing
> > a tool to use the browser to show status, kick players, etc. I've been
> > reading a lot of documentation regarding this matter and I stardet to
> > script.
> >
> > #!/usr/bin/perl
> > use IO::Socket;
> > use strict;
> >
> > my $resp = undef;
> > my $num  = undef;
> > my $addr = "193.126.109.33";
> > my $port = 12203;
> > my $pass = "";
> >
> > # create socket connection to server
> > my $sock = IO::Socket::INET->new(
> > PeerAddr => $addr,
> >     PeerPort => $port,
> >     Proto    => 'udp'
> > );
> >
> > print "Socket could not be created: $!\n\n" unless $sock;
> >
> > $sock->send("\xFF\xFF\xFF\xFFchallenge rcon\n");
> > if (defined($sock->recv($resp, 4096))) {
> > if ($resp =~ /^\xFF\xFF\xFF\xFFchallenge\s(\d+)/) {
> > $num = $1;
> > $num =~ s/^\s*//;
> > $num =~ s/\s*$//;
> > } else {
> > print "Error: Server returned wrong message (maybe wrong server
> > version)\n";
> > print "Received: $resp";
> > exit;
> > }
> > }
> >
> > $sock->send("\xFF\xFF\xFF\xFFrcon $num \"$pass\" status\n");
> > if (defined($sock->recv($resp, 4096))) {
> > print "$resp\n";
> > $resp =~ s/\xFF\xFF\xFF\xFFl{0,1}//;    # Remove header stuff
> > $resp =~ s/^\s*//;                      # Remove leading spaces
> > $resp =~ s/\s*$//;                      # Remove trailing spaces
> > print "$resp\n"
> > }
> > close($sock);
> >
> > I think this is correct but it doesn't do nothing. Can anyone help me
> > please? I'm tired of trying solutions and dont get any result.
> >
> > Regards
> > André Rivotti Casimiro
> >




More information about the Mohaa mailing list