#!/usr/bin/perl -Tw # Jon Hart # # Simple perl script to encode a string or file into # its hex equivalent. # # Especially useful against web applications, i.e.: # # http://somesite.com/passwd.html # # translates into... # # http://soemesite.com/%70%61%73%73%77%64%2e%68%74%6d%6c # use strict; if ($ARGV[0]) { my $file = $ARGV[0]; open(FILE, "< $file") or die "Couldn't open $file: $!\n"; while () { encode($_); } close(FILE); } else { while (<>) { encode($_); } } sub encode { my $string = shift; chomp($string); map { printf("%%%x", ord("$_")) } split(//, $string); print("\n"); }