Created
October 29, 2009 04:07
-
-
Save whym/221137 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!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") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment