Subdomain Posts
Bash | 206 days ago
Bash | 218 days ago
Bash | 218 days ago
Bash | 218 days ago
Bash | 218 days ago
Bash | 222 days ago
Bash | 222 days ago
Bash | 222 days ago
Perl | 223 days ago
Perl | 306 days ago
Recent Posts
None | 8 sec ago
C | 8 sec ago
None | 8 sec ago
None | 10 sec ago
Python | 12 sec ago
JavaScript | 15 sec ago
C++ | 16 sec ago
None | 42 sec ago
C | 45 sec ago
Java | 46 sec ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By epixoip on the 19th of May 2009 07:54:24 AM Download | Raw | Embed | Report
  1. #!/usr/bin/perl
  2. # Mon May 18 13:33:40 PDT 2009 by epixoip <epixoip@hush.com>
  3. # multi-threaded scanner for webdav-enabled servers. note this
  4. # does NOT tell you if your server is vulnerable to any WebDAV
  5. # exploits! it only tells you if WebDAV is enabled.
  6.  
  7. $|++;
  8. use IO::Socket;
  9. use threads;
  10. use Thread::Queue;
  11. use Term::ANSIColor qw(:constants);
  12. our $starttime : shared;
  13. our $count : shared;
  14. our $hostcnt : shared;
  15. our $thrnum :  shared = 200; # change to adjust performance
  16. our $q : shared;
  17. our %webdav : shared;
  18.  
  19. sub scan {
  20.         my $host = shift;
  21.         my $sock = new IO::Socket::INET (PeerAddr => "$host:http(80)",Timeout => 1);
  22.         if ($sock) {
  23.                 print $sock "OPTIONS * HTTP/1.0\n\n";
  24.                 while (<$sock>) {
  25.                         if ( $_ =~ /^(?:Allow|Public)\:\ (.*(?:COPY|MOVE|MKCOL|PROPFIND|PROPPATCH|LOCK|UNLOCK|SEARCH))/img ) {
  26.                                 $webdav{$host} = $1;
  27.                         }
  28.                 }
  29.                 close $sock;
  30.         }
  31. }
  32.  
  33. sub report {
  34.         print BOLD WHITE."\n\n[".GREEN."+".WHITE."]".RESET." The following hosts were discovered supporting WebDAV:\n";
  35.         while ( my ($key, $value) = each(%webdav) ) { print "\t$key \t=> $value\n"; }
  36.         exit;
  37. }
  38.  
  39. sub main {
  40.         print BOLD WHITE."[".GREEN."+".WHITE."]".RESET." Building queue... ";
  41.         $q = new Thread::Queue;
  42.         my $file = shift;
  43.         open HOSTS, $file or die $!;
  44.         while (<HOSTS>) { chomp $_; $q->enqueue($_); $hostcnt++; }
  45.         close HOSTS;
  46.         print "added $hostcnt hosts\n";
  47.         print BOLD WHITE."[".GREEN."+".WHITE."]".RESET." $thrnum worker thread(s) will be spawned\n";
  48.         print BOLD WHITE."[".GREEN."+".WHITE."]".RESET." WebDAV scan initiated for $hostcnt hosts\n";
  49.         while (1) {
  50.                 my @threads = threads->list;
  51.                 if ($q->pending > 0) {
  52.                         if  ($#threads <= $thrnum + 1) {
  53.                                 threads->new(\&scan, $q->dequeue);
  54.                                 $count++;
  55.                         } else {
  56.                                 foreach $running (@threads) {
  57.                                         $running->join();
  58.                                 }
  59.                         }
  60.                         my $percent = $count / $hostcnt * 100;
  61.                         $width = `tput cols` - 35;
  62.                         $char = ON_GREEN " ". RESET;
  63.                         printf GREEN."---".RESET." %s hosts scanned  %s %.0f%%\r", $count, $char x (($width)*$count/$hostcnt), $percent;
  64.                 } else {
  65.                         if ($#threads > 0) {
  66.                                 foreach $running (@threads) {
  67.                                         $running->join();
  68.                                 }
  69.                         }
  70.                         &report;
  71.                 }
  72.         }
  73. }
  74.  
  75. &main($ARGV[0]);
Submit a correction or amendment below. [ previous version ] | [ difference ] | Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: