summaryrefslogtreecommitdiff
path: root/pptpd-1.3.3/tools
diff options
context:
space:
mode:
Diffstat (limited to 'pptpd-1.3.3/tools')
-rwxr-xr-xpptpd-1.3.3/tools/pptp-portslave6
-rwxr-xr-xpptpd-1.3.3/tools/vpnstats55
-rwxr-xr-xpptpd-1.3.3/tools/vpnstats.pl125
-rwxr-xr-xpptpd-1.3.3/tools/vpnuser59
4 files changed, 245 insertions, 0 deletions
diff --git a/pptpd-1.3.3/tools/pptp-portslave b/pptpd-1.3.3/tools/pptp-portslave
new file mode 100755
index 0000000..fbaee83
--- /dev/null
+++ b/pptpd-1.3.3/tools/pptp-portslave
@@ -0,0 +1,6 @@
+#!/bin/bash
+export PORTSLAVELOGNAME="AutoPPP"
+export PORTSLAVE_SESSION=`date +%s``printf "%X" $RANDOM`
+export PORTSLAVE_START_TIME=`date +%s`
+export PORTSLAVE_DO_ACCT="1"
+exec /usr/sbin/pppd $* plugin /usr/lib/libpsr.so
diff --git a/pptpd-1.3.3/tools/vpnstats b/pptpd-1.3.3/tools/vpnstats
new file mode 100755
index 0000000..bfc9a3d
--- /dev/null
+++ b/pptpd-1.3.3/tools/vpnstats
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# vpnstats Get commaseparated file and mail it to the admin
+# Version 1.0 beta by Richard de Vroede - Linvision BV <richard@linvision.com>
+#
+
+# check for conf file, else create with defaults
+CONF=/etc/vpnstats.conf
+if [ ! -f $CONF ]; then
+ echo "LOGFILE=/var/log/messages.1" > $CONF
+ echo "STATFILE=/var/log/vpnstats" >> $CONF
+ echo "TEMPFILE=/tmp/tmpvpnstats" >> $CONF
+ echo "SMTP=localhost" >> $CONF
+ echo "FROM=" >> $CONF
+ echo "TO=" >> $CONF
+fi
+. $CONF
+
+# check for weekly crontab, else create it
+CRON=/etc/cron.weekly/vpnstats.cron
+if [ ! -f $CRON ]; then
+ echo "#!/bin/bash" > $CRON
+ echo "$0" >> $CRON
+ chmod 755 $CRON
+fi
+
+echo "Name,Login,Logout,Connected Minutes,Recieved Bytes,Transmitted Bytes" > $STATFILE
+PPPDPID=$(grep "peer authentication succeeded" $LOGFILE | cut -d [ -f2 | cut -d ] -f 1)
+while [ "$PPPDPID" != "" ]; do
+ PID=$(echo $PPPDPID | awk '{print $1}')
+ grep $PID $LOGFILE | grep pppd | grep -v pptpd > $TEMPFILE
+ NAME=$(grep "succeeded for" $TEMPFILE | awk -F "succeeded for" '{print $2}' | cut -d " " -f 2)
+ LOGIN=$(grep "succeeded for" $TEMPFILE | cut -d " " -f 1-3)
+ LOGOUT=$(grep "Connect time" $TEMPFILE | cut -d " " -f 1-3)
+ CONNECT=$(grep "Connect time" $TEMPFILE | cut -d ] -f 2 | cut -d " " -f 4)
+ RXB=$(grep "Sent" $TEMPFILE | cut -d ] -f 2 | cut -d " " -f 3)
+ TXB=$(grep "Sent" $TEMPFILE | cut -d ] -f 2 | cut -d " " -f 6)
+ echo "$NAME,$LOGIN,$LOGOUT,$CONNECT,$RXB,$TXB" >> $STATFILE
+ PPPDPID=$(echo $PPPDPID | sed "s%$PID%%")
+ rm -f $TEMPFILE
+done
+
+MAILER=$(echo $(locate sendEmail) | awk '{print$1}')
+if [ "$MAILER" != "" ]; then
+ if [ "$FROM" = "" ]; then FROM=root@`uname -n`; fi
+ if [ "$TO" = "" ]; then TO=root@localhost; fi
+ $MAILER -s $SMTP -u "VPNstats" -f $FROM -t $TO -m " " -a $STATFILE
+else
+ if [ -f "/bin/mail" ]; then
+ cat $STATFILE | /bin/mail -s "VPNstats" $TO
+ else
+ echo "You need /bin/mail OR"
+ echo "the Perl program sendEmail located at http://freshmeat.net/projects/sendemail/"
+ fi
+fi
diff --git a/pptpd-1.3.3/tools/vpnstats.pl b/pptpd-1.3.3/tools/vpnstats.pl
new file mode 100755
index 0000000..1688d98
--- /dev/null
+++ b/pptpd-1.3.3/tools/vpnstats.pl
@@ -0,0 +1,125 @@
+#!/usr/bin/perl -w
+use strict;
+#
+# vpnstats - generate list of VPN connections from PPTP+PPP log messages
+# copyright (C) 2002 Scott Merrill (skippy@skippy.net)
+#
+# usage: vpnstats /var/log/messages
+#
+# version 1.4 09-09-2003
+# - thanks to Masaya Miyamoto (miyamo@po.ntts.co.jp)
+# and David Fuzishima (david_f@zipmail.com.br) for fixing the
+# date/time regexes to catch single-digit days (9 instead of 09).
+#
+# version 1.3
+# - thanks to Andy Behrens <andy.behrens@coat.com> for
+# fixing up the regex to catch extraneous whitespace, and
+# domain names that inlucde numbers and underscores.
+# - I modified the output to report when a user is still connected
+# - thanks to Wolfgang Powisch for fixing hostnames included a "-"
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+my @messages = ();
+my %PID_USER = ();
+my %PID_IP = ();
+my %PID_LENGTH = ();
+my %PID_SENT = ();
+my %PID_RECEIVED = ();
+my %PID_DATETIME = ();
+my %USER_TOTAL_CONNECT = ();
+my %USER_TOTAL_TIME = ();
+my %USER_TOTAL_SENT = ();
+my %USER_TOTAL_RECEIVED = ();
+my %vpnstats = ();
+
+@messages = <>;
+
+# for each line of input
+foreach my $x (@messages) {
+ if ($x =~ /^(\w+\s+\d+\s\d+:\d+:\d+)\s # $1 = date+time
+ \S+\spppd\[(\d+)\]:\s # $2 = PID
+ MSCHAP-v2\speer\sauthentication\ssucceeded\sfor\s
+ # I don't want the DOMAIN\\ prefix
+ (.+\\)*(\w+)$ # $4 = username
+ /x) {
+ $PID_USER{$2} = $4;
+ $PID_DATETIME{$2} = $1;
+ $USER_TOTAL_CONNECT{$4}++;
+ } elsif ($x =~ /^(\w+\s+\d+\s\d+:\d+:\d+)\s # $1 = date+time
+ \S+\spppd\[(\d+)\]:\s # $2 = PID
+ Connect\stime\s
+ (\d*\.\d*) # $3 = minutes
+ \sminutes\.$
+ /x) {
+ $PID_LENGTH{$2} = $3;
+ $USER_TOTAL_TIME{$PID_USER{$2}} += $3;
+ } elsif ($x =~ /^(\w+\s+\d+\s\d+:\d+:\d+)\s # $1 = date+time
+ \S+\spppd\[(\d+)\]:\s # $2 = PID
+ Sent\s(\d+)\sbytes,\s # $3 = bytes sent
+ received\s(\d+)\s # $4 = bytes received
+ /x) {
+ $PID_SENT{$2} = $3;
+ $PID_RECEIVED{$2} = $4;
+ $USER_TOTAL_SENT{$PID_USER{$2}} += $3;
+ $USER_TOTAL_RECEIVED{$PID_USER{$2}} += $4;
+ } elsif ($x =~ /^(\w+\s+\d+\s\d+:\d+:\d+)\s # $1 = date+time
+ \S+\spptpd\[(\d+)\]:\s # $2 = PID
+ CTRL:\sClient\s
+ (\d+\.\d+\.\d+\.\d+)\s # $3 = IP
+ control\sconnection\sfinished$
+ /x) {
+ $PID_IP{($2+1)} = $3;
+ if (!defined ($PID_USER{($2+1)})) {
+ $PID_DATETIME{($2+1)} = $1;
+ $PID_USER{($2+1)} = "FAILED";
+ $USER_TOTAL_CONNECT{"FAILED"}++;
+ }
+ }
+}
+foreach my $user (sort keys %USER_TOTAL_CONNECT) {
+ if (! defined $user) { next };
+ if ($user ne "FAILED") {
+ print $user, ": ", $USER_TOTAL_CONNECT{$user}, " connections, ";
+ print $USER_TOTAL_TIME{$user}, " minutes (";
+ print $USER_TOTAL_SENT{$user}, " sent, ";
+ print $USER_TOTAL_RECEIVED{$user}, " received).\n";
+ foreach my $pid (sort keys %PID_DATETIME) {
+ if ($user eq $PID_USER{$pid}) {
+ print " ";
+ print $PID_DATETIME{$pid}, ": connected ";
+ if ($PID_IP{$pid}) {
+ print "from $PID_IP{$pid} ";
+ print "for $PID_LENGTH{$pid} minutes.\n";
+ } else {
+ print "<still connected>\n";
+ }
+ }
+ }
+ }
+}
+if (defined $USER_TOTAL_CONNECT{"FAILED"}) {
+ print "\n\n";
+ print "FAILED CONNECTION ATTEMPTS: ";
+ print $USER_TOTAL_CONNECT{"FAILED"}, "\n";
+ foreach my $pid (sort keys %PID_DATETIME) {
+ if ($PID_USER{$pid} eq "FAILED") {
+ print " ";
+ print $PID_DATETIME{$pid}, ": attempt from ";
+ print $PID_IP{$pid}, "\n";
+ }
+ }
+}
+
diff --git a/pptpd-1.3.3/tools/vpnuser b/pptpd-1.3.3/tools/vpnuser
new file mode 100755
index 0000000..814027c
--- /dev/null
+++ b/pptpd-1.3.3/tools/vpnuser
@@ -0,0 +1,59 @@
+#! /bin/sh
+#
+# vpnuser Add/Del user to chap-secrets for VPN
+# Version 1.0 beta by Richard de Vroede - Linvision BV
+# Ideas or worshipping to: richard@linvision.com
+#
+
+config="/etc/ppp/chap-secrets"
+ERROR="Usage:\n$0 add <username> <passwd> or\n$0 del <username> or\n$0 show [<username>] or\n$0 domain <username> <domain>"
+
+# See how we were called.
+case "$1" in
+ add)
+ if [ "$(echo $2)" != "" ] & [ "$(echo $3)" != "" ]; then
+ echo -e "$2\t*\t$3\t*" >> $config
+ chmod 600 $config
+ else
+ echo -e $ERROR
+ exit 1
+ fi
+ ;;
+ del)
+ if [ "$(echo $2)" != "" ]; then
+ grep -vw "$2" $config > /tmp/vpnblaat
+ mv /tmp/vpnblaat $config
+ chmod 600 $config
+ else
+ echo -e $ERROR
+ exit 1
+ fi
+ ;;
+ show)
+ echo -e "User\tServer\tPasswd\tIPnumber"
+ echo "---------------------------------"
+ if [ "$(echo $2)" != "" ]; then
+ grep -w $2 $config
+ else
+ cat $config
+ fi
+ ;;
+ domain)
+ if [ "$(echo $2)" != "" ] & [ "$(echo $3)" != "" ]; then
+ grep -vw "$2" $config > /tmp/vpnblaat
+ DATA=`grep -w "$2" $config`
+ mv /tmp/vpnblaat $config
+ DOM=`echo $3 | tr a-z A-Z`
+ dom=`echo $3 | tr A-Z a-z`
+ echo "$DOM\\\\$DATA" >> $config
+ echo "$dom\\\\$DATA" >> $config
+ chmod 600 $config
+ else
+ echo -e $ERROR
+ exit 1
+ fi
+ ;;
+ *)
+ echo -e $ERROR
+ exit 1
+esac