Category Archives: Linux

STOP IPTABLES

#!/bin/sh
echo "Stopping firewall and allowing everyone..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
Advertisements

Maillog Enhanced Queries

POSTFIX

E-Mails TO specific address ignoring amavis delivered queue “relay=127.0.0.1”

cat postfix| grep -v Greylisting | grep -i "to=<foo@foo>" | grep -Ev 'relay=dfilt|relay=127.0.0.1' | awk '{print $6}' | grep -v NOQUEUE | sort | uniq | while read L; do echo -e "\n------$L------\n" && grep $L postfix; done > output.txt; COUNT=`cat postfix| grep -v Greylisting | grep -i "to=<foo@foo>" | grep -Ev 'relay=dfilt|relay=127.0.0.1' | awk '{print $6}' | grep -v NOQUEUE | sort | uniq | wc -l` && echo -e "\n\nTOTAL CORREOS = $COUNT\n" >> output.txt

E-Mails FROM specific address ignoring amavis delivered queue “relay=127.0.0.1”

cat postfix| grep -i "from=<foo@foo>" | awk '{print $6}' | grep -v NOQUEUE | sort | uniq > temp.queues ; cat temp.queues | while read L; do grep $L postfix| grep -E 'relay=127.0.0.1|relay=dfilt' | awk '{print $6}' ; done > temp.queues.2 ; diff temp.queues temp.queues.2 | grep "<" | awk '{print $2}' | while read Z; do echo -e "\n-----$Z-----\n" && grep $Z postfix; done > output.txt; COUNT=`diff temp.queues temp.queues.2 | grep "<" | wc -l` && echo -e "\n\nTOTAL CORREOS = $COUNT\n" >> output.txt; rm temp.queues* -rf

Calculate navigation size SQUID logs

IP’s used by administrator user

user = administrator

(xzcat *access*.xz; zcat *access*.gz) | grep administrator | awk '{if(data[$3]==0)ips[++cnt]=$3; data[$3]+=$5}END{for(i=1;i<=cnt;i++){print ips[i]" "data[ips[i]]/1048576}}'

IP’s used by impresora¬†user without DENY

(xzcat *access*.xz; zcat *access*.gz) | grep -v TCP_DENIED | awk '$8 ~ /impresora/ {if(data[$3]==0)ips[++cnt]=$3; data[$3]+=$5}END{for(i=1;i<=cnt;i++){print ips[i]" "data[ips[i]]/1048576}}'

List openvpn valid certificates (using index.txt)

list_valid_certificates.sh

#!/bin/bash

# Run this script inside openvpn certificates directory.

rm -fv listado_certificados_validos.txt

CNT=`grep ^V index.txt | wc -l`

for i in 6 7
do
 grep ^V index.txt | cut -d / -f $i | sed 's+/emailAddress++g' | grep ^"CN" >> listado_certificados_validos.txt
done

CNT2=`cat listado_certificados_validos.txt | wc -l`

echo -e "-- VALIDANDO DATOS -- \n"

echo -e $CNT $CNT2" \n"

if [ $CNT2 -eq $CNT ]
then
 cat listado_certificados_validos.txt | sort | nl && echo -e "\nOK"
fi