3 #************************************************************************
4 #* IRC - Internet Relay Chat, tools/crypter
5 #* Copyright (C) 1991 Sean Batt
7 #* This program is free software; you can redistribute it and/or modify
8 #* it under the terms of the GNU General Public License as published by
9 #* the Free Software Foundation; either version 1, or (at your option)
12 #* This program is distributed in the hope that it will be useful,
13 #* but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 #* GNU General Public License for more details.
17 #* You should have received a copy of the GNU General Public License
18 #* along with this program; if not, write to the Free Software
19 #* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #* $Id: crypter,v 1.2 2002-03-07 22:52:57 ghostwolf Exp $
24 #From Sean Batt sean@coombs.anu.edu.au
26 #Temporary output file
28 $tmpfile = "/tmp/ircd.conf.tmp";
31 #Original ircd.conf file
35 print "crypting ",$ircdconf,"\n";
36 @saltset = ('a' .. 'z', 'A' .. 'Z', '0' .. '9', '.', '/');
39 open ($ircdout, ">$tmpfile") || die "open $!";
42 #if its not an "O" line we can ignore it
43 $text =~ /^o/i || print ($ircdout $text) && next;
45 @oline = split(':', $text);
46 $salt = $saltset[rand(time)%64].$saltset[(rand(time)>>6)%64];
47 $oline[2] = crypt(@oline[2], $salt);
48 print ($ircdout join(':',@oline)."\n");
52 print "/bin/cp ",$tmpfile," ",$ircdconf,"\n";
53 (fork()==0) ? exec("/bin/cp", $tmpfile, $ircdconf) : wait;
54 print "",$ircdconf," has been crypted successfully!\n";