Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!python
- # -*- encoding: utf-8 -*-
- # DNS log converter from Microsoft DNS to namebench
- # INPUT:
- # 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)
- # OUTPUT:
- # domain://images.slashdot.jp
- import os,sys
- import re
- logpath = os.path.join(u'xxx',u'dns.txt')
- outpath = os.path.join(u'xxx',u'dnsx.txt')
- out = open(outpath, 'w')
- for line in open(logpath, 'rb'):
- line = line.strip()
- res = re.search(r'NOERROR\]\s[A-Z]+\s+(\S+)',line)
- if res != None:
- domain = 'domain://' + re.sub(r'\(\d+\)', '.', res.group(1)).strip('.')
- out.write(domain + "\n")
Add Comment
Please, Sign In to add comment