#!/usr/bin/perl -w # Fill in your Art of DNS hostname and password here # (Go to http://www.dnsart.com/ to get an account) # $CONF_HOST = "username.dnsart.com"; $CONF_PASS = "password"; # If your ISP doesn't let you connect directly on port 80 # (e.g. they use a proxy server) then # use 7777 instead of 80 on the line below $CONF_PORT = "80"; ################################################## # # The Art of DNS - FreeBSD / Linux client # Copyright (C) 2001 The Art of DNS # support@dnsart.com # 22-Jan-2001 # # Requires the following modules (available from CPAN): # # Crypt::PasswdMD5 (relies on Digest::MD5) # LWP::Simple # URI::Escape # # The easiest way to get these modules is: # perl -MCPAN -eshell # then at the cpan> prompt type: # install MD5 # install Crypt::PasswdMD5 # install LWP::Simple # install URI::Escape # for whatever modules you are missing # # Usage: # dnsping [hostname] [password] # where hostname and password can both be # hardcoded in the program file. (See above) # # Revision History: # # v1.0.1 22 Jan 2001 (JasonW) # - Added support to connect on # alternate port, to bypass HTTP proxies. # # v1.0.0 09 Jan 2001 (JasonW) # - Initial version # ################################################## # No User Serviceable Parts below this line ################################################## use Crypt::PasswdMD5; use LWP::Simple; use URI::Escape; # either grab the hostname and/or password from # the command line, or use the coded values from # above $hostname = shift || $CONF_HOST; $password = shift || $CONF_PASS; # Where to make our requests for challenge and auth $url = "http://www.dnsart.com:$CONF_PORT"; $challenge_url = "$url/challenge.php?u=$hostname"; $auth_url= "$url/auth.php?u=$hostname&p="; # We'll add the password on later # Grab the challenge. unless (defined ($content = get $challenge_url)) { die "could not get $challenge_url\n"; } # Make sure the challenge result is in the format / split it up # into the password salt and the challenge salt. if ($content =~ /(\$1\$.{8}\$)\n(\$1\$.{8}\$)\n.*/) { $salt = $1; $chal = $2; } else { die "Challenge message malformed\n"; } # Do the double crypt, so that the server will be able to compare $cryptedpassword = unix_md5_crypt(unix_md5_crypt($password, $salt),$chal); # Removed any "bad" characters that will cause HTML trouble $cryptedpassword = uri_escape("$cryptedpassword"); # Tack the password onto the URL we defined above, now that we # know what it's going to be. $auth_url = $auth_url . $cryptedpassword; # Sent the auth request; spit out the result unless (defined ($content = get $auth_url)) { die "could not get $auth_url\n"; } print "$content"; # EOF