Archive for the 'Perl' Category

Parsing HTTP records (one-liner)

Monday, August 15th, 2005

Extracting tripples (host, referrer, GET) from HTTP connection packets (prints stuff on “.”).

perl -ne ‘$get = $1 if /^GET ([^\s]) /; $host = $1 if /^Host: ([^\s])/; $ref=$1 if /^Referer: ([^\s]*)/; if (/^.$/) { print “ID, $host, $get, $ref\n”;}’

Perl one-liner: Adding all new files to SVN

Wednesday, June 22nd, 2005

svn add svn status | perl -ne '/\?\s*(.*)/ && print "$1 "'

Perl injection

Thursday, October 28th, 2004

!/usr/bin/perl -w

use re ‘eval’; #this evil command enables it!

$a = “bla”; $user_input = “(?{print “we’re executing this code ;-) \n”;})”; $a =~ /$user_input/;

!/usr/bin/perl -w

@files=ls $ARGV[0]; print “file list: @files\n”;

Encode URL in perl -one liner

Thursday, October 28th, 2004

perl -e ‘use URI::Escape; while(<>) { chop $; print(uri_escape($).”\n”);} ‘

DB2 log analysis

Wednesday, October 27th, 2004

A cool perl one-liners from Diego:

perl -ne ‘$name = $1 if /application name=(.);/; /text=(.(SELECT|INSERT|UPDATE|DELETE).*$)/i && print “$name => $1\n”;’ db2audit.txt | less

perl -ne ‘/text=(.(SELECT|INSERT|UPDATE|DELETE).$)/i && print “$1\n”‘ db2audit.txt