Skip to content

Instantly share code, notes, and snippets.

View altmas5's full-sized avatar
🏊

Jorge Vallecillo altmas5

🏊
View GitHub Profile
@altmas5
altmas5 / zimbraSetPass.sh
Last active October 8, 2015 13:08
short way to set zimbra accounts password pattern when validity expires because of server conf
#!/bin/bash
# correr como usuario zimbra
# se deja como password el username + contenido de la variable append
# se fuerza al usuario a cambiar la contraseña en el próximo inicio de sesión.
zmprov -l getAllAccounts > cuentas;
append='x0i1*';
for line in $(cat cuentas);
do
@altmas5
altmas5 / removeChars.sh
Created August 13, 2012 02:22
remove chars massively in files of working directory
#!/bin/bash
# usage> ejecutarlo en el mismo directorio donde se encuentran las imagenes
# en el cut se indica a partir de cual caracter va a dejar el nombre
# falta codigo de autodestruccion - one liners rules!
for i in *.jpg; do mv "$i" "`echo $i|cut -c2-`"; done
@altmas5
altmas5 / blacklist
Created August 13, 2012 02:24
shorewall blacklist file of IPs doing DoS attack on my server
#
# For information about entries in this file, type "man shorewall-blacklist"
# Please see http://shorewall.net/blacklisting_support.htm for additional
# Shorewall version 4 - Blacklist File
# information.
###############################################################################
#ADDRESS/SUBNET PROTOCOL PORT
110.84.206.32
110.84.209.87
110.84.235.188
@altmas5
altmas5 / routeNoFb.sh
Created August 13, 2012 02:27
set facebook networks routes to localhost
#!/usr/bin/sh
route add -net 69.63.176.0 netmask 255.255.240.0 gw 127.0.0.1;
route add -net 66.220.144.0 netmask 255.255.240.0 gw 127.0.0.1;
route add -net 66.220.144.0 netmask 255.255.248.0 gw 127.0.0.1;
route add -net 66.220.152.0 netmask 255.255.248.0 gw 127.0.0.1;
route add -net 66.220.159.0 netmask 255.255.255.0 gw 127.0.0.1;
route add -net 69.28.179.0 netmask 255.255.255.0 gw 127.0.0.1;
route add -net 69.63.176.0 netmask 255.255.248.0 gw 127.0.0.1;
route add -net 69.63.184.0 netmask 255.255.248.0 gw 127.0.0.1;
@altmas5
altmas5 / antivirus.sh
Created October 21, 2012 23:02
Ejecución de ClamAV en busca de shells, backdoors y otras MALAS hierbas
#!/bin/bash
resultado="/home/altmas5/scan.txt"
clamscan -r /www/ | grep FOUND > $resultado;
sed -i '/LibClamAV/ d' $resultado;
#guardando size del archivo para evitar correos vacios
TAM=$(stat --printf="%s" $resultado);
if [ "$TAM" != "0" ] #importante el espacio entre if-[-"-"-!=-"-"]
then
echo $resultado | /usr/bin/mail -s "Resultado de antivirus clamAV en servidor web" vos@tudominio.com
@altmas5
altmas5 / switchkbmap.sh
Created November 4, 2012 00:01
switch keybord layout
#!/bin/bash
current=`setxkbmap -query| grep layout| awk '{print $2}'`
echo $current;
if [ $current == "us" ]
then
# echo "Esta en gringo"
setxkbmap es
else
if [ $current == "es" ]
@altmas5
altmas5 / ossec-sms.sh
Created November 27, 2012 23:21
Active response for ossec notified by sms with gnokii
#!/bin/bash
# For including it on your OSSEC conf:
# Requires gnokii
# http://www.ossec.net/doc/manual/ar/ar-custom.html
/usr/bin/gnokii --deletesms ME 1 25;
ACTION=$1
USER=$2
IP=$3
@altmas5
altmas5 / youtube offline playlist
Created December 28, 2012 16:33
download all videos of a playlist on youtube and convert from flv to mp4
#!/bin/bash
# descargar playlist de youtube
# y convertir de flv a mp4 para ver
# offline en dispositivos como PDAs
# uso youtube-dl y ffmpeg
#agrega o linkea youtube-dl a tu PATH
DIR='$HOME/Videos/';
@altmas5
altmas5 / startVMs.sh
Created February 8, 2013 23:50
"Automagically" start all VMs in the free version of citrix xen server on boot time
#!/bin/bash
#invoke this script at the end of /etc/rc.local file
for j in $(/opt/xensource/bin/xe vm-list is-control-domain=false | grep label| awk '{print $4}')
do
/opt/xensource/bin/xe vm-start name-label=$j;
sleep 30;
done
@altmas5
altmas5 / backup-postgresql.sh
Created March 5, 2013 16:54
backup/dump all PostgreSQL local databases 1. dump each database schema 2. dump each database data ***Run as postgres user
#!/bin/bash
timeslot=$(date +"%Y%m%d_%H-%M");
exec > log.$timeslot 2>&1
set -x
DBs=$(psql -l|grep -v 'Name\|Nombre\|:\|rows\|filas\|\---\|databases\|Listado\|postgres\|template'|awk '{print $1}'|grep -v ^\|);
for db in $DBs;
do
pg_dump -sv $db -O > /var/lib/postgresql/bckps/sch_$db-$timeslot.sql;
sleep 5;