-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEvenBetterFormat.ps1
More file actions
24 lines (24 loc) · 1.34 KB
/
EvenBetterFormat.ps1
File metadata and controls
24 lines (24 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$URL = "https://www.cvedetails.com/vulnerability-search.php?f=1&vendor=&product=putty%25&cveid=&msid=&bidno=&cweid=&cvssscoremin=&cvssscoremax=&psy=&psm=&pey=&pem=&usy=&usm=&uey=&uem="
$page = Invoke-WebRequest -Uri $URL
# Getting table by ID.
$CVEtable = $page.ParsedHtml.getElementByID("vulnslisttable")
# Extracting table rows as a collection.
$TableBody = $CVEtable.childNodes | Where-Object { $_.tagName -eq "TBODY" }
$TableRows = $TableBody.childNodes | Where-Object { $_.tagName -eq "TR" }
# Creating a collection of table headers.
$TableHeaders = $TableRows[0].childNodes | Where-Object { $_.tagName -eq "TH" } | select -expandproperty InnerText
$ColumnTableHeaders = @($TableHeaders)
# Converting rows to a collection of PS objects exportable to CSV.
$CSVobject = @()
foreach ($TableRow in $TableRows) {
$TableData = $TableRow.childNodes | Where-Object { $_.tagName -eq "TD" }
# Skipping the first row (headers).
if ([String]::IsNullOrEmpty($TableData)) { continue }
$RowObject = New-Object PSObject
for ($i = 0; $i -lt $ColumnTableHeaders.Count; $i++) {
$RowObject | Add-Member -MemberType NoteProperty -Name $ColumnTableHeaders[$i] `
-Value $TableData[$i].innertext
}
$CSVobject += $RowObject
}
$CSVobject | ? `# -Match "\d" | Export-Csv -Path $env:TEMP\export.csv -NoTypeInformation