• 从网页上抓取Windows补丁信息然后整型输出(PowerShell)


    $report = [pscustomobject]@{'Date' = $null; 'MSRC' = $null; 'KB' = $null; 'Severity' = $null; 'Version' = $null; 'Summary' = $null; 'ThreatType' = $null}
    $report | Export-Csv -Path E:PatchReport.csv -Force -Encoding Unicode -Delimiter "`t"
    $parttern = "[(]d{7}[)]"  #获取title最右侧的KB号码,对于任意年份的补丁都通用
    $parttern_title = "(Information Disclosure|Remote Code Execution|Elevation of Privilege|Security Feature Bypass|Cumulative Security Update|Security Update|Denial of Service|Tampering)"
    $WebClient = New-Object System.Net.WebClient
    $WebClient.Encoding=[System.Text.Encoding]::UTF8
    $xml = [XML]($WebClient.DownloadString("https://technet.microsoft.com/en-us/security/rss/bulletin"))
    $xml.rss.channel.item | foreach {
    $msrc = $_.link.substring($_.link.length - 8, 8)
    do {
    $patchweb = $WebClient.DownloadString("https://technet.microsoft.com/en-us/library/security/$msrc")
    } while (!$?)         #$?表示最后一条执行的命令所返回的结果是True还是False, 在这里是True
    $result = [regex]::Match($patchweb, $parttern)
    $kbnumbers = $result.value.Substring(1, 7) #KB
    $cdata = $_.encoded.InnerText -replace "Severity Rating: ", "" -replace "Revision Note: ", "" -replace "Summary: ", "" -split "<br/>"
    #发布日期+MS号+KB号+危险等级+版本+摘要信息+威胁类型
    foreach ($kbnumber in $kbnumbers) {
    $_.pubdate.substring(0,10) + "`t" + ($_.link).substring($_.link.length - 8, 8) + "`t" + $kbnumber + "`t" + $cdata[0] + "`t" + $cdata[1].Substring(0,4) + "`t" + $cdata[2] + "`t" + [regex]::Match($_.title, $parttern_title, 'IgnoreCase')
    } 
    } | Out-File -FilePath E:PatchReport.csv -Append -Encoding unicode
  • 相关阅读:
    dedecms5.7安装百度(ueditor)编辑器的方法
    shell多线程之进程间通信(2)
    shell多线程之进程间通信
    awk笔记
    用shell做简单的分布式计算
    C语言实现常用查找算法——二分查找
    C语言实现常用排序算法——基数排序
    C语言实现常用数据结构——堆
    C语言实现常用数据结构——图
    C语言实现常用数据结构——二叉查找树
  • 原文地址:https://www.cnblogs.com/IvanChen/p/4488246.html
Copyright © 2020-2023  润新知