astrutt

cgi-irc decode.pl

Oct 12th, 2017
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.75 KB | None | 0 0
  1. #!/usr/bin/perl
  2. # (C) 2000 David Leadbeater ([email protected])
  3. # cgi-irc comes with ABSOLUTELY NO WARRANTY
  4. # This is free software, and you are welcome to redistribute it
  5. # under certain conditions; read the file COPYING for details
  6.  
  7. # Decode hex ip addresses as found in CGI:IRC whois (realname) output with the
  8. # encode ip addresses option turned on
  9.  
  10. # Now i understand wtf pack and unpack do:
  11. # perl -le'print join ".", unpack "C*",pack "H*", $ARGV[0]'
  12.  
  13. use strict;
  14. use Socket;
  15. my($input,$output);
  16.  
  17. print "Type the Hex IP to decode into a normal IP address\n";
  18. $input=<>;
  19. $input =~ s/[^a-z0-9]//gi;
  20.  
  21. $output = pack "H*", $input;
  22.  
  23. print "IP: " . join(".", unpack "C*", $output) . "\n";
  24. print "Host: " . scalar gethostbyaddr($output, AF_INET) . "\n";
Advertisement
Add Comment
Please, Sign In to add comment