forked from gdestuynder/openvpn-netfilter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f5a5a7
commit 6488590
Showing
3 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#! /usr/bin/env bash | ||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1 | ||
# | ||
# The contents of this file are subject to the Mozilla Public License Version | ||
# 1.1 (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# http://www.mozilla.org/MPL/ | ||
# | ||
# Software distributed under the License is distributed on an "AS IS" basis, | ||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | ||
# for the specific language governing rights and limitations under the | ||
# License. | ||
# | ||
# The Original Code is the vpn-fw-find-user.sh for the OpenVPN Netfilter plugin | ||
# | ||
# The Initial Developer of the Original Code is | ||
# Mozilla Corporation | ||
# Portions created by the Initial Developer are Copyright (C) 2012 | ||
# the Initial Developer. All Rights Reserved. | ||
# | ||
# Contributor(s): | ||
# [email protected] (ulfr) | ||
# | ||
# Alternatively, the contents of this file may be used under the terms of | ||
# either the GNU General Public License Version 2 or later (the "GPL"), or | ||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | ||
# in which case the provisions of the GPL or the LGPL are applicable instead | ||
# of those above. If you wish to allow use of your version of this file only | ||
# under the terms of either the GPL or the LGPL, and not to allow others to | ||
# use your version of this file under the terms of the MPL, indicate your | ||
# decision by deleting the provisions above and replace them with the notice | ||
# and other provisions required by the GPL or the LGPL. If you do not delete | ||
# the provisions above, a recipient may use your version of this file under | ||
# the terms of any one of the MPL, the GPL or the LGPL. | ||
if [ -z $1 ]; then | ||
echo "usage: $0 <user cn>" | ||
echo "search for a vpn user that matches the input, and display all firewall rules" | ||
exit 1 | ||
fi | ||
usercn=$1 | ||
useriplist=$(iptables -L -v -n |grep "$usercn"|grep match-set|awk '{print $11}') | ||
groupslist=$(echo $(iptables -L -v -n |grep "$usercn"|grep match-set|awk '{print $16}')|tr ";" "\n") | ||
|
||
for userip in $useriplist; do | ||
echo -e "\n--- $usercn has IP $userip ---" | ||
echo -e "ldap groups:\n$(for g in $groupslist; do echo "- $g";done)" | ||
echo -e "\n--- IPTABLES RULES ---" | ||
for chain in INPUT OUTPUT FORWARD; do | ||
iptables -L $chain -v -n |grep -E "Chain $chain|$userip" | ||
done | ||
iptables -L $userip -v -n | ||
echo | ||
echo -e "\n--- IPSET HASH TABLE ---" | ||
ipset --list $userip | ||
echo -e "--- end of $usercn $userip ---\n\n" | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#! /usr/bin/env bash | ||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1 | ||
# | ||
# The contents of this file are subject to the Mozilla Public License Version | ||
# 1.1 (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# http://www.mozilla.org/MPL/ | ||
# | ||
# Software distributed under the License is distributed on an "AS IS" basis, | ||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | ||
# for the specific language governing rights and limitations under the | ||
# License. | ||
# | ||
# The Original Code is the vpn-netfilter-clean-ip.sh for OpenVPN Netfilter.py | ||
# | ||
# The Initial Developer of the Original Code is | ||
# Mozilla Corporation | ||
# Portions created by the Initial Developer are Copyright (C) 2012 | ||
# the Initial Developer. All Rights Reserved. | ||
# | ||
# Contributor(s): | ||
# [email protected] (ulfr) | ||
# | ||
# Alternatively, the contents of this file may be used under the terms of | ||
# either the GNU General Public License Version 2 or later (the "GPL"), or | ||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | ||
# in which case the provisions of the GPL or the LGPL are applicable instead | ||
# of those above. If you wish to allow use of your version of this file only | ||
# under the terms of either the GPL or the LGPL, and not to allow others to | ||
# use your version of this file under the terms of the MPL, indicate your | ||
# decision by deleting the provisions above and replace them with the notice | ||
# and other provisions required by the GPL or the LGPL. If you do not delete | ||
# the provisions above, a recipient may use your version of this file under | ||
# the terms of any one of the MPL, the GPL or the LGPL. | ||
if [ -z $1 ]; then | ||
/bin/echo "usage: $0 <user ip>" | ||
/bin/echo "find the firewall rules for a specific VPN IP and delete them all" | ||
exit 1 | ||
fi | ||
userip="$1" | ||
TMP="$(mktemp)-$userip" | ||
/sbin/iptables-save|/bin/grep -E "\-(s|d) $userip/32"|/bin/sed -e "s/-A/\/sbin\/iptables -D/" > $TMP | ||
/bin/echo "/sbin/iptables -F $userip" >> $TMP | ||
/bin/echo "/sbin/iptables -X $userip" >> $TMP | ||
/bin/echo "/usr/sbin/ipset --destroy $userip" >> $TMP | ||
#echo "Stored $(wc -l $TMP|awk '{print $1}') cleanup rules in $TMP" | ||
/bin/bash $TMP | ||
/bin/rm "$TMP" |