Guest User

Untitled

a guest
Jun 11th, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2. #
  3. # see usage() or run eDNS.pl with no command line
  4. # for usage information
  5. #
  6.  
  7. use strict;
  8. use vars qw($myip $firewall $target $username $password $version);
  9. use vars qw($pass $url $sock @result $result $code $domain);
  10. use Getopt::Long;
  11.  
  12. GetOptions('u=s' => \$username, 'p=s' => \$password, 'ip=s' => \$myip, 'd=s' => \$domain);
  13.  
  14. usage() if !$username;
  15. usage() if !$password;
  16.  
  17. # If you're behind a firewall or HTTP proxy, set this to 1.
  18. # If you're not sure, set it to 1; that's the safer setting anyway.
  19. # If you KNOW you're not behind a firewall or proxy, set to 0.
  20. $firewall = 0;
  21.  
  22. # Originally written for hn.org by:
  23. #
  24. # (C)2000-2001 David E. Smith <dave@bureau42.com> and released to the
  25. # public under the terms of the GNU General Public License.
  26. #
  27. # With credits given to:
  28. #
  29. # Modified by Daniel Hagan <dhagan@colltech.com> on 4/2001 to use IO::Socket,
  30. # Syslog, and some error checking. Now logs all output to daemon facility.
  31. #
  32. # Other changes made/suggested by Aurelien Beaujean <aure@dagobah.eu.org>
  33. # Sorry, but I can't type the accent over the first "e" in Aurelien.
  34. #
  35. # It was then hacked up to work with Everydns.net by Dave Fortunato
  36. # <davidf@everydns.net>
  37.  
  38. use MIME::Base64;
  39. use IO::Socket;
  40.  
  41. if ($firewall && !$myip) {
  42. die "Error: IP required as command line argument when \$firewall is set to true.";
  43. }
  44.  
  45. $target = "dyn.everydns.net";
  46. $version = "0.1";
  47. $pass = MIME::Base64::encode_base64("$username:$password");
  48.  
  49. if ($firewall == 1 or $myip) {
  50. $url = "/index.php?ver=$version&ip=$myip" if !$domain;
  51. $url = "/index.php?ver=$version&ip=$myip&domain=$domain" if $domain;
  52. } else {
  53. $url = "/index.php?ver=$version" if !$domain;
  54. $url = "/index.php?ver=$version&domain=$domain" if $domain;
  55. }
  56.  
  57. $sock = new IO::Socket::INET(
  58. PeerAddr => "$target",
  59. PeerPort => 'http(80)'
  60. );
  61.  
  62. if (!$sock) {
  63. print "Connect failed\n\n";
  64. exit(1);
  65. }
  66.  
  67. $sock->autoflush(1);
  68.  
  69. $sock->print("GET $url HTTP/1.0\r\n");
  70. $sock->print("User-Agent: eDNS.pl $version\r\n");
  71. $sock->print("Host: $target\r\n");
  72. $sock->print("Authorization: Basic $pass\r\n\r\n");
  73.  
  74. @result = $sock->getlines();
  75.  
  76. undef $sock; #Close the socket
  77.  
  78. $result = join '', @result;
  79. #print $result; #uncomment for debugging information
  80. $result =~ m/Exit Code: (\d+)/i;
  81. $code = $1;
  82.  
  83. if ($code eq "0" and $myip) {
  84. print "Succeeded in setting domain to $myip.\n";
  85. exit(0);
  86. } elsif ($code eq "0" and !$myip){
  87. print "Succeeded in setting domain to current ip address\n";
  88. exit(0);
  89. } else {
  90. print "Received Exit Code $code, probably failed.\n";
  91. exit(1);
  92. }
  93.  
  94. sub usage {
  95. print "Usage: eDNS.exe -u username -p password -ip IP_Address -d domain\n";
  96. print "Or : eDNS.exe -u username -p password -d domain\n";
  97. print "Or : eDNS.exe -u username -p password\n";
  98. exit(1);
  99. }
Add Comment
Please, Sign In to add comment