我需要将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服务器缓存窥探远程信息泄漏“"SSL证书”(主机名错误) "SSL自签名证书“
我需要输出
只有下面的漏洞摘要
\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或任何其他方法来实现这一点?
发布于 2015-05-27 19:55:26
您可以使用diff命令或diffuse GUI工具比较两个文件:
diff Old.tex New.tex或
diffuse Old.tex New.tex为了进行更深入的分析,我建议编写一个简短的python (或perl)脚本,在脚本中读取两个文件,找到您感兴趣的行,比较它们,并进行所需的替换。
发布于 2014-07-28 08:39:37
最简单的方法是在第一行中找到要搜索的唯一文本,然后使用grep定位该行,并添加-A8以捕获接下来的8行上下文。在您的情况下,可能会发生以下情况:
grep -A8 {Summary\ of\ security\ vulnerabilities filename假设单词的组合对于漏洞行是唯一的,那么您将得到您希望得到的上面的行。
https://stackoverflow.com/questions/24991182
复制相似问题