(view source code of obscure.pl as plain text)
#! perl
# Run this script without command line arguments for an explanation of the technique used to obscure URLs
# Store the screen messages in variables
$header = "\nObscure.pl, Version 1.10\n";
$header = $header."Obscure an URL by using decimal IP address and fake login name.\n";
$syntax = $syntax."Usage: OBSCURE.PL url [ -DEBUG ]\n\n";
$syntax = $syntax."Where: \"url\" can be any valid URL, host name or IP address\n";
$syntax = $syntax." -DEBUG displays intermediate results\n";
$example = "Explanation:\n";
$example = $example."Let us take the fictional http://somehost.com/sources/ and let's assume\n";
$example = $example."somehost.com's IP address is 1.2.3.4. The decimal representation of the\n";
$example = $example."IP address is: 1 * 256^3 + 2 * 256^2 + 3 * 256 + 4 = 16909060\n";
$example = $example."(try pinging 16909060, it will show 1.2.3.4 as the address being pinged)\n";
$example = $example."So the URL could also be written as http://16909060/sources/\n";
$example = $example."Any URL may be preceded with a (fake) user ID followed by an \@\n";
$example = $example."So we can further obscure the URL by adding a (fake) host as login name:\n";
$example = $example."http://fake.host\@16909060/sources/ still points to http://somehost.com/sources/\n";
$footer = "Note: Security settings of your browser may block use of decimal addresses\n\n";
$footer = $footer."Written by Rob van der Woude\nhttp://www.robvanderwoude.com\n";
# Show help message if no arguments were specified
if ( !@ARGV[0] ) {
die "$header\n$syntax\n$example\n$footer";
}
# Parse command line arguments
$debug = 0;
$error = 0;
foreach ( @ARGV ) {
SWITCH: {
if ( uc( $_ ) eq "-DEBUG" ) {
$debug = 1;
last SWITCH;
}
if ( $_ =~ m/^(((?:ht|f)tp):\/\/)?([^\/]{5,})(\/.*)?$/i ) {
$url = $_;
$protf = $1;
$prota = $2;
$host = $3;
$path = $4;
last SWITCH;
}
# If you arrived at this part of the code,
# an invalid argument was specified, so we
# abort with a help message
die "$header\n$syntax\n$example\n$footer";
}
}
# Show help message if invalid arguments were specified
if ( !$host ) {
die "$header\n$syntax\n$example\n$footer";
}
# If a hostname was specified, convert it to an IP address
if ( $host =~ m/\d+\.\d+\.\d+\.\d+/ ) {
$ip = $host;
} else {
`ping $host -n 1 -w 500` =~ /^[^\[]+\[(\d+\.\d+\.\d+\.\d+)\]/;
$ip = "$1";
}
# Check if we now have a valid IP address, abort if not
if ( $ip =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)/ ) {
if ( $1 > 255 or $2 > 255 or $3 > 255 or $4 > 255 ) {
die"\nERROR: Invalid IP address\n\n\n$header\n$syntax\n$footer";
}
$obsc = (( $1 * 256 + $2 ) * 256 + $3 ) * 256 + $4;
} else {
die "\nERROR: Invalid host name or host not online\n\n\n$header\n$syntax\n$footer";
}
# Display the result
print "$header\n$footer\n\n";
# Display intermediate results when -DEBUG switch was specified
if ( $debug ) {
print "URL = $url\n",
"Protocol = $prota\n",
"Host name = $host\n",
"IP address = $ip\n",
"Decimal IP = $obsc\n",
"Path = $path\n\n";
}
print "Obscured URL examples:\n\n $protf$obsc$path\n",
" $protf"."www.whateveryoulike.here\@$obsc$path\n";
page last modified: 2024-04-16; loaded in 0.0085 seconds