Guest User

Untitled

a guest
Apr 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #!python
  2. # -*- encoding: utf-8 -*-
  3.  
  4. # DNS log converter from Microsoft DNS to namebench
  5.  
  6. # INPUT:
  7. # 20091029 11:49:01 848 PACKET 02728D00 UDP Rcv 133.11.34.152 053d Q [0001 D NOERROR] A (6)images(8)slashdot(2)jp(0)
  8. # OUTPUT:
  9. # domain://images.slashdot.jp
  10.  
  11. import os,sys
  12. import re
  13.  
  14. logpath = os.path.join(u'xxx',u'dns.txt')
  15. outpath = os.path.join(u'xxx',u'dnsx.txt')
  16.  
  17. out = open(outpath, 'w')
  18.  
  19. for line in open(logpath, 'rb'):
  20. line = line.strip()
  21. res = re.search(r'NOERROR\]\s[A-Z]+\s+(\S+)',line)
  22. if res != None:
  23. domain = 'domain://' + re.sub(r'\(\d+\)', '.', res.group(1)).strip('.')
  24. out.write(domain + "\n")
Add Comment
Please, Sign In to add comment