diff -u nsec3walker-20101223/collect nsec3walker-javantea/collect
--- nsec3walker-20101223/collect	2010-12-24 01:49:40.000000000 -0800
+++ nsec3walker-javantea/collect	2015-02-15 09:47:27.503783003 -0800
@@ -4,7 +4,11 @@
 import subprocess
 import binascii
 import sys
-import bsddb
+try:
+  import bsddb
+except ImportError:
+  import bsddb3 as bsddb
+#end try
 import os
 
 r = random.SystemRandom()
@@ -12,14 +16,14 @@
 domain = "org"
 if len(sys.argv) >= 2:
   domain = sys.argv[1]
-
+domain = domain.strip('.')
 servers = []
 
 if len(sys.argv) >= 3:
   for i in range(2,len(sys.argv)):
     servers.append(sys.argv[i])
 else:
-  x = subprocess.Popen(["dig","+short","ns",domain],stdout=subprocess.PIPE).stdout
+  x = subprocess.Popen(["dig","+short","ns",domain + '.'],stdout=subprocess.PIPE).stdout
   for s in x:
     y = subprocess.Popen(["dig","+short",s.strip()],stdout=subprocess.PIPE).stdout
     for i in y:
@@ -28,6 +32,9 @@
 print "domain",domain
 for i in range(len(servers)):
   print "server",servers[i]
+if len(servers) == 0:
+  print "No servers found. Exiting."
+  exit(1)
 
 fntodo = "collect.todo."+str(os.getpid())
 todo = bsddb.btopen(fntodo,"n")
@@ -40,7 +47,7 @@
 nexthash = {}
 
 while len(todo) > 0 or len(nexthash) == 0:
-  if salt:
+  if salt != 0:
     x = hashes.readline().split()
     h = x[0]
     guess = x[1]
@@ -79,54 +86,63 @@
       # if y[0] == "nsec3" and y[1] in nexthash:
       #   print "again",y[1],y[2]
       if y[0] == "nsec3" and not y[1] in nexthash:
-        if not salt:
-          print "salt",y[3]
-          print "iterations",y[4]
-          salt = binascii.a2b_hex(y[3])
-          iterations = int(y[4])
-	  hashprocess = subprocess.Popen(["./randomhashes",domain,y[4],y[3]],stdout=subprocess.PIPE)
+        # NSEC3 parser
+        nexthash1  = y[1]
+        nexthash2  = y[2]
+        salt_query = y[3]
+        iter_query = y[4]
+        if (salt_query == '-' or len(salt_query) & 1 == 1):
+          salt_query = ''
+        if salt == 0:
+          print "salt",salt_query
+          print "iterations",iter_query
+          salt = binascii.a2b_hex(salt_query)
+          iterations = int(iter_query)
+	  hashprocess = subprocess.Popen(["./randomhashes",domain,iter_query,salt_query],stdout=subprocess.PIPE)
 	  hashes = hashprocess.stdout
-	if salt != binascii.a2b_hex(y[3]):
-	  print "newsalt",binascii.a2b_hex(y[3])
-        print "nexthash "+y[1]+" "+y[2]
-        nexthash[y[1]] = y[2]
+	if salt != binascii.a2b_hex(salt_query):
+	  # This shouldn't happen, but it seems to be with by.
+	  print "newsalt", salt_query
+        print "nexthash "+nexthash1+" "+nexthash2
+        nexthash[nexthash1] = nexthash2
         if len(todo) == 0:
-          todo[y[2]] = y[1]
+          todo[nexthash2] = nexthash1
         else:
-	  if y[1] in todo:
-	    if y[1] < y[2] and y[2] < todo[y[1]]:
-	      todo[y[2]] = todo[y[1]]
-	      del todo[y[1]]
-	    elif todo[y[1]] < y[1] and y[1] < y[2]:
-	      todo[y[2]] = todo[y[1]]
-	      del todo[y[1]]
-	    elif y[2] == todo[y[1]]:
-	      del todo[y[1]]
-	    elif y[2] == nexthash[todo[y[1]]]:
-	      del todo[y[1]]
+	  if nexthash1 in todo:
+	    if nexthash1 < nexthash2 and nexthash2 < todo[nexthash1]:
+	      todo[nexthash2] = todo[nexthash1]
+	      del todo[nexthash1]
+	    elif todo[nexthash1] < nexthash1 and nexthash1 < nexthash2:
+	      todo[nexthash2] = todo[nexthash1]
+	      del todo[nexthash1]
+	    elif nexthash2 == todo[nexthash1]:
+	      del todo[nexthash1]
+	    elif nexthash2 == nexthash[todo[nexthash1]]:
+	      del todo[nexthash1]
 	  else:
             x = todo.last()
-	    if x[1] < x[0] and ((x[0] <= y[1] and y[1] <= y[2]) or (x[0] <= y[1] and y[2] <= x[1]) or (y[1] <= y[2] and y[2] <= x[1])):
-              if y[2] != x[1]:
-                todo[y[2]] = x[1]
-              todo[x[0]] = y[1]
-	    elif x[1] < x[0] and ((x[0] <= y[1] and y[2] == nexthash[x[1]]) or (y[1] <= x[1] and y[2] == nexthash[x[1]])):
-              todo[x[0]] = y[1]
-            elif x[0] <= y[1] and y[1] < y[2] and y[2] <= x[1]:
-              if y[2] != x[1]:
-                todo[y[2]] = x[1]
-              todo[x[0]] = y[1]
-	    elif y[2] == nexthash[x[1]] and x[0] <= y[1] and y[1] <= x[1]:
+	    if x[1] < x[0] and ((x[0] <= nexthash1 and nexthash1 <= nexthash2) or (x[0] <= nexthash1 and nexthash2 <= x[1]) or (nexthash1 <= nexthash2 and nexthash2 <= x[1])):
+              if nexthash2 != x[1]:
+                todo[nexthash2] = x[1]
+              todo[x[0]] = nexthash1
+	    elif x[1] < x[0] and ((x[0] <= nexthash1 and nexthash2 == nexthash[x[1]]) or (nexthash1 <= x[1] and nexthash2 == nexthash[x[1]])):
+              todo[x[0]] = nexthash1
+            elif x[0] <= nexthash1 and nexthash1 < nexthash2 and nexthash2 <= x[1]:
+              if nexthash2 != x[1]:
+                todo[nexthash2] = x[1]
+              todo[x[0]] = nexthash1
+	    elif nexthash2 == nexthash[x[1]] and x[0] <= nexthash1 and nexthash1 <= x[1]:
 	      del todo[x[0]]
-	    elif todo.first()[0] <= y[1] and y[1] <= todo.last()[0]:
-	      todo.set_location(y[1])
+	    elif todo.first()[0] <= nexthash1 and nexthash1 <= todo.last()[0]:
+	      todo.set_location(nexthash1)
 	      x = todo.previous()
-              if x[0] <= y[1] and y[1] < y[2] and y[2] <= x[1]:
-                if y[2] != x[1]:
-                  todo[y[2]] = x[1]
-                todo[x[0]] = y[1]
-	      elif y[2] == nexthash[x[1]] and x[0] <= y[1] and y[1] <= x[1]:
+              if x[0] <= nexthash1 and nexthash1 < nexthash2 and nexthash2 <= x[1]:
+                if nexthash2 != x[1]:
+                  todo[nexthash2] = x[1]
+                todo[x[0]] = nexthash1
+	      elif nexthash2 == nexthash[x[1]] and x[0] <= nexthash1 and nexthash1 <= x[1]:
 	        del todo[x[0]]
+          #end NSEC3 parser
 	if len(nexthash) > len(todo):
 	  print "stats",len(todo),numhashes,numqueries,len(nexthash),"maybe",(len(nexthash)*len(nexthash))/(len(nexthash)-len(todo))
 	else:
diff -u nsec3walker-20101223/query nsec3walker-javantea/query
--- nsec3walker-20101223/query	2010-12-24 01:49:40.000000000 -0800
+++ nsec3walker-javantea/query	2014-10-25 22:57:55.251308565 -0700
@@ -16,5 +16,6 @@
     if ($4 == "NS") print "ns",tolower($1),tolower($5)
     gsub(/\..*$/,"",$1)
     if ($4 == "NSEC3") print "nsec3",tolower($1),tolower($9),tolower($8),tolower($7)
+    if ($4 == "NSEC") print "nsec",tolower($5)
   }
 '
diff -u nsec3walker-20101223/unhash nsec3walker-javantea/unhash
--- nsec3walker-20101223/unhash	2010-12-24 01:49:40.000000000 -0800
+++ nsec3walker-javantea/unhash	2014-12-17 14:49:04.593829760 -0800
@@ -4,19 +4,35 @@
 import sys
 
 dictionary = "/usr/share/dict/words"
+collect_file = sys.stdin
 if len(sys.argv) >= 2:
   dictionary = sys.argv[1]
+  if len(sys.argv) >= 3:
+    collect_file = open(sys.argv[2],'r')
 
-name = set()
+if dictionary == '-':
+  dictin = sys.stdin
+  if collect_file == sys.stdin:
+    sys.stderr.write("Error: you must specify a collect file if you want the dictionary to be on stdin.")
+    sys.stderr.write("Usage: unhash dictionary collect_file >unhashes")
+    sys.stderr.write("       unhash - collect_file <dictionary >unhashes")
+    sys.stderr.write("       unhash dictionary >unhashes")
+else:
+  dictin = open(dictionary, 'r')
 
-salt = 0
+name = set()
+domain = None
+salt = ''
+iterations = '0'
 
-for line in sys.stdin:
+for line in collect_file:
   y = line.strip().split()
+  if len(y) == 0: continue
   if y[0] == "domain":
     domain = y[1]
   elif y[0] == "salt":
-    salt = y[1]
+    if len(y) > 1:
+      salt = y[1]
   elif y[0] == "iterations":
     iterations = y[1]
   elif y[0] == "nexthash":
@@ -33,9 +49,8 @@
 
 print "names:",numnames
 
-if domain and salt and numnames:
-  dictprocess = subprocess.Popen(["cat",dictionary],stdout=subprocess.PIPE)
-  hashprocess = subprocess.Popen(["./dicthashes",domain,iterations,salt],stdin=dictprocess.stdout,stdout=subprocess.PIPE)
+if domain and numnames:
+  hashprocess = subprocess.Popen(["./dicthashes",domain,iterations,salt],stdin=dictin,stdout=subprocess.PIPE)
   for line in hashprocess.stdout:
     numhashes += 1
     x = line.strip().split()
