Guest User

Untitled

a guest
Sep 8th, 2011
707
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2. # Copyright (c) 2011, Stephan Chenette and David Saunders
  3. # All rights reserved.
  4. #
  5. # Redistribution and use in source and binary forms, with or without modification,
  6. # are permitted provided that the following conditions are met:
  7. #
  8. # * Redistributions of source code must retain the above copyright notice,
  9. # this list of conditions and the following disclaimer.
  10. # * Redistributions in binary form must reproduce the above copyright notice,
  11. # this list of conditions and the following disclaimer in the documentation
  12. # and/or other materials provided with the distribution.
  13. #
  14. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  17. # IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  18. # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  19. # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  21. # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  22. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  23. # THE POSSIBILITY OF SUCH DAMAGE.
  24.  
  25. use warnings;
  26. use strict;
  27.  
  28. use Net::DNS;
  29.  
  30. my $DEBUG = 1;
  31.  
  32. my $google_public_dns = "8.8.8.8";
  33.  
  34. my $host = $ARGV[0];
  35.  
  36. if ( !defined $host ) {
  37. print STDERR "Usage: $0 HOST\n";
  38. exit 1;
  39. }
  40.  
  41. print "host: " . $host . "\n" if ($DEBUG);
  42.  
  43. my $res = Net::DNS::Resolver->new;
  44. $res->nameservers( $google_public_dns );
  45.  
  46. # Important to specify a 'TXT' query
  47. my $query = $res->search( $host, 'TXT' ) or die "NULL\n";
  48.  
  49. foreach my $rr ( $query->answer ) {
  50. next unless $rr->type eq 'TXT';
  51. print "key:\n" . $rr->txtdata . "\n";
  52. }
RAW Paste Data