【发布时间】:2014-07-28 08:28:32
【问题描述】:
我需要将 New.tex http://pastebin.com/PCafGYwG 与 Old.tex http://pastebin.com/jRU8rhhV 进行比较,如果同一 IP 中的两个文档中存在相同的漏洞,则得到输出。
例如:两个文件的 IP 地址都是 10.1.2.3。
New.tex
\subsection {Summary of security vulnerabilities found on the host with IP address 10.1.2.3}
\begin{center}
\begin{longtable}{|p{0.2in}|p{0.5in}|p{4in}|p{0.4in}|} \hline
\textit{\textbf{No}} &\textit{\textbf{Severity level}} & \textit{\textbf{Vulnerability name}} & \textit{\textbf{More}} \\ \hline
1 & \cellcolor{Red}High& DNS Server Cache Snooping Remote Information Disclosure & \href{http://www.rootsecure.net/content/downloads/pdf/dns\_cache\_snooping.pdf}{$\Rightarrow$} \\ \hline
2 & \cellcolor{BurntOrange}Medium & SSL Certificate with Wrong Hostname & \href{http://www.tenable.com/plugins/index.php?view=single&id=45411}{$\Rightarrow$} \\ \hline
3 & \cellcolor{BurntOrange}Medium & SSL Self-Signed Certificate & \href{http://www.tenable.com/plugins/index.php?view=single&id=57582}{$\Rightarrow$} \\ \hline
4 & \cellcolor{SkyBlue}Low & SSL RC4 Cipher Suites Supported & \href{http://www.nessus.org/u?217a3666}{$\Rightarrow$} \\
\end{longtable}
\end{center}
.............
.....................
...
Old.tex
.............
.......
......................
\subsection {Summary of security vulnerabilities found on the host with IP address 10.1.2.3}
\begin{center}
\begin{longtable}{|p{0.2in}|p{0.5in}|p{4in}|p{0.4in}|} \hline
\textit{\textbf{No}} &\textit{\textbf{Severity level}} & \textit{\textbf{Vulnerability name}} & \textit{\textbf{More}} \\ \hline
1 & \cellcolor{BurntOrange}Medium & DNS Server Cache Snooping Remote Information Disclosure & \href{http://www.rootsecure.net/content/downloads/pdf/dns\_cache\_snooping.pdf}{$\Rightarrow$} \\ \hline
2 & \cellcolor{BurntOrange}Medium & SSL Certificate Cannot Be Trusted & \href{http://www.tenable.com/plugins/index.php?view=single&id=51192}{$\Rightarrow$} \\ \hline
3 & \cellcolor{BurntOrange}Medium & SSL Certificate with Wrong Hostname & \href{http://www.tenable.com/plugins/index.php?view=single&id=45411}{$\Rightarrow$} \\ \hline
4 & \cellcolor{BurntOrange}Medium & SSL Self-Signed Certificate & \href{http://www.tenable.com/plugins/index.php?view=single&id=57582}{$\Rightarrow$} \\ \hline
\end{longtable}
\end{center}
..............
.......
...........
在这种情况下,
两者都有漏洞 ="DNS Server Cache Snooping Remote Information Disclosure" "SSL Certificate with Wrong Hostname" "SSL Self-Signed Certificate"
我需要输出
只有漏洞摘要如下
\subsection {Summary of security vulnerabilities found on the host with IP address 10.1.2.3}
\begin{center}
\begin{longtable}{|p{0.2in}|p{0.5in}|p{4in}|p{0.4in}|} \hline
\textit{\textbf{No}} &\textit{\textbf{Severity level}} & \textit{\textbf{Vulnerability name}} & \textit{\textbf{More}} \\ \hline
1 & \cellcolor{Red}Medium & DNS Server Cache Snooping Remote Information Disclosure & \href{http://www.rootsecure.net/content/downloads/pdf/dns\_cache\_snooping.pdf}{$\Rightarrow$} \\ \hline
2 & \cellcolor{BurntOrange}Medium & SSL Certificate with Wrong Hostname & \href{http://www.tenable.com/plugins/index.php?view=single&id=45411}{$\Rightarrow$} \\ \hline
3 & \cellcolor{BurntOrange}Medium & SSL Self-Signed Certificate & \href{http://www.tenable.com/plugins/index.php?view=single&id=57582}{$\Rightarrow$} \\ \hline
\end{longtable}
\end{center}
如何在 linux 上使用 bash 脚本、awk、sed 或任何其他方法实现此目的?
【问题讨论】:
-
我会开始做类似的事情:
awk '/10.1.2.3/ {f=1} f; /\end{center}/ {f=0}' new > stuff_new来存储一个特定的块,然后与old文件相同。然后你可以以某种方式比较它们,尽管它们看起来很不一样。 -
过滤规则是什么?为什么你在高中和高中之间选择中等?