-
Notifications
You must be signed in to change notification settings - Fork 22
/
Parse_DNSDebugLogs.ps1
80 lines (75 loc) · 2.46 KB
/
Parse_DNSDebugLogs.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#this script pulls in a DNS log and parses it for unique DNS records
#
$path = ".\dns2.txt " #Location where DNS Debug log is placed.
$fulllogpath = "fulllogpath.txt" #The location and file name where the full log is placed (has duplicates)
$trimmeddns = "trimmeddns.txt" #The location where the final trimmed dns records go.
$amount = 112 #How much of the debug log should be trimmed away.
ForEach($line in (Get-content $path))
{
if ($line.length -gt $amount) {
if($line -match "(3)"){
$line = $line -replace "\(3\)","."
}
if($line -match '(0)'){
$line = $line -replace '\(0\)',''
}
if($line -match '(16)'){
$line = $line -replace '\(16\)','.'
}
if($line -match '(5)'){
$line = $line -replace '\(5\)','.'
}
if($line -match '(9)'){
$line = $line -replace '\(9\)','.'
}
if($line -match '(4)'){
$line = $line -replace '\(4\)','.'
}
if($line -match '(6)'){
$line = $line -replace '\(6\)','.'
}
if($line -match '(2)'){
$line = $line -replace '\(2\)','.'
}
if($line -match '(7)'){
$line = $line -replace '\(7\)','.'
}
if($line -match '(8)'){
$line = $line -replace '\(7\)','.'
}
if($line -match '(1)'){
$line = $line -replace '\(1\)','.'
}
if($line -match '(14)'){
$line = $line -replace '\(14\)','.'
}
if($line -match '(10)'){
$line = $line -replace '\(10\)','.'
}
if($line -match '(13)'){
$line = $line -replace '\(13\)','.'
}
if($line -match '(12)'){
$line = $line -replace '\(12\)','.'
}
if($line -match '(8)'){
$line = $line -replace '\(8\)','.'
}
if($line -match '(15)'){
$line = $line -replace '\(15\)','.'
}
if($line -match '(11)'){
$line = $line -replace '\(11\)','.'
}
if($line -match '(19)'){
$line = $line -replace '\(19\)','.'
}
if($line -match '(17)'){
$line = $line -replace '\(17\)','.'
}
if($line -match '(21)'){
$line = $line -replace '\(21\)','.'
}
Add-Content $fulllogpath $line.Substring($amount+1)}
}
Add-content $trimmedDNS Log ((Get-Content $fulllogpath).ToLower() | Sort-Object |Get-Unique )