大家好 最近,关于将应用程序从物理基础架构,读取数据中心传输到云的讨论很多。 例如,在Microsoft Azure中 。 关于一个或多个应用程序从一个地方到另一地方的任何其他转移的说明,或者一般而言。 这种问题中最大的问题之一是需要找到应用程序的所有外部依赖项。 这不是指代码中的依赖关系,而是指应用程序对外部系统的依赖关系。 实际上,有时我们需要找到我们的提案正在与谁交谈,以及谁正在与他交谈。 如果我们没有全面的SIEM,可以这么说,可以说,将SIEM用于贫困人口。 严格来说,对于Windows上的系统,有以下句子。
我们需要:
- 在与应用程序关联的一种或多种方式下,在所有计算机上启用Windows防火墙日志记录
- 下载到管理站PSQuickGraph模块
- 堆积和分析日志,建立链接图
以最简单的形式,日志分析看起来像这样。 糟糕,额头,但是你能做什么。 实际上,我懒得为日志竞赛编写逻辑,我只是复制了所有内容两次。 但是出于我们的目的,“粗鲁地在额头上”也将用来展示这个想法
$f = gc "C:\Temp\pfirewall_public.log" $regex = '^(?<datetime>\d{4,4}-\d{2,2}-\d{2,2}\s\d{2}:\d{2}:\d{2})\s(?<action>\w+)\s(?<protocol>\w+)\s(?<srcip>\b(?:\d{1,3}\.){3}\d{1,3}\b)\s(?<dstip>\b(?:\d{1,3}\.){3}\d{1,3}\b)\s(?<srcport>\d{1,5})\s(?<dstport>\d{1,5})\s(?<size>\d+|-)\s(?<tcpflags>\d+|-)\s(?<tcpsyn>\d+|-)\s(?<tcpack>\d+|-)\s(?<tcpwin>\d+|-)\s(?<icmptype>\d+|-)\s(?<icmpcode>\d+|-)\s(?<info>\d+|-)\s(?<path>.+)$' $log = $f | % { $_ -match $regex | Out-Null if ($Matches) { [PSCustomObject]@{ action = $Matches.action srcip = [ipaddress]$Matches.srcip dstport = $Matches.dstport tcpflags = $Matches.tcpflags dstip = [ipaddress]$Matches.dstip info = $Matches.info size = $Matches.size protocol = $Matches.protocol tcpack = $Matches.tcpac srcport = $Matches.srcport tcpsyn = $Matches.tcpsyn datetime = [datetime]$Matches.datetime icmptype = $Matches.icmptype tcpwin = $Matches.tcpwin icmpcode = $Matches.icmpcode path = $Matches.path } } } $f = gc "C:\Temp\pfirewall_public2.log" $log2 = $f | % { $_ -match $regex | Out-Null if ($Matches) { [PSCustomObject]@{ action = $Matches.action srcip = [ipaddress]$Matches.srcip dstport = $Matches.dstport tcpflags = $Matches.tcpflags dstip = [ipaddress]$Matches.dstip info = $Matches.info size = $Matches.size protocol = $Matches.protocol tcpack = $Matches.tcpac srcport = $Matches.srcport tcpsyn = $Matches.tcpsyn datetime = [datetime]$Matches.datetime icmptype = $Matches.icmptype tcpwin = $Matches.tcpwin icmpcode = $Matches.icmpcode path = $Matches.path } } } $l = $log + $log2 $g = new-graph -Type BidirectionalGraph $l | ? {$_.srcip -and $_.dstip} | % { Add-Edge -From $_.srcip -To $_.dstip -Graph $g | out-null } Show-GraphLayout -Graph $g
实际上,在此示例中,我们仅使用正则表达式解析Windows防火墙日志,将其分解为对象-每行一个对象。 上帝保佑她RAM,不要死。 在此示例中,我们有两个日志,分别来自两台不同的计算机。 解析之后,我们只需将所有内容合并到一个大数组中并对其进行搜索,即可添加图形的顶点和边缘。 好吧,因此-显示它。 因此,大致结果如下:

我希望有人派上用场。