bash snippet: dumping function call trace

Posted on Mon 18 July 2011 in Hacks • Tagged with bash, debugging, scriptLeave a comment

Uno snippet di codice bash utile nel debugging di script.

#@.. function:: __cm_exit_error([text],[...])
#@
#@   Stampa la stringa passata in stderr ed esce
#@   Se è impostata la variabile __cm_debug stampa lo stack di chiamata delle funzioni
#@
#@   :param text: la stringa da stampare
#@   :type text: String
#@
__cm_exit_error()

{
        echo "Error in ${FUNCNAME[1]}:${BASH_LINENO ...
Continue reading

cisco IOS contextual config diffs via syslog

Posted on Mon 11 October 2010 in Hacks • Tagged with cisco, cli, syslogLeave a comment

Event amanager applet per salvare il diff tra stratup-config e running-config via syslog.

event manager applet wr-mem-match 
 event cli pattern "wr.* mem.*" sync yes
 action 1.0 cli command "enable"
 action 1.1 cli command "show archive config differences nvram:/startup-config system:/running-config"
 action 1.2 syslog msg "$_cli_result"
 set ...
Continue reading

Authentication username in Astersik SIP peer

Posted on Mon 12 July 2010 in VoIP • Tagged with asterisk, c, patch, VoIPLeave a comment

Asterisk use peername as username during SIP inbound digest authentication.
This patch add authuser parameter in SIP peer definition and use authuser in digest authentication:

Peer definition in /etc/asterisk/sip.conf

...
[pietro](sip-client-base)
authuser=MyUsername
secret=XXXXX
qualify=yes
nat=yes
...

Peer definition in my SIP client (Twinkle)
client configuration

REGISTER ...

Continue reading

GNU/Find posix acl support

Posted on Mon 28 September 2009 in Hacks • Tagged with c, find, gnuLeave a comment

Cercare file che corrispondono a delle acl posix all'interno di un filesystem molto intricato è sempre un delirio.

Questa patch aggiunge l'opzione -acl al comando find (GNU/Findutils).

Esempio d'uso:

$ touch 1 2 3 4
$ mkdir 5
$ setfacl -m u:root:rx 1
$ setfacl -m g:bin ...
Continue reading

Verbose bash history

Posted on Thu 02 July 2009 in HacksLeave a comment

Usando questo codice durante l'inizializzasione della shell viene salvata una command history nel file .bash_verbose_history contenete data e ora, tty (oppure l'ip se l'utente è collegato in ssh) eil comando eseguito. Inoltre evita la sovrascrittura del file .bash_verbose_history e .bash_history eseguendone una copia quando il file raggiunge ...

Continue reading

VPN layer 3 con OpenSSH

Posted on Mon 22 December 2008 in Systems • Tagged with bash, ssh, vpnLeave a comment

Dalla versione 4.3 di OpenSSH è stato introdotto il supporto per TUN/TAP. Questo sigifica che è possibile stabilire un tunnel cifrato tra due peer o due (o piu) reti.
Questo script si occupa di fare il discover dei device tun da utilizzare, assegnare gli indirizzi e le rotte ...

Continue reading

Reading Windows and Office product key

Posted on Wed 17 December 2008 in Hacks • Tagged with product key, python, registry, windowsLeave a comment

I product key di M\$ Windows e Office vengono salvati nel registro in alcune chiavi cifrate
Pygetkey decifra le chiavi e le stampa a video oppure le salva in chiaro in un'altra chiave di registro. Puo' inoltre preleveare i product key da un pc remoto.

Pygetkey è scritto in ...

Continue reading

Worstbit posix acl

Posted on Fri 26 September 2008 in Hacks • Tagged with acl posix, cLeave a comment

Software C che si occupa dell'encode e decode dei filename contenuti nei dump del comando

 getfacl -R

https://github.com/pbertera/junk/tree/master/worstbit

Continue reading

Check_web_form.py

Posted on Wed 24 September 2008 in Systems • Tagged with http, nagios, pythonLeave a comment

Check script di nagios per eseguire il submit di un form e cercare dei valori nella response del server.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31 ...
Continue reading

PowerChute con apcupsd

Posted on Wed 03 September 2008 in Systems • Tagged with apcupsd, backports, debian, linux, powerchuteLeave a comment

Dalla versione 3.14 apcupsd supporta il protocollo PowerChute di APC:

PowerChute Network Shutdown Driver (PCNET)

I backport per Debian etch: http://www.bertera.it/software/apcupsd

Continue reading