#!/usr/bin/perl ## fauxirc.pl - fake IRC server for sandnet use ## (c)2006 Joe Stewart use IO::Socket; use POSIX; my (@user, @nick); my $port = "6667"; #my $topic = "!adv.start lsass 2 1 10 4.5.7.1 -s"; my $topic = "no topic"; my $time = time; print "Starting Faux IRC Server Emulation on port $port\n"; my $sock = IO::Socket::INET->new(LocalAddr => "4.5.6.1", LocalPort => $port, Type => SOCK_STREAM, Reuse => 1, Listen => 10) or die "Fatal: Couldn't bind to port $port (Already in use?)\n"; while ($remote = $sock->accept()) { my ($port, $addr) = unpack_sockaddr_in($remote->peername); my $ip = inet_ntoa($addr); logger("Connection from $ip"); while (<$remote>) { chomp; logger($_); if (/^USER /i) { @user = split(/\s+/); } elsif (/^NICK /i) { @nick = split(/\s+/); my $n = $nick[1]; my $u = $user[1]; if (substr($n,0,9) eq "Drudgebot") { print $remote ":leaf127x865.m00p.org 433 * Drudgebot :Nickname is already in use.\n"; } else { #print $remote qq~:1.1.1.5 001 $n :Welcome to the RoxNet IRC Network $n\!$u\@4.5.6.7 #:1.1.1.5 002 $n :Your host is 1.1.1.5, running version Unreal3.2.2 #:1.1.1.5 003 $n :This server was created Mon Jan 3 2005 at 23:50:34 CST #:1.1.1.5 004 $n 1.1.1.5 Unreal3.2.2 iowghraAsORTVSxNCWqBzvdHtGp lvhopsmntikrRcaqOALQbSeKVfMGCuzNT #:1.1.1.5 005 $n SAFELIST HCN MAXCHANNELS=30 CHANLIMIT=#:30 MAXLIST=b:60,e:60 NICKLEN=30 CHANNELLEN=32 TOPICLEN=307 KICKLEN=307 AWAYLEN=307 MAXTARGETS=20WALLCHOPS WATCH=128 :are supported by this server #:1.1.1.5 005 $n SILENCE=15 MODES=12 CHANTYPES=# PREFIX=(ohv)\@\%+ CHANMODES=beqa,kfL,l,psmntirRcOAQKVGCuzNSMT NETWORK=RoxNet CASEMAPPING=ascii EXTBAN=\~,cqnr ELIST=MNUCT STATUSMSG=\@\%+ EXCEPTS CMDS=KNOCK,MAP,DCCALLOW :are supported by this server #:1.1.1.5 251 $n :There are 1 users and 11403 invisible on 4 servers #:1.1.1.5 252 $n 2 :operator(s) online #:1.1.1.5 253 $n 4 :unknown connection(s) #:1.1.1.5 254 $n 8 :channels formed #:1.1.1.5 255 $n :I have 3661 clients and 1 servers #:1.1.1.5 265 $n :Current Local Users: 3661 Max: 14975 #:1.1.1.5 266 $n :Current Global Users: 11404 Max: 15366 #:1.1.1.5 422 $n :MOTD File is missing #:$n MODE $n :+iw print $remote ":MySQL 001 $n :MySQL $n!\~$n@4.5.6.7\r\n\:MySQL 376 $n :\r\n"; #print $remote qq~:m.0.d NOTICE AUTH :*** Looking up your hostname... #:m.0.d NOTICE AUTH :*** Found your hostname #:m.0.d 001 $n :Welcome to the ROXnet IRC Network $n\! #:m.0.d 002 $n :Your host is m.0.d, running version Unreal3.2.3 #:m.0.d 003 $n :This server was created Tue Jul 19 2005 at 12:38:43PDT #:m.0.d 004 $n m.0.d Unreal3.2.3 iowghraAsORTVSxNCWqBzvdHtGplvhopsmntikrRcaqOALQbSeIKVfMCuzNTGj #:m.0.d 005 $n SAFELIST HCN MAXCHANNELS=5 CHANLIMIT=#:5 MAXLIST=b:60,e:60,I:60 NICKLEN=30 CHANNELLEN=32 TOPICLEN=307 KICKLEN=307 AWAYLEN=307 MAXTARGETS=20 WALLCHOPS WATCH=128 :are supported by this server #:m.0.d 005 $n SILENCE=15 MODES=12 CHANTYPES=# PREFIX=(qaohv)\~&@%+ CHANMODES=beI,kfL,lj,psmntirRcOAQKVGCuzNSMTG NETWORK=ROXnet CASEMAPPING=ascii EXTBAN=\~,cqnr ELIST=MNUCT STATUSMSG=\~&@%+ EXCEPTS INVEX CMDS=KNOCK,MAP,DCCALLOW,USERIP :are supported by this server #:m.0.d 251 $n :There are 33 users and 603 invisible on 1 servers #:m.0.d 252 $n 2 :operator(s) online #:m.0.d 253 $n 10 :unknown connection(s) #:m.0.d 254 $n 10 :channels formed #:m.0.d 255 $n :I have 636 clients and 0 servers #:m.0.d 265 $n :Current Local Users: 636 Max: 688 #:m.0.d 266 $n :Current Global Users: 636 Max: 636 #:m.0.d 422 $n :MOTD File is missing #:$n MODE $n :+iwx #~; sleep 1; #my $channel = "#.R4d1ant1X"; #print $remote "PING :m.0.d\n"; # print $remote qq~:$n\!x\@x.org JOIN :$channel #:m.0.d 332 $n $channel :$topic #:m.0.d 333 $n $channel a $time #:m.0.d 353 $n \@ $channel :$n \@a \@b #:m.0.d 366 $n $channel :End of /NAMES list. #~; } } elsif (/^MODE [A-Za-z0-9]/i) { } elsif (/^JOIN (.*)/i) { my $channel = $1; my $bla; ($channel,$bla) = split(/\s+/, $channel); print $remote ":$n\!x\@x.org JOIN :$channel\r\n:MySQL 332 $n $channel :$topic\r\n:MySQL 333 $n $channel a $time\r\n:MySQL 353 $n \@ $channel :$n \@a \@b\r\n:MySQL 366 $n $channel :End of /NAMES list.\r\n"; } } sleep 5; } sub logger { my $msg = shift; open(OUT,">>/tmp/sandnetirc.log") or return; my $timestamp = POSIX::strftime("%Y-%m-%d-%H:%M:%S:",localtime(time())); print OUT "$timestamp $msg\n"; close OUT; }