<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>猪在笑</title>
	<atom:link href="http://www.huangwei.me/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.huangwei.me/blog</link>
	<description>暇时吃紧，忙里偷闲</description>
	<lastBuildDate>Mon, 30 Aug 2010 04:52:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>nautilus脚本应用实例之二：右键菜单挂载/卸载ISO</title>
		<link>http://www.huangwei.me/blog/2010/08/30/nautilus-scripts-mount-iso/</link>
		<comments>http://www.huangwei.me/blog/2010/08/30/nautilus-scripts-mount-iso/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 04:51:41 +0000</pubDate>
		<dc:creator>c4pr1c3</dc:creator>
				<category><![CDATA[CodeSnippet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[nautilus]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.huangwei.me/blog/?p=613</guid>
		<description><![CDATA[<a href="http://creativecommons.org/licenses/by/3.0/deed.zh"><strong>版权声明</strong></a><strong>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></strong>

右键挂载选中的iso

#!/usr/bin/perl -w
&#160;
# This script mount the selected iso(s).
&#160;
use strict;
&#160;
my @fi[......]<p class='read-more'><a href='http://www.huangwei.me/blog/2010/08/30/nautilus-scripts-mount-iso/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<div style="margin-top: 2px;">
<A href="http://creativecommons.org/licenses/by/3.0/deed.zh"><FONT color=#11779f><STRONG>版权声明</STRONG></FONT></A><FONT color=#11779f><STRONG>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></STRONG></FONT>
</div>
<p>右键挂载选中的iso</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This script mount the selected iso(s).</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@files</span> <span style="color: #339933;">=</span> <span style="color: #000066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$ENV</span><span style="color: #009900;">&#123;</span>NAUTILUS_SCRIPT_SELECTED_FILE_PATHS<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$foo</span> <span style="color: #339933;">=</span> <span style="color: #000066;">system</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;gksudo -u root -k -m 'enter your password for root terminal access' /bin/echo 'r00t'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #0000ff;">$foo</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$file</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@files</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #339933;">-</span>f <span style="color: #0000ff;">$file</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span> <span style="color: #339933;">-</span>l <span style="color: #0000ff;">$file</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@dialog</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;gdialog&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;--title&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;Error&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;--msgbox&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Error: Can not mount $file.    <span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>    Only regular files can be mounted.    &quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;200&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;300&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066;">system</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@dialog</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #0000ff;">$_</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$file</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$dir</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$filename</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">m/(.*)[\\\/](.+)/</span> <span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$2</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span> <span style="color: #000066;">undef</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$_</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #339933;">-</span>d <span style="color: #ff0000;">&quot;/media/$filename&quot;</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000066;">system</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;sudo mkdir /media/$filename&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000066;">system</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;sudo mount -o loop -t iso9660 $file /media/$filename&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>右键卸载选中的iso</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This script unmount the selected iso(s).</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@files</span> <span style="color: #339933;">=</span> <span style="color: #000066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$ENV</span><span style="color: #009900;">&#123;</span>NAUTILUS_SCRIPT_SELECTED_FILE_PATHS<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$foo</span> <span style="color: #339933;">=</span> <span style="color: #000066;">system</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;gksudo -u root -k -m 'enter your password for root terminal access' /bin/echo 'r00t'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #0000ff;">$foo</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$file</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@files</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #339933;">-</span>f <span style="color: #0000ff;">$file</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span> <span style="color: #339933;">-</span>l <span style="color: #0000ff;">$file</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@dialog</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;gdialog&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;--title&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;Error&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;--msgbox&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Error: Can not unmount $file.    <span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>    Only regular files can be unmounted.    &quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;200&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;300&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066;">system</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@dialog</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #0000ff;">$_</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$file</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$dir</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$filename</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">m/(.*)[\\\/](.+)/</span> <span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$2</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span> <span style="color: #000066;">undef</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$_</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
			<span style="color: #000066;">system</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;sudo umount /media/$filename&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">-</span>d <span style="color: #ff0000;">&quot;/media/$filename&quot;</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000066;">system</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;sudo rmdir /media/$filename&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<div style="margin-top: 15px; ">
<hr style="border: 1px solid #cccccc;"/>
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.huangwei.me/blog/">猪在笑</a> <a href="http://www.huangwei.me/blog/">[ http://www.huangwei.me/blog/ ]</a><br/><strong>本文链接地址:</strong> <a href="http://www.huangwei.me/blog/2010/08/30/nautilus-scripts-mount-iso/">http://www.huangwei.me/blog/2010/08/30/nautilus-scripts-mount-iso/</a></p>
<hr style="border: 1px solid #cccccc;"/>
</div>
<div  class="related_post_title">您可能还对以下文章感兴趣</div><ul class="related_post"><li><a href="http://www.huangwei.me/blog/2010/08/30/gnome-nautilus-scripts-meld/" title="nautilus脚本应用实例之一：用meld比较选中的文件或文件夹">nautilus脚本应用实例之一：用meld比较选中的文件或文件夹</a></li><li><a href="http://www.huangwei.me/blog/2010/08/27/wangwang-linux-im/" title="无需安装阿里旺旺即可聊天的方法">无需安装阿里旺旺即可聊天的方法</a></li><li><a href="http://www.huangwei.me/blog/2010/08/02/perl-gtk2-libnotify/" title="[CodeSnippet]Perl实现Gtk任务栏的消息提示">[CodeSnippet]Perl实现Gtk任务栏的消息提示</a></li><li><a href="http://www.huangwei.me/blog/2010/08/02/sniffer-with-perl-pcap/" title="[CodeSnippet]Perl抓包分析之DNS debug">[CodeSnippet]Perl抓包分析之DNS debug</a></li><li><a href="http://www.huangwei.me/blog/2010/07/29/qemu-vmware-conflict/" title="[已验证]qemu和vmware冲突">[已验证]qemu和vmware冲突</a></li><li><a href="http://www.huangwei.me/blog/2010/02/20/ubuntu-keyboard-shortcuts/" title="Ubuntu中你可能不知道的一些有用的键盘快捷键">Ubuntu中你可能不知道的一些有用的键盘快捷键</a></li><li><a href="http://www.huangwei.me/blog/2010/01/10/linux%e4%b8%8bpptp-vpn-3%e5%88%86%e9%92%9f%e5%bf%ab%e9%80%9f%e9%85%8d%e7%bd%ae/" title="Linux下PPTP VPN 3分钟快速配置">Linux下PPTP VPN 3分钟快速配置</a></li><li><a href="http://www.huangwei.me/blog/2009/11/22/ubuntu%e5%b0%8f%e6%8a%80%e5%b7%a7%e7%b3%bb%e5%88%97%e4%b9%8b%e5%9b%9b%e7%b3%bb%e7%bb%9f%e5%90%af%e5%8a%a8%e4%bc%98%e5%8c%96%e4%b9%8bbootchart/" title="[Ubuntu小技巧系列之四]系统启动优化之bootchart">[Ubuntu小技巧系列之四]系统启动优化之bootchart</a></li><li><a href="http://www.huangwei.me/blog/2009/07/19/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aa%e5%9c%a8%e7%ba%bf%e5%a4%87%e4%bb%bd%e5%92%8c%e6%96%87%e4%bb%b6%e5%90%8c%e6%ad%a5%e7%9a%84%e7%bd%91%e7%ab%99/" title="[推荐]一个在线备份和文件同步的网站">[推荐]一个在线备份和文件同步的网站</a></li><li><a href="http://www.huangwei.me/blog/2009/06/11/ubuntu%e5%b0%8f%e6%8a%80%e5%b7%a7%e7%b3%bb%e5%88%97%e4%b9%8b%e4%b8%89%e8%b7%a8%e5%b9%b3%e5%8f%b0%e5%8e%8b%e7%bc%a9%e6%96%87%e4%bb%b6%e8%a7%a3%e5%8e%8b%e7%bc%a9%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98/" title="[Ubuntu小技巧系列之三]跨平台压缩文件解压缩乱码问题的解决">[Ubuntu小技巧系列之三]跨平台压缩文件解压缩乱码问题的解决</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.huangwei.me/blog/2010/08/30/nautilus-scripts-mount-iso/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nautilus脚本应用实例之一：用meld比较选中的文件或文件夹</title>
		<link>http://www.huangwei.me/blog/2010/08/30/gnome-nautilus-scripts-meld/</link>
		<comments>http://www.huangwei.me/blog/2010/08/30/gnome-nautilus-scripts-meld/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 04:47:09 +0000</pubDate>
		<dc:creator>c4pr1c3</dc:creator>
				<category><![CDATA[CodeSnippet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[nautilus]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.huangwei.me/blog/?p=609</guid>
		<description><![CDATA[<a href="http://creativecommons.org/licenses/by/3.0/deed.zh"><strong>版权声明</strong></a><strong>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></strong>

前两天推特上<a href="http://peigen.info/?p=87" target="_blank">@peigen推荐了一款diff工具meld</a>，和我之前使用的diffuse相比，最大的优点是可以进行文件夹比较。但存在的共同缺点就是如果直接使用nautilus中集成关联打开方式的方法，无法直接通过选中两个待比[......]<p class='read-more'><a href='http://www.huangwei.me/blog/2010/08/30/gnome-nautilus-scripts-meld/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<div style="margin-top: 2px;">
<A href="http://creativecommons.org/licenses/by/3.0/deed.zh"><FONT color=#11779f><STRONG>版权声明</STRONG></FONT></A><FONT color=#11779f><STRONG>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></STRONG></FONT>
</div>
<p>前两天推特上<a href="http://peigen.info/?p=87" target="_blank">@peigen推荐了一款diff工具meld</a>，和我之前使用的diffuse相比，最大的优点是可以进行文件夹比较。但存在的共同缺点就是如果直接使用nautilus中集成关联打开方式的方法，无法直接通过选中两个待比较的文件或文件夹右键直接进行比较，而总是打开两个应用程序实例。研究了一下nautilus的右键菜单定制方法，但总感觉功能不够强大，且无法完成这个看似非常简单的需求。</p>
<p>偶然间发现了这篇文章：<a href="http://ubuntu-tutorials.com/2006/12/29/right-click-to-launch-custom-scripts-with-nautilus-ubuntu-6061-610/">http://ubuntu-tutorials.com/2006/12/29/right-click-to-launch-custom-scripts-with-nautilus-ubuntu-6061-610/</a></p>
<p>研究了一下，原来可以通过定制gnome-nautilus的右键菜单执行脚本来实现我的需求。下面附上我实现好的两个nautilus脚本</p>
<p>用meld比较选中的文件</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This script compares the selected file(s) with meld.</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@files</span> <span style="color: #339933;">=</span> <span style="color: #000066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$ENV</span><span style="color: #009900;">&#123;</span>NAUTILUS_SCRIPT_SELECTED_FILE_PATHS<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$count</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$#files</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$count</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">2</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@dialog</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;gdialog&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;--title&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;Error&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;--msgbox&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Error: Only 2 files can be compared at once. &quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;200&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;300&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">system</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@dialog</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$file</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@files</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #339933;">-</span>f <span style="color: #0000ff;">$file</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span> <span style="color: #339933;">-</span>l <span style="color: #0000ff;">$file</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@dialog</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;gdialog&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;--title&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;Error&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;--msgbox&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Error: Can not compare $file.    <span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>    Only regular files can be diffed.    &quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;200&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;300&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066;">system</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@dialog</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066;">system</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;meld $files[0] $files[1]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>用meld比较选中的文件夹</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This script compares the selected dir(s) with meld.</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@files</span> <span style="color: #339933;">=</span> <span style="color: #000066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$ENV</span><span style="color: #009900;">&#123;</span>NAUTILUS_SCRIPT_SELECTED_FILE_PATHS<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$count</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$#files</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$count</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">2</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@dialog</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;gdialog&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;--title&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;Error&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;--msgbox&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Error: Only 2 directories can be compared at once. &quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;200&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;300&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">system</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@dialog</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$file</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@files</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #339933;">-</span>d <span style="color: #0000ff;">$file</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@dialog</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;gdialog&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;--title&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;Error&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;--msgbox&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Error: Can not compare $file.    <span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>    Only directories can be diffed.    &quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;200&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;300&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066;">system</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@dialog</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066;">system</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;meld $files[0] $files[1]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<div style="margin-top: 15px; ">
<hr style="border: 1px solid #cccccc;"/>
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.huangwei.me/blog/">猪在笑</a> <a href="http://www.huangwei.me/blog/">[ http://www.huangwei.me/blog/ ]</a><br/><strong>本文链接地址:</strong> <a href="http://www.huangwei.me/blog/2010/08/30/gnome-nautilus-scripts-meld/">http://www.huangwei.me/blog/2010/08/30/gnome-nautilus-scripts-meld/</a></p>
<hr style="border: 1px solid #cccccc;"/>
</div>
<div  class="related_post_title">您可能还对以下文章感兴趣</div><ul class="related_post"><li><a href="http://www.huangwei.me/blog/2010/08/30/nautilus-scripts-mount-iso/" title="nautilus脚本应用实例之二：右键菜单挂载/卸载ISO">nautilus脚本应用实例之二：右键菜单挂载/卸载ISO</a></li><li><a href="http://www.huangwei.me/blog/2010/08/27/wangwang-linux-im/" title="无需安装阿里旺旺即可聊天的方法">无需安装阿里旺旺即可聊天的方法</a></li><li><a href="http://www.huangwei.me/blog/2010/08/02/perl-gtk2-libnotify/" title="[CodeSnippet]Perl实现Gtk任务栏的消息提示">[CodeSnippet]Perl实现Gtk任务栏的消息提示</a></li><li><a href="http://www.huangwei.me/blog/2010/08/02/sniffer-with-perl-pcap/" title="[CodeSnippet]Perl抓包分析之DNS debug">[CodeSnippet]Perl抓包分析之DNS debug</a></li><li><a href="http://www.huangwei.me/blog/2010/07/29/qemu-vmware-conflict/" title="[已验证]qemu和vmware冲突">[已验证]qemu和vmware冲突</a></li><li><a href="http://www.huangwei.me/blog/2010/02/20/ubuntu-keyboard-shortcuts/" title="Ubuntu中你可能不知道的一些有用的键盘快捷键">Ubuntu中你可能不知道的一些有用的键盘快捷键</a></li><li><a href="http://www.huangwei.me/blog/2010/01/10/linux%e4%b8%8bpptp-vpn-3%e5%88%86%e9%92%9f%e5%bf%ab%e9%80%9f%e9%85%8d%e7%bd%ae/" title="Linux下PPTP VPN 3分钟快速配置">Linux下PPTP VPN 3分钟快速配置</a></li><li><a href="http://www.huangwei.me/blog/2009/11/22/ubuntu%e5%b0%8f%e6%8a%80%e5%b7%a7%e7%b3%bb%e5%88%97%e4%b9%8b%e5%9b%9b%e7%b3%bb%e7%bb%9f%e5%90%af%e5%8a%a8%e4%bc%98%e5%8c%96%e4%b9%8bbootchart/" title="[Ubuntu小技巧系列之四]系统启动优化之bootchart">[Ubuntu小技巧系列之四]系统启动优化之bootchart</a></li><li><a href="http://www.huangwei.me/blog/2009/07/19/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aa%e5%9c%a8%e7%ba%bf%e5%a4%87%e4%bb%bd%e5%92%8c%e6%96%87%e4%bb%b6%e5%90%8c%e6%ad%a5%e7%9a%84%e7%bd%91%e7%ab%99/" title="[推荐]一个在线备份和文件同步的网站">[推荐]一个在线备份和文件同步的网站</a></li><li><a href="http://www.huangwei.me/blog/2009/06/11/ubuntu%e5%b0%8f%e6%8a%80%e5%b7%a7%e7%b3%bb%e5%88%97%e4%b9%8b%e4%b8%89%e8%b7%a8%e5%b9%b3%e5%8f%b0%e5%8e%8b%e7%bc%a9%e6%96%87%e4%bb%b6%e8%a7%a3%e5%8e%8b%e7%bc%a9%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98/" title="[Ubuntu小技巧系列之三]跨平台压缩文件解压缩乱码问题的解决">[Ubuntu小技巧系列之三]跨平台压缩文件解压缩乱码问题的解决</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.huangwei.me/blog/2010/08/30/gnome-nautilus-scripts-meld/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>无需安装阿里旺旺即可聊天的方法</title>
		<link>http://www.huangwei.me/blog/2010/08/27/wangwang-linux-im/</link>
		<comments>http://www.huangwei.me/blog/2010/08/27/wangwang-linux-im/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 03:31:57 +0000</pubDate>
		<dc:creator>c4pr1c3</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[纯净水]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[wangwang]]></category>
		<category><![CDATA[淘宝]]></category>
		<category><![CDATA[网络技术]]></category>
		<category><![CDATA[阿里旺旺]]></category>

		<guid isPermaLink="false">http://www.huangwei.me/blog/?p=602</guid>
		<description><![CDATA[<a href="http://creativecommons.org/licenses/by/3.0/deed.zh"><strong>版权声明</strong></a><strong>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></strong>

Linux下的IM方案有很多种，QQ可以使用WebQQ，GTalk、MSN等可以使用pidgin，飞信有libFetion、OpenFetion，唯独阿里旺旺比较麻烦，没有简单、可行的方案。Wine版的不太好用，开个虚拟机[......]<p class='read-more'><a href='http://www.huangwei.me/blog/2010/08/27/wangwang-linux-im/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<div style="margin-top: 2px;">
<A href="http://creativecommons.org/licenses/by/3.0/deed.zh"><FONT color=#11779f><STRONG>版权声明</STRONG></FONT></A><FONT color=#11779f><STRONG>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></STRONG></FONT>
</div>
<p>Linux下的IM方案有很多种，QQ可以使用WebQQ，GTalk、MSN等可以使用pidgin，飞信有libFetion、OpenFetion，唯独阿里旺旺比较麻烦，没有简单、可行的方案。Wine版的不太好用，开个虚拟机吧太麻烦。记得以前是可以用网页旺旺的，但可惜现在用起来比较麻烦，只能通过网页和淘宝店主临时聊天。那如果我想和我的好友（非淘宝卖家）聊天怎么办呢？</p>
<p>分析了一下网页版的阿里旺旺的启动链接，发现了一个有趣的参数，如下：</p>
<p>http://www.taobao.com/webww/?ver=1&amp;&amp;touid=cntaobao<span style="color: #ff0000"><strong><span style="background-color: #ffffff">对方旺旺用户名</span></strong></span>&amp;siteid=cntaobao&amp;status=2&amp;portalId=&amp;gid=&amp;itemsId=</p>
<p>网页版的旺旺可以在线保存聊天记录，保存时间根据你的等级来换算。</p>
<p>另外，已经通过网页旺旺聊天的用户会自动保存在最近联系人列表里，登录<a href="http://www.taobao.com/webww/" target="_blank">阿里旺旺网页版</a>后，单击右下旺旺小水滴，再单击您要与其聊天的旺旺帐号，就可以打开与好友的聊天窗口了。更多关于阿里旺旺网页版的帮助可以在登录<a href="http://www.taobao.com/webww/" target="_blank">阿里旺旺网页版</a>后，点击帮助。</p>
<p>附上一个界面截图</p>
<p><a href="http://www.huangwei.me/blog/wp-content/uploads/2010/08/screenshot51.png"><img class="alignleft" src="http://www.huangwei.me/blog/wp-content/uploads/2010/08/screenshot51.png" alt="阿里旺旺网页版界面截图" width="500" height="300" /></a></p>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<div style="margin-top: 15px; ">
<hr style="border: 1px solid #cccccc;"/>
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.huangwei.me/blog/">猪在笑</a> <a href="http://www.huangwei.me/blog/">[ http://www.huangwei.me/blog/ ]</a><br/><strong>本文链接地址:</strong> <a href="http://www.huangwei.me/blog/2010/08/27/wangwang-linux-im/">http://www.huangwei.me/blog/2010/08/27/wangwang-linux-im/</a></p>
<hr style="border: 1px solid #cccccc;"/>
</div>
<div  class="related_post_title">您可能还对以下文章感兴趣</div><ul class="related_post"><li><a href="http://www.huangwei.me/blog/2010/08/02/sniffer-with-perl-pcap/" title="[CodeSnippet]Perl抓包分析之DNS debug">[CodeSnippet]Perl抓包分析之DNS debug</a></li><li><a href="http://www.huangwei.me/blog/2010/08/30/nautilus-scripts-mount-iso/" title="nautilus脚本应用实例之二：右键菜单挂载/卸载ISO">nautilus脚本应用实例之二：右键菜单挂载/卸载ISO</a></li><li><a href="http://www.huangwei.me/blog/2010/08/30/gnome-nautilus-scripts-meld/" title="nautilus脚本应用实例之一：用meld比较选中的文件或文件夹">nautilus脚本应用实例之一：用meld比较选中的文件或文件夹</a></li><li><a href="http://www.huangwei.me/blog/2010/08/02/perl-gtk2-libnotify/" title="[CodeSnippet]Perl实现Gtk任务栏的消息提示">[CodeSnippet]Perl实现Gtk任务栏的消息提示</a></li><li><a href="http://www.huangwei.me/blog/2010/07/29/qemu-vmware-conflict/" title="[已验证]qemu和vmware冲突">[已验证]qemu和vmware冲突</a></li><li><a href="http://www.huangwei.me/blog/2010/03/24/firefox-autoproxy-pac-bug-fix/" title="[原创]非官方修复Firefox自动代理配置脚本bug的方法">[原创]非官方修复Firefox自动代理配置脚本bug的方法</a></li><li><a href="http://www.huangwei.me/blog/2010/02/20/ubuntu-keyboard-shortcuts/" title="Ubuntu中你可能不知道的一些有用的键盘快捷键">Ubuntu中你可能不知道的一些有用的键盘快捷键</a></li><li><a href="http://www.huangwei.me/blog/2010/01/10/linux%e4%b8%8bpptp-vpn-3%e5%88%86%e9%92%9f%e5%bf%ab%e9%80%9f%e9%85%8d%e7%bd%ae/" title="Linux下PPTP VPN 3分钟快速配置">Linux下PPTP VPN 3分钟快速配置</a></li><li><a href="http://www.huangwei.me/blog/2009/11/22/ubuntu%e5%b0%8f%e6%8a%80%e5%b7%a7%e7%b3%bb%e5%88%97%e4%b9%8b%e5%9b%9b%e7%b3%bb%e7%bb%9f%e5%90%af%e5%8a%a8%e4%bc%98%e5%8c%96%e4%b9%8bbootchart/" title="[Ubuntu小技巧系列之四]系统启动优化之bootchart">[Ubuntu小技巧系列之四]系统启动优化之bootchart</a></li><li><a href="http://www.huangwei.me/blog/2009/07/19/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aa%e5%9c%a8%e7%ba%bf%e5%a4%87%e4%bb%bd%e5%92%8c%e6%96%87%e4%bb%b6%e5%90%8c%e6%ad%a5%e7%9a%84%e7%bd%91%e7%ab%99/" title="[推荐]一个在线备份和文件同步的网站">[推荐]一个在线备份和文件同步的网站</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.huangwei.me/blog/2010/08/27/wangwang-linux-im/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>以安全的名义</title>
		<link>http://www.huangwei.me/blog/2010/08/21/security-as-a-slogan/</link>
		<comments>http://www.huangwei.me/blog/2010/08/21/security-as-a-slogan/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 04:40:39 +0000</pubDate>
		<dc:creator>c4pr1c3</dc:creator>
				<category><![CDATA[安全技术]]></category>
		<category><![CDATA[纯净水]]></category>
		<category><![CDATA[360]]></category>
		<category><![CDATA[baidu]]></category>
		<category><![CDATA[互联网八卦]]></category>
		<category><![CDATA[百度]]></category>

		<guid isPermaLink="false">http://www.huangwei.me/blog/?p=597</guid>
		<description><![CDATA[<a href="http://creativecommons.org/licenses/by/3.0/deed.zh"><strong>版权声明</strong></a><strong>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></strong>

2周多没有上网，互联网的大拿们又有很多动作和故事。而这些故事的焦点都和360有关，恰好都和&#8221;安全&#8221;有关。下面我们来看看相关新闻事件。
新闻事件一: <a href="http://baoz.net/360-kill-baidu-bar-again/">360再屠百度工具条，百度诉360不正当竞争索赔1[......]</a><p class='read-more'><a href='http://www.huangwei.me/blog/2010/08/21/security-as-a-slogan/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<div style="margin-top: 2px;">
<A href="http://creativecommons.org/licenses/by/3.0/deed.zh"><FONT color=#11779f><STRONG>版权声明</STRONG></FONT></A><FONT color=#11779f><STRONG>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></STRONG></FONT>
</div>
<p>2周多没有上网，互联网的大拿们又有很多动作和故事。而这些故事的焦点都和360有关，恰好都和&#8221;安全&#8221;有关。下面我们来看看相关新闻事件。</p>
<p>新闻事件一: <a href="http://baoz.net/360-kill-baidu-bar-again/">360再屠百度工具条，百度诉360不正当竞争索赔1000万</a></p>
<address>原告诉称，今年3月初，发现两被告在其360安全卫士7.0软件版本中，将两原告共同经营的百度工具栏和百度地址栏两款软件定义为“恶评插件”，并描述为“<strong>此类插件具有恶意行为，可能会危害您的电脑，建议您立即清理”</strong>。</address>
<p>点评一： 用恶意插件来说事是360的起家之道，周鸿t在一手造出了3721这个流氓软件后,又亲手绞杀了这个&#8221;恶意插件&#8221;。360当年给出的最有杀伤力的一句解释是:&#8221;这是广大网民的选择&#8221;。我似乎看到了周鸿t扛着一面大旗，上书&#8221;替天行道&#8221;四个大字！在360安全卫士的历史版本中，曾经把恶意插件称为&#8221;<strong>恶评插件</strong>&#8220;。</p>
<p>“恶评”这个词是很有互联网气质和民主精神的，“相信群众的眼睛是雪亮的”看似毫无破绽，完美无缺的理由。但实际上从技术操作和实现的角度有一个很重要的漏洞：<strong>诱导</strong>！民意是可以被诱导的！就拿360安全卫士对插件的评分投票机制来说，一款软件的第一票、前十票是谁投的呢？如果前十票都投的是“差评”，再加上360安全卫士的循循善诱式的<strong>安装提醒</strong>、<strong>体检提醒</strong>“<strong>此类插件具有恶意行为，可能会危害您的电脑，建议您立即清理</strong>”，有多少小白会继续投“差评”？我们光且不论投票数据的真实性。我们都知道，软件是人开发出来的，软件是可以升级的。<strong>人可以知错能改，软件通过升级一样是可以亡羊补牢的</strong>。但360安全卫士则不会给“恶评插件”这样的机会，只要你被抓住一次把柄，那你将被一辈子贴上&#8221;恶意插件”的标签！后果也就可想而知了。</p>
<p>新闻事件二: <a href="http://www.cnbeta.com/articles/119838.htm" target="_blank">360公司发声明回应百度起诉</a></p>
<address>360公司的声明全文</address>
<address>1、挂马网站和钓鱼网站每年<strong>导致网民数百亿元损失</strong>，而搜索引擎已经成为欺诈网站、钓鱼网站和挂马网站传播的主要途径。为网民在搜索结果页面上提示和防范安全风险，是360安全卫士的责任。百度所谓360“篡改百度搜索结果”实际上是360网盾为网民提供的搜索引擎保护功能，可以提示和标注搜索结果页面上的不良网站。</p>
<p>2、百度在搜索结果中没有尽到对网民进行安全告知的义务。<strong>百度不是安全公司</strong>，对于其免责声明中宣称：“百度对其概不负责，亦不承担任何法律责任”，我们表示理解。但360安全卫士保护了用户，却被百度以“侵害商业利益”为由起诉，我们对此表示不能理解。</p>
<p>3、安全公司对搜索引擎提供保护是<strong>国际惯例</strong>，赛门铁克、麦咖啡、安博士等国际安全公司都分别对GOOGLE、雅虎等搜索结果提供风险提示。</p>
<p>4、关于360安全卫士的恶评插件功能，已经为网民提供了长达四年的安全服务，对于百度工具栏和百度地址栏是否为恶评插件，是由<strong>网友投票决定</strong>的。百度应该检查这两款软件是否存在不正当行为。</p>
</address>
<p>点评二：360公司的回应可谓是精心设计，模板式的回复。先站在网民的角度告诉所有人，360安全卫士的做法是在保护大家的经济利益。在获得了大家的认可之后，给百度当头一棒：“你不是安全公司”，换句话说就是：“你不行就别瞎嚷嚷”。再有，就是搬出“国际惯例”，其实还是在给百度难看，“你的搜索技术没有跟上国际水平”。最后，又用上了360的看家本领：“网友投票决定的”，和我360无关！整个声明的主题就只有一个，不是我360公司在整你百度，谁让你安全不行呢。我360<strong>代表广大网友，消灭你</strong>！</p>
<p>其实我们坐下来，细细品位整个事件的经过。从安全研究人员的角度来说，百度在整个事件中之所以处于被动地位，归根结底还是自己的安全技术不过关，安全能力被人质疑，安全水平没有达到国际水准。而360恰好就是一个善于“<strong>发现漏洞，定位漏洞，利用漏洞</strong>”的公司。在我看来，百度如果要起诉360，反击360。除了诉诸法律之外，更重要的是拿出有效的反例，来证明360所屏蔽的百度搜索结果，是<span style="color: #ff0000"><strong>误报</strong></span>！从目前事件的发展来看，百度是拿不出这样的误报实例，也就只能从法律漏洞的角度来和360算账了。</p>
<p>360的发展历史和模式给了广大软件厂商，特别是互联网软件厂商敲响了一个警钟。在商业利益、业务模式、用户体验和安全保护面前，安全保护看上去是最不起眼，也是最偏离企业盈利的主线的。但随着广大互联网用户、计算机用户、电子设备用户的安全意识的增强，甚至在某种意义上来说是安全偏执、敏感的趋势下，<strong>以安全的名义来说事还真让人无法反驳</strong>！安全应该成为软件厂商的产品的基本特性之一，而不要想着用安全来做增值服务。因为<strong>安全的本质不是增值，而是减少、避免或挽回风险带来的损失</strong>。<span style="color: #ff0000"><strong>软件产品中有安全特性并不一定会给软件本身增加盈利增长点，但软件产品中没有安全特性一定会给软件本身增加一个失败风险点</strong></span>。再联系到最近的<a href="http://www.cnbeta.com/articles/119875.htm" target="_blank">Intel收购Mcafee事件</a>，让我们看到了国际IT巨头对于安全的态度正在发生着积极、正确的改变。安全的本质价值正在被发现和挖掘，安全产业的新的商业模式正在酝酿和发展。如何以安全的名义来说事、做事和成事是一个值得深入思考的话题。</p>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<div style="margin-top: 15px; ">
<hr style="border: 1px solid #cccccc;"/>
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.huangwei.me/blog/">猪在笑</a> <a href="http://www.huangwei.me/blog/">[ http://www.huangwei.me/blog/ ]</a><br/><strong>本文链接地址:</strong> <a href="http://www.huangwei.me/blog/2010/08/21/security-as-a-slogan/">http://www.huangwei.me/blog/2010/08/21/security-as-a-slogan/</a></p>
<hr style="border: 1px solid #cccccc;"/>
</div>
<div  class="related_post_title">您可能还对以下文章感兴趣</div><ul class="related_post"><li><a href="http://www.huangwei.me/blog/2010/08/04/firefox-extension-install-bug/" title="Firefox扩展安装时来源域检查bug一枚">Firefox扩展安装时来源域检查bug一枚</a></li><li><a href="http://www.huangwei.me/blog/2010/08/02/sniffer-with-perl-pcap/" title="[CodeSnippet]Perl抓包分析之DNS debug">[CodeSnippet]Perl抓包分析之DNS debug</a></li><li><a href="http://www.huangwei.me/blog/2010/08/02/ssh-security-harden/" title="SSH安全加固一二三">SSH安全加固一二三</a></li><li><a href="http://www.huangwei.me/blog/2010/07/29/ssl-mitm-attacks/" title="SSL MITM Attacks">SSL MITM Attacks</a></li><li><a href="http://www.huangwei.me/blog/2010/05/30/simple-ddos-detection/" title="简单几条命令检测DDoS攻击">简单几条命令检测DDoS攻击</a></li><li><a href="http://www.huangwei.me/blog/2010/05/05/cloud-computing-thoughts/" title="云安全服务乱想">云安全服务乱想</a></li><li><a href="http://www.huangwei.me/blog/2010/02/20/2010cwe25/" title="2010 CWE TOP 25">2010 CWE TOP 25</a></li><li><a href="http://www.huangwei.me/blog/2010/02/09/security-misunderstanding/" title="[科普]个人电脑安全的常见误区分析">[科普]个人电脑安全的常见误区分析</a></li><li><a href="http://www.huangwei.me/blog/2010/02/09/anti-telecom-ad/" title="自己动手屏蔽无良电信的网页劫持插广告">自己动手屏蔽无良电信的网页劫持插广告</a></li><li><a href="http://www.huangwei.me/blog/2010/01/30/%e7%a0%b4%e8%a7%a3%e5%90%88%e8%82%a5%e7%94%b5%e4%bf%a1%e7%9a%84adsl%e7%8c%ab%e4%b8%8a%e7%bd%91%e9%99%90%e5%88%b6/" title="破解合肥电信的ADSL猫上网限制">破解合肥电信的ADSL猫上网限制</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.huangwei.me/blog/2010/08/21/security-as-a-slogan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>密码保护：log@2010.8.8 Lunar 6.28</title>
		<link>http://www.huangwei.me/blog/2010/08/09/2010-8-8/</link>
		<comments>http://www.huangwei.me/blog/2010/08/09/2010-8-8/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 16:03:49 +0000</pubDate>
		<dc:creator>c4pr1c3</dc:creator>
				<category><![CDATA[纯净水]]></category>
		<category><![CDATA[总结]]></category>

		<guid isPermaLink="false">http://www.huangwei.me/blog/?p=591</guid>
		<description><![CDATA[无法提供任何摘要。这是一篇受保护的文章。]]></description>
			<content:encoded><![CDATA[<div style="margin-top: 2px;">
<A href="http://creativecommons.org/licenses/by/3.0/deed.zh"><FONT color=#11779f><STRONG>版权声明</STRONG></FONT></A><FONT color=#11779f><STRONG>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></STRONG></FONT>
</div>
<form action="http://www.huangwei.me/blog/wp-pass.php" method="post">
<p>这是一篇受密码保护的文章。您需要提供访问密码：</p>
<p><label for="pwbox-591">密码：<br />
<input name="post_password" id="pwbox-591" type="password" size="20" /></label><br />
<input type="submit" name="Submit" value="提交" /></p></form>
<div style="margin-top: 15px; ">
<hr style="border: 1px solid #cccccc;"/>
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.huangwei.me/blog/">猪在笑</a> <a href="http://www.huangwei.me/blog/">[ http://www.huangwei.me/blog/ ]</a><br/><strong>本文链接地址:</strong> <a href="http://www.huangwei.me/blog/2010/08/09/2010-8-8/">http://www.huangwei.me/blog/2010/08/09/2010-8-8/</a></p>
<hr style="border: 1px solid #cccccc;"/>
</div>
<div  class="related_post_title">您可能还对以下文章感兴趣</div><ul class="related_post"><li><a href="http://www.huangwei.me/blog/2010/07/01/thanks-to-friends/" title="毕业了，感谢我的好友们">毕业了，感谢我的好友们</a></li><li><a href="http://www.huangwei.me/blog/2010/06/30/thanks-to-tutors/" title="毕业了，感谢我的老师们">毕业了，感谢我的老师们</a></li><li><a href="http://www.huangwei.me/blog/2010/06/29/thanks-to-elder/" title="毕业了，感谢我的师兄师姐们">毕业了，感谢我的师兄师姐们</a></li><li><a href="http://www.huangwei.me/blog/2010/06/28/thanks-to-the-young/" title="毕业了，感谢我的师弟师妹们">毕业了，感谢我的师弟师妹们</a></li><li><a href="http://www.huangwei.me/blog/2010/06/09/nothing-but-bull-shit/" title="胡思乱想一篇">胡思乱想一篇</a></li><li><a href="http://www.huangwei.me/blog/2009/12/31/2009%e5%b9%b4a%e6%80%bb%e7%bb%93%e5%92%8c2010%e5%b9%b4b%e8%ae%a1%e5%88%92/" title="2009年A总结和2010年B计划">2009年A总结和2010年B计划</a></li><li><a href="http://www.huangwei.me/blog/2008/12/29/%e6%80%bb%e7%bb%932008/" title="总结2008">总结2008</a></li><li><a href="http://www.huangwei.me/blog/2007/12/31/ua2007-2/" title="总结2007">总结2007</a></li><li><a href="http://www.huangwei.me/blog/2006/12/27/ua2006oiu2007-2/" title="总结2006展望2007">总结2006展望2007</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.huangwei.me/blog/2010/08/09/2010-8-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox扩展安装时来源域检查bug一枚</title>
		<link>http://www.huangwei.me/blog/2010/08/04/firefox-extension-install-bug/</link>
		<comments>http://www.huangwei.me/blog/2010/08/04/firefox-extension-install-bug/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 02:46:56 +0000</pubDate>
		<dc:creator>c4pr1c3</dc:creator>
				<category><![CDATA[0-day]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[安全技术]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[firefox扩展开发]]></category>

		<guid isPermaLink="false">http://www.huangwei.me/blog/?p=588</guid>
		<description><![CDATA[<a href="http://creativecommons.org/licenses/by/3.0/deed.zh"><strong>版权声明</strong></a><strong>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></strong>

Firefox版本：Mozilla Firefox 3.6.8
测试网址：<a href="http://ubublogger.wordpress.com/2010/06/28/new-version-of-libnotify-for-mozilla-0-2-stable/" target="_blank">http://ubublogger.wordpress.com/2010/06/28/new-version-of-libnotify-for-mo[......]</a><p class='read-more'><a href='http://www.huangwei.me/blog/2010/08/04/firefox-extension-install-bug/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<div style="margin-top: 2px;">
<A href="http://creativecommons.org/licenses/by/3.0/deed.zh"><FONT color=#11779f><STRONG>版权声明</STRONG></FONT></A><FONT color=#11779f><STRONG>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></STRONG></FONT>
</div>
<p>Firefox版本：Mozilla Firefox 3.6.8</p>
<p>测试网址：<a href="http://ubublogger.wordpress.com/2010/06/28/new-version-of-libnotify-for-mozilla-0-2-stable/" target="_blank">http://<span style="background-color: #ffff00">ubublogger.wordpress.com</span>/2010/06/28/new-version-of-libnotify-for-mozilla-0-2-stable/</a></p>
<p>bug说明：网页中的扩展安装的真实地址是：<a href="http://launchpad.net/libnotify-mozilla/0.2/0.2-stable/+download/libnotify-mozilla-0.2.xpi" target="_blank">http://<span style="background-color: #ffff00">launchpad.net/</span>libnotify-mozilla/0.2/0.2-stable/+download/libnotify-mozilla-0.2.xpi</a></p>
<p>但是firefox的扩展安装警告提醒用户要安装的扩展来自wordpress.com！这个乌龙有点鸡肋，但认真搞搞也许能被用于鸡翅钓鱼。</p>
<p><img src="http://www.huangwei.me/blog/wp-content/uploads/2010/08/Screenshot.png" alt="Firfox扩展安装时来源域安全检查bug" width="600" height="480" /></p>
<div style="margin-top: 15px; ">
<hr style="border: 1px solid #cccccc;"/>
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.huangwei.me/blog/">猪在笑</a> <a href="http://www.huangwei.me/blog/">[ http://www.huangwei.me/blog/ ]</a><br/><strong>本文链接地址:</strong> <a href="http://www.huangwei.me/blog/2010/08/04/firefox-extension-install-bug/">http://www.huangwei.me/blog/2010/08/04/firefox-extension-install-bug/</a></p>
<hr style="border: 1px solid #cccccc;"/>
</div>
<div  class="related_post_title">您可能还对以下文章感兴趣</div><ul class="related_post"><li><a href="http://www.huangwei.me/blog/2010/07/23/mozilla-chrome-registration/" title="Firefox扩展开发之chrome注册机制">Firefox扩展开发之chrome注册机制</a></li><li><a href="http://www.huangwei.me/blog/2010/07/21/debug-ffextension-with-chromebug/" title="Firefox扩展调试的新方法">Firefox扩展调试的新方法</a></li><li><a href="http://www.huangwei.me/blog/2010/08/21/security-as-a-slogan/" title="以安全的名义">以安全的名义</a></li><li><a href="http://www.huangwei.me/blog/2010/08/02/sniffer-with-perl-pcap/" title="[CodeSnippet]Perl抓包分析之DNS debug">[CodeSnippet]Perl抓包分析之DNS debug</a></li><li><a href="http://www.huangwei.me/blog/2010/08/02/ssh-security-harden/" title="SSH安全加固一二三">SSH安全加固一二三</a></li><li><a href="http://www.huangwei.me/blog/2010/07/29/ssl-mitm-attacks/" title="SSL MITM Attacks">SSL MITM Attacks</a></li><li><a href="http://www.huangwei.me/blog/2010/06/29/firefox-extension-debug/" title="Firefox扩展调试的一些心得和技巧">Firefox扩展调试的一些心得和技巧</a></li><li><a href="http://www.huangwei.me/blog/2010/06/29/vim-xul-cscope/" title="用vim和cscope构建xul代码阅读的环境">用vim和cscope构建xul代码阅读的环境</a></li><li><a href="http://www.huangwei.me/blog/2010/05/30/simple-ddos-detection/" title="简单几条命令检测DDoS攻击">简单几条命令检测DDoS攻击</a></li><li><a href="http://www.huangwei.me/blog/2010/05/05/cloud-computing-thoughts/" title="云安全服务乱想">云安全服务乱想</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.huangwei.me/blog/2010/08/04/firefox-extension-install-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[CodeSnippet]Perl实现Gtk任务栏的消息提示</title>
		<link>http://www.huangwei.me/blog/2010/08/02/perl-gtk2-libnotify/</link>
		<comments>http://www.huangwei.me/blog/2010/08/02/perl-gtk2-libnotify/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 09:21:54 +0000</pubDate>
		<dc:creator>c4pr1c3</dc:creator>
				<category><![CDATA[CodeSnippet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.huangwei.me/blog/?p=584</guid>
		<description><![CDATA[<a href="http://creativecommons.org/licenses/by/3.0/deed.zh"><strong>版权声明</strong></a><strong>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></strong>

依赖的Perl第三方lib为Gtk2::Notify
Ubuntu下安装：
sudo apt-get install libgtk2-notify-perl
代码如下：

#!/usr/bin/perl -w
use Gt[......]<p class='read-more'><a href='http://www.huangwei.me/blog/2010/08/02/perl-gtk2-libnotify/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<div style="margin-top: 2px;">
<A href="http://creativecommons.org/licenses/by/3.0/deed.zh"><FONT color=#11779f><STRONG>版权声明</STRONG></FONT></A><FONT color=#11779f><STRONG>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></STRONG></FONT>
</div>
<p>依赖的Perl第三方lib为Gtk2::Notify</p>
<p>Ubuntu下安装：</p>
<p>sudo apt-get install libgtk2-notify-perl</p>
<p>代码如下：</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
<span style="color: #000000; font-weight: bold;">use</span> Gtk2<span style="color: #339933;">::</span><span style="color: #006600;">Notify</span> <span style="color: #339933;">-</span>init<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Test Perl Notify&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Encode<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$summary</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;summary here&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$message</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;message here&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$icon</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;/usr/share/icons/hicolor/128x128/apps/fwbuilder.png&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$attach_widget</span> <span style="color: #339933;">=</span> <span style="color: #000066;">undef</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$notification</span> <span style="color: #339933;">=</span> Gtk2<span style="color: #339933;">::</span><span style="color: #006600;">Notify</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>new<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$summary</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$message</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$icon</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$attach_widget</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$notification</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>show<span style="color: #339933;">;</span></pre></div></div>

<p>效果如图：</p>
<p><img src="http://www.huangwei.me/blog/wp-content/uploads/2010/08/screenshot42.png" alt="perl-gtk2-libnotify screenshot" width="385" height="171" /></p>
<p>后记：</p>
<p>有这么一款Firefox扩展，可以实现Firefox下载完成的任务栏消息提示。查看了一下它的代码，发现是用python实现的libnotify接口。只需要改一下xpi文件中的install.rdf就可以在3.6版本的Firefox上安装了。扩展安装地址：<a href="https://addons.mozilla.org/en-US/firefox/addon/9622/" target="_blank">https://addons.mozilla.org/en-US/firefox/addon/9622/</a></p>
<p>按照这个方法，其实很多Web应用程序都可以借此实现Linux下的任务栏消息提示集成。有时间的话我来写一个WebQQ的消息提示扩展玩玩。</p>
<div style="margin-top: 15px; ">
<hr style="border: 1px solid #cccccc;"/>
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.huangwei.me/blog/">猪在笑</a> <a href="http://www.huangwei.me/blog/">[ http://www.huangwei.me/blog/ ]</a><br/><strong>本文链接地址:</strong> <a href="http://www.huangwei.me/blog/2010/08/02/perl-gtk2-libnotify/">http://www.huangwei.me/blog/2010/08/02/perl-gtk2-libnotify/</a></p>
<hr style="border: 1px solid #cccccc;"/>
</div>
<div  class="related_post_title">您可能还对以下文章感兴趣</div><ul class="related_post"><li><a href="http://www.huangwei.me/blog/2010/08/02/sniffer-with-perl-pcap/" title="[CodeSnippet]Perl抓包分析之DNS debug">[CodeSnippet]Perl抓包分析之DNS debug</a></li><li><a href="http://www.huangwei.me/blog/2009/06/07/ubuntu%e5%b0%8f%e6%8a%80%e5%b7%a7%e7%b3%bb%e5%88%97%e4%b9%8b%e4%ba%8cprogramming-in-c-from-scratch/" title="[Ubuntu小技巧系列之二]programming in C from scratch">[Ubuntu小技巧系列之二]programming in C from scratch</a></li><li><a href="http://www.huangwei.me/blog/2010/08/30/nautilus-scripts-mount-iso/" title="nautilus脚本应用实例之二：右键菜单挂载/卸载ISO">nautilus脚本应用实例之二：右键菜单挂载/卸载ISO</a></li><li><a href="http://www.huangwei.me/blog/2010/08/30/gnome-nautilus-scripts-meld/" title="nautilus脚本应用实例之一：用meld比较选中的文件或文件夹">nautilus脚本应用实例之一：用meld比较选中的文件或文件夹</a></li><li><a href="http://www.huangwei.me/blog/2010/08/27/wangwang-linux-im/" title="无需安装阿里旺旺即可聊天的方法">无需安装阿里旺旺即可聊天的方法</a></li><li><a href="http://www.huangwei.me/blog/2010/07/29/qemu-vmware-conflict/" title="[已验证]qemu和vmware冲突">[已验证]qemu和vmware冲突</a></li><li><a href="http://www.huangwei.me/blog/2010/02/20/ubuntu-keyboard-shortcuts/" title="Ubuntu中你可能不知道的一些有用的键盘快捷键">Ubuntu中你可能不知道的一些有用的键盘快捷键</a></li><li><a href="http://www.huangwei.me/blog/2010/01/10/linux%e4%b8%8bpptp-vpn-3%e5%88%86%e9%92%9f%e5%bf%ab%e9%80%9f%e9%85%8d%e7%bd%ae/" title="Linux下PPTP VPN 3分钟快速配置">Linux下PPTP VPN 3分钟快速配置</a></li><li><a href="http://www.huangwei.me/blog/2009/11/22/ubuntu%e5%b0%8f%e6%8a%80%e5%b7%a7%e7%b3%bb%e5%88%97%e4%b9%8b%e5%9b%9b%e7%b3%bb%e7%bb%9f%e5%90%af%e5%8a%a8%e4%bc%98%e5%8c%96%e4%b9%8bbootchart/" title="[Ubuntu小技巧系列之四]系统启动优化之bootchart">[Ubuntu小技巧系列之四]系统启动优化之bootchart</a></li><li><a href="http://www.huangwei.me/blog/2009/07/19/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aa%e5%9c%a8%e7%ba%bf%e5%a4%87%e4%bb%bd%e5%92%8c%e6%96%87%e4%bb%b6%e5%90%8c%e6%ad%a5%e7%9a%84%e7%bd%91%e7%ab%99/" title="[推荐]一个在线备份和文件同步的网站">[推荐]一个在线备份和文件同步的网站</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.huangwei.me/blog/2010/08/02/perl-gtk2-libnotify/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[CodeSnippet]Perl抓包分析之DNS debug</title>
		<link>http://www.huangwei.me/blog/2010/08/02/sniffer-with-perl-pcap/</link>
		<comments>http://www.huangwei.me/blog/2010/08/02/sniffer-with-perl-pcap/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 09:05:13 +0000</pubDate>
		<dc:creator>c4pr1c3</dc:creator>
				<category><![CDATA[CodeSnippet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[安全技术]]></category>
		<category><![CDATA[网络技术]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.huangwei.me/blog/?p=579</guid>
		<description><![CDATA[<a href="http://creativecommons.org/licenses/by/3.0/deed.zh"><strong>版权声明</strong></a><strong>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></strong>

依赖的Perl第三方库在Ubuntu上安装：
<ul>
<li>libnet-pcap-perl</li>
<li>libnet-dns-perl</li>
</ul>
如果还需要其他Perl第三方库，可以通过apt-file（Ubuntu Lucid默认没有安装）来检索所需[......]<p class='read-more'><a href='http://www.huangwei.me/blog/2010/08/02/sniffer-with-perl-pcap/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<div style="margin-top: 2px;">
<A href="http://creativecommons.org/licenses/by/3.0/deed.zh"><FONT color=#11779f><STRONG>版权声明</STRONG></FONT></A><FONT color=#11779f><STRONG>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></STRONG></FONT>
</div>
<p>依赖的Perl第三方库在Ubuntu上安装：</p>
<ul>
<li>libnet-pcap-perl</li>
<li>libnet-dns-perl</li>
</ul>
<p>如果还需要其他Perl第三方库，可以通过apt-file（Ubuntu Lucid默认没有安装）来检索所需要的pm文件在哪个deb包。</p>
<p>例如：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ apt-file search Net::DNS::Packet
 libnet-dns-perl: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>man<span style="color: #000000; font-weight: bold;">/</span>man3<span style="color: #000000; font-weight: bold;">/</span>Net::DNS::Packet.3pm.gz</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ apt-file search Net::Pcap
 libnet-pcap-perl: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>man<span style="color: #000000; font-weight: bold;">/</span>man3<span style="color: #000000; font-weight: bold;">/</span>Net::Pcap.3pm.gz</pre></div></div>

<p>Wireshark虽然也可以抓包分析，但是用可编程的脚本语言来辅助分析可以省去很多肉眼比对的工作。<br class="spacer_" /></p>
<p>下面直接上代码：</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Copyright 2003, Brian Hatch, released under the GPL</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># watch_dns:</span>
<span style="color: #666666; font-style: italic;">#   A program to watch for inbound DNS queries, and print the</span>
<span style="color: #666666; font-style: italic;">#   source, destination, and requested domain name of the queries.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># You'll need to fill this in with your actual IP address</span>
<span style="color: #666666; font-style: italic;"># (If we didn't restrict the destination IP address, we'd</span>
<span style="color: #666666; font-style: italic;"># catch all our outbound queries too.)</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Original Downloaded from:</span>
<span style="color: #666666; font-style: italic;"># http://www.hackinglinuxexposed.com/articles/20030730.html</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Modified by huangwei.me 2010-08-02</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># 本机IP地址定义</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$MY_IP_ADDRESS</span><span style="color: #339933;">=</span><span style="color: #ff0000;">'10.2.1.83'</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># 非特权权限的uid/gid，可以用id命令查看当前用户的uid和gid</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$UNPRIV</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;1001&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># 自行指定监听网卡,留空将使用系统默认探测到的网卡</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$MY_DEV</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;vmnet8&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># No changes required hereafter</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">use</span> Net<span style="color: #339933;">::</span><span style="color: #006600;">Pcap</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Net<span style="color: #339933;">::</span><span style="color: #006600;">DNS</span><span style="color: #339933;">::</span><span style="color: #006600;">RR</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> FileHandle<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> English<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;"># $UID等价于$&amp;lt;, $EUID等价于$&amp;gt;</span>
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
&nbsp;
STDOUT<span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>autoflush<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pid</span> <span style="color: #339933;">=</span> <span style="color: #000066;">fork</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #000066;">defined</span> <span style="color: #0000ff;">$pid</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Unable to fork.  Yikes.&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$pid</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;"># Parent process (running as root) will wait for</span>
		<span style="color: #666666; font-style: italic;"># child.  If child exits, we'll create another one.</span>
		<span style="color: #000066;">wait</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;"># To keep us from respawning too fast if necessary.</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Child starting<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;"># Child process will do actual sniffing.</span>
		<span style="color: #666666; font-style: italic;"># First, create our packet capturing device</span>
		<span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pcap_t</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> create_pcap<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">unless</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$pcap_t</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Unable to create pcap&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;"># Let's stop running as root.  Since we already</span>
		<span style="color: #666666; font-style: italic;"># have our pcap descriptor, we can still use it.</span>
		<span style="color: #0000ff;">$EGID</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;$UNPRIV $UNPRIV&quot;</span><span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;"># setgid and setgroups()</span>
		<span style="color: #0000ff;">$GID</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$UNPRIV</span><span style="color: #339933;">;</span>
		<span style="color: #0000ff;">$UID</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$UNPRIV</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$EUID</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$UNPRIV</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;"># Capture packets forever.</span>
		Net<span style="color: #339933;">::</span><span style="color: #006600;">Pcap</span><span style="color: #339933;">::</span><span style="color: #006600;">loop</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pcap_t</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">\&amp;amp</span><span style="color: #339933;">;</span>process_pkt<span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;"># Technically, we shouldn't get here since the loop</span>
		<span style="color: #666666; font-style: italic;"># is infinite (-1), but just in case, close and exit.</span>
		Net<span style="color: #339933;">::</span><span style="color: #006600;">Pcap</span><span style="color: #339933;">::</span><span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pcap_t</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">exit</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> create_pcap <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$promisc</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;"># enter promiscuous mode or not.</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$snaplen</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1500</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># the maximum number of bytes to capture from each packet</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$to_ms</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>			<span style="color: #666666; font-style: italic;"># timeout</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$opt</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>                          <span style="color: #666666; font-style: italic;"># Sure, optimisation is good...</span>
	<span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$err</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$net</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$mask</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$dev</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$filter_t</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$filter</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;udp dst port 53 or udp src port 53&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># pcap capture filter</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># Look up an appropriate device (eth0 usually)</span>
	<span style="color: #0000ff;">$dev</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$MY_DEV</span> <span style="color: #339933;">||</span> Net<span style="color: #339933;">::</span><span style="color: #006600;">Pcap</span><span style="color: #339933;">::</span><span style="color: #006600;">lookupdev</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">\$err</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;sniffing on &quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$dev</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$dev</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Net::Pcap::lookupdev failed.  Error was $err&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>Net<span style="color: #339933;">::</span><span style="color: #006600;">Pcap</span><span style="color: #339933;">::</span><span style="color: #006600;">lookupnet</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$dev</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">\$net</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">\$mask</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">\$err</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Net::Pcap::lookupnet failed.  Error was $err&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># Actually open up our descriptor</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pcap_t</span> <span style="color: #339933;">=</span> Net<span style="color: #339933;">::</span><span style="color: #006600;">Pcap</span><span style="color: #339933;">::</span><span style="color: #006600;">open_live</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$dev</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$snaplen</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$promisc</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$to_ms</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">\$err</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$pcap_t</span> <span style="color: #339933;">||</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Can't create packet descriptor.  Error was $err&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> Net<span style="color: #339933;">::</span><span style="color: #006600;">Pcap</span><span style="color: #339933;">::</span><span style="color: #006600;">compile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pcap_t</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">\$filter_t</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$filter</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$opt</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$net</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Unable to compile filter string '$filter'<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># Make sure our sniffer only captures those bytes we want in</span>
	<span style="color: #666666; font-style: italic;"># our filter.</span>
	Net<span style="color: #339933;">::</span><span style="color: #006600;">Pcap</span><span style="color: #339933;">::</span><span style="color: #006600;">setfilter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pcap_t</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$filter_t</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># Return our pcap descriptor</span>
	<span style="color: #0000ff;">$pcap_t</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Routine to process the packet -- called by Net::Pcap::loop()</span>
<span style="color: #666666; font-style: italic;"># every time an appropriate packet is snagged.</span>
<span style="color: #000000; font-weight: bold;">sub</span> process_pkt <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$user_data</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$hdr</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$pkt</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@_</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$src_ip</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">26</span><span style="color: #339933;">;</span>           <span style="color: #666666; font-style: italic;"># start of the source IP in the packet</span>
	<span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$dst_ip</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">;</span>           <span style="color: #666666; font-style: italic;"># start of the dest IP in the packet</span>
	<span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$udp</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">42</span><span style="color: #339933;">;</span>              <span style="color: #666666; font-style: italic;"># start of UDP pkt payload</span>
	<span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$domain_start</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">55</span><span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;"># start of the domain in the packet</span>
	<span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># extract the source IP addr into dotted quad form.</span>
	<span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$source</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d.%d.%d.%d&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #000066;">ord</span><span style="color: #009900;">&#40;</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pkt</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$src_ip</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #000066;">ord</span><span style="color: #009900;">&#40;</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pkt</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$src_ip</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #000066;">ord</span><span style="color: #009900;">&#40;</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pkt</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$src_ip</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #000066;">ord</span><span style="color: #009900;">&#40;</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pkt</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$src_ip</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># extract the destination IP addr into dotted quad form.</span>
	<span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$destination</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d.%d.%d.%d&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #000066;">ord</span><span style="color: #009900;">&#40;</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pkt</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$dst_ip</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #000066;">ord</span><span style="color: #009900;">&#40;</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pkt</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$dst_ip</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #000066;">ord</span><span style="color: #009900;">&#40;</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pkt</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$dst_ip</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #000066;">ord</span><span style="color: #009900;">&#40;</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pkt</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$dst_ip</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #0000ff;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pkt</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$domain_start</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #0000ff;">$data</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/0.*//g</span><span style="color: #339933;">;</span>             <span style="color: #666666; font-style: italic;"># strip off everything after the domain</span>
	<span style="color: #0000ff;">$data</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/[^-a-zA-Z0-9]/./g</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;"># change the domain component separators</span>
	<span style="color: #666666; font-style: italic;"># back int to dots.</span>
&nbsp;
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;$source -&amp;gt; $destination: $data<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$source</span> <span style="color: #b1b100;">and</span> <span style="color: #0000ff;">$destination</span> <span style="color: #b1b100;">and</span> <span style="color: #0000ff;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	dump_dns<span style="color: #009900;">&#40;</span>parse_dns<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pkt</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$udp</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># dump dns query &amp;amp; response in details</span>
<span style="color: #000000; font-weight: bold;">sub</span> dump_dns <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dns</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$dns</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>print<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> parse_dns <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pkt</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$udp</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@_</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$udp_payload</span> <span style="color: #339933;">=</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$pkt</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$udp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dns</span> <span style="color: #339933;">=</span> Net<span style="color: #339933;">::</span><span style="color: #006600;">DNS</span><span style="color: #339933;">::</span><span style="color: #006600;">Packet</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>new<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">\$udp_payload</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">return</span> <span style="color: #0000ff;">$dns</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<div style="margin-top: 15px; ">
<hr style="border: 1px solid #cccccc;"/>
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.huangwei.me/blog/">猪在笑</a> <a href="http://www.huangwei.me/blog/">[ http://www.huangwei.me/blog/ ]</a><br/><strong>本文链接地址:</strong> <a href="http://www.huangwei.me/blog/2010/08/02/sniffer-with-perl-pcap/">http://www.huangwei.me/blog/2010/08/02/sniffer-with-perl-pcap/</a></p>
<hr style="border: 1px solid #cccccc;"/>
</div>
<div  class="related_post_title">您可能还对以下文章感兴趣</div><ul class="related_post"><li><a href="http://www.huangwei.me/blog/2010/08/27/wangwang-linux-im/" title="无需安装阿里旺旺即可聊天的方法">无需安装阿里旺旺即可聊天的方法</a></li><li><a href="http://www.huangwei.me/blog/2010/08/02/perl-gtk2-libnotify/" title="[CodeSnippet]Perl实现Gtk任务栏的消息提示">[CodeSnippet]Perl实现Gtk任务栏的消息提示</a></li><li><a href="http://www.huangwei.me/blog/2010/08/30/nautilus-scripts-mount-iso/" title="nautilus脚本应用实例之二：右键菜单挂载/卸载ISO">nautilus脚本应用实例之二：右键菜单挂载/卸载ISO</a></li><li><a href="http://www.huangwei.me/blog/2010/08/30/gnome-nautilus-scripts-meld/" title="nautilus脚本应用实例之一：用meld比较选中的文件或文件夹">nautilus脚本应用实例之一：用meld比较选中的文件或文件夹</a></li><li><a href="http://www.huangwei.me/blog/2010/08/02/ssh-security-harden/" title="SSH安全加固一二三">SSH安全加固一二三</a></li><li><a href="http://www.huangwei.me/blog/2010/07/29/qemu-vmware-conflict/" title="[已验证]qemu和vmware冲突">[已验证]qemu和vmware冲突</a></li><li><a href="http://www.huangwei.me/blog/2010/05/30/simple-ddos-detection/" title="简单几条命令检测DDoS攻击">简单几条命令检测DDoS攻击</a></li><li><a href="http://www.huangwei.me/blog/2010/03/24/firefox-autoproxy-pac-bug-fix/" title="[原创]非官方修复Firefox自动代理配置脚本bug的方法">[原创]非官方修复Firefox自动代理配置脚本bug的方法</a></li><li><a href="http://www.huangwei.me/blog/2010/02/20/ubuntu-keyboard-shortcuts/" title="Ubuntu中你可能不知道的一些有用的键盘快捷键">Ubuntu中你可能不知道的一些有用的键盘快捷键</a></li><li><a href="http://www.huangwei.me/blog/2010/02/09/anti-telecom-ad/" title="自己动手屏蔽无良电信的网页劫持插广告">自己动手屏蔽无良电信的网页劫持插广告</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.huangwei.me/blog/2010/08/02/sniffer-with-perl-pcap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH安全加固一二三</title>
		<link>http://www.huangwei.me/blog/2010/08/02/ssh-security-harden/</link>
		<comments>http://www.huangwei.me/blog/2010/08/02/ssh-security-harden/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 04:59:07 +0000</pubDate>
		<dc:creator>c4pr1c3</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[安全技术]]></category>
		<category><![CDATA[denyhosts]]></category>
		<category><![CDATA[fail2ban]]></category>
		<category><![CDATA[pam_abl]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[安全加固]]></category>
		<category><![CDATA[暴力破解]]></category>

		<guid isPermaLink="false">http://www.huangwei.me/blog/?p=574</guid>
		<description><![CDATA[<a href="http://creativecommons.org/licenses/by/3.0/deed.zh"><strong>版权声明</strong></a><strong>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></strong>

今天车东大侠在GReader上分享了一篇文章《<a href="https://blog.delphij.net/2010/07/ssh.html" target="_blank">为什么要用公钥/私钥而不是密码去做SSH身份验证</a>》，联系到最近越来越恶劣的网络环境，我越发觉得有必要把我的一些SSH安全方法分享一下，以降低SSH通道被恶意破坏的概率，提高攻击[......]<p class='read-more'><a href='http://www.huangwei.me/blog/2010/08/02/ssh-security-harden/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<div style="margin-top: 2px;">
<A href="http://creativecommons.org/licenses/by/3.0/deed.zh"><FONT color=#11779f><STRONG>版权声明</STRONG></FONT></A><FONT color=#11779f><STRONG>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></STRONG></FONT>
</div>
<p>今天车东大侠在GReader上分享了一篇文章《<a href="https://blog.delphij.net/2010/07/ssh.html" target="_blank">为什么要用公钥/私钥而不是密码去做SSH身份验证</a>》，联系到最近越来越恶劣的网络环境，我越发觉得有必要把我的一些SSH安全方法分享一下，以降低SSH通道被恶意破坏的概率，提高攻击者的攻击代价。</p>
<h2>0. 系统自动更新</h2>
<p>这个世界上没有什么漏洞会比一个系统级的远程溢出漏洞更可怕的了！虽然此类漏洞如今是越来越少被公开，越来越少被发现。但本着不怕一万，就怕万一的安全指导原则。小概率、高危险的漏洞只能依靠及时的系统更新来帮助我们修复了。</p>
<p>除此之外，应用软件级别的漏洞也可以通过系统自动更新来杜绝。</p>
<p>以下的安全加固主要是从应用程序配置的角度来谈SSH的安全加固，配置既包括SSH本身的配置参数，也包括使用第三方软件来对SSH进行额外的安全配置。</p>
<h2>1. 更换默认的SSH端口</h2>
<p>有句大俗话，叫&#8221;不怕贼偷就怕贼惦记&#8221;。对于信息安全来说，就是“只要给我足够的时间，任何系统都会被发现漏洞，并被攻破”。如果使用默认的22端口来使用SSH，其主要不安全因素体现在2点：</p>
<p>(1) 互联网上每时每刻都有人在做端口扫描，在nmap的默认扫描设置里，22端口作为常用端口会在默认的扫描选项条件下被用于端口扫描、连接尝试、操作系统探测等。所以，如果你使用默认的22端口，就是等于告诉“贼”：“来吧，我在用SSH服务。试试看暴力破解我的口令？”</p>
<p>(2) 有一个英文单词叫censorship，有一种技术叫DPI，有一种设备叫IDS。造句就是：censorship会使用基于DPI技术的IDS来偷窥你！如果你使用默认的22端口，那么IDS会非常开心，因为这等于是帮助它节省了DPI的开销！</p>
<h2>2. sshd设置中的不安全因素</h2>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># 建议更换默认端口</span>
Port <span style="color: #000000;">22</span>
<span style="color: #666666; font-style: italic;"># 建议只监听需要的端口，默认是监听所有可用的本机IP地址</span>
<span style="color: #666666; font-style: italic;">#ListenAddress ::</span>
<span style="color: #666666; font-style: italic;">#ListenAddress 0.0.0.0</span>
<span style="color: #666666; font-style: italic;"># 建议只使用SSH协议版本2</span>
Protocol <span style="color: #000000;">2</span>
<span style="color: #666666; font-style: italic;"># 建议使用更长的服务器密钥长度，如2048</span>
ServerKeyBits <span style="color: #000000;">768</span>
<span style="color: #666666; font-style: italic;"># Authentication:</span>
<span style="color: #666666; font-style: italic;"># 默认登录超时时间一般为120秒，建议缩短该时间到30</span>
LoginGraceTime <span style="color: #000000;">120</span>
<span style="color: #666666; font-style: italic;"># 建议禁止Root用户直接登录，将yes改为no</span>
PermitRootLogin <span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #666666; font-style: italic;"># 如果你不需要基于口令的登录方式，可以将yes改为no</span>
<span style="color: #666666; font-style: italic;">#PasswordAuthentication yes</span></pre></div></div>

<h2>3. 使用第三方安全加固工具</h2>
<p>目前来说，针对SSH协议的最轻便的攻击手段就是暴力口令破解。因此，使用第三方安全加固工具的主要目的也就是对抗暴力破解攻击。现有的第三方SSH暴力破解对抗工具从技术实现手段来说，主要有两大类。分别是基于日志审计触发机制和基于PAM的插件机制。基于日志审计触发机制的代表工具分别是<a href="http://www.fail2ban.org/wiki/index.php/Main_Page">fail2ban</a>和<a href="http://denyhosts.sourceforge.net/">denyhosts</a>，但这两款工具都曾经暴露出一些漏洞，其中主要的漏洞原理都是日志注入技术。相比较而言，<a href="http://pam-abl.deksai.com/" target="_blank">pam_abl</a>是更为安全的一种防止暴力破解口令攻击的工具。</p>
<p>最后推荐Google &#8220;<strong>ssh security best practice</strong>&#8220;</p>
<p>第一条结果就非常值得仔细阅读：<a href="http://www.cyberciti.biz/tips/linux-unix-bsd-openssh-server-best-practices.html" target="_blank">http://www.cyberciti.biz/tips/linux-unix-bsd-openssh-server-best-practices.html</a></p>
<h3>参考资料</h3>
<ol>
<li><a href="http://www.rackaid.com/resources/how-to-harden-or-secure-ssh-for-improved-security/" target="_blank">http://www.rackaid.com/resources/how-to-harden-or-secure-ssh-for-improved-security/</a></li>
<li><a href="http://www.rackaid.com/resources/rise-in-ssh-brute-force-attacks/" target="_blank">http://www.rackaid.com/resources/rise-in-ssh-brute-force-attacks/</a></li>
<li><a href="http://www.ossec.net/main/attacking-log-analysis-tools" target="_blank">http://www.ossec.net/main/attacking-log-analysis-tools</a></li>
</ol>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<div style="width: 1px;height: 1px;overflow: hidden">
<h1 id="page-title" class="asset-name entry-title">为什么要用公钥/私钥而不是密码去做SSH身份验证</h1>
</div>
<div style="margin-top: 15px; ">
<hr style="border: 1px solid #cccccc;"/>
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.huangwei.me/blog/">猪在笑</a> <a href="http://www.huangwei.me/blog/">[ http://www.huangwei.me/blog/ ]</a><br/><strong>本文链接地址:</strong> <a href="http://www.huangwei.me/blog/2010/08/02/ssh-security-harden/">http://www.huangwei.me/blog/2010/08/02/ssh-security-harden/</a></p>
<hr style="border: 1px solid #cccccc;"/>
</div>
<div  class="related_post_title">您可能还对以下文章感兴趣</div><ul class="related_post"><li><a href="http://www.huangwei.me/blog/2010/08/02/sniffer-with-perl-pcap/" title="[CodeSnippet]Perl抓包分析之DNS debug">[CodeSnippet]Perl抓包分析之DNS debug</a></li><li><a href="http://www.huangwei.me/blog/2010/05/30/simple-ddos-detection/" title="简单几条命令检测DDoS攻击">简单几条命令检测DDoS攻击</a></li><li><a href="http://www.huangwei.me/blog/2010/01/30/%e7%a0%b4%e8%a7%a3%e5%90%88%e8%82%a5%e7%94%b5%e4%bf%a1%e7%9a%84adsl%e7%8c%ab%e4%b8%8a%e7%bd%91%e9%99%90%e5%88%b6/" title="破解合肥电信的ADSL猫上网限制">破解合肥电信的ADSL猫上网限制</a></li><li><a href="http://www.huangwei.me/blog/2007/03/20/obacktrack-2oaiec-2/" title="[原创]BackTrack 2硬盘安装笔记">[原创]BackTrack 2硬盘安装笔记</a></li><li><a href="http://www.huangwei.me/blog/2010/08/30/nautilus-scripts-mount-iso/" title="nautilus脚本应用实例之二：右键菜单挂载/卸载ISO">nautilus脚本应用实例之二：右键菜单挂载/卸载ISO</a></li><li><a href="http://www.huangwei.me/blog/2010/08/30/gnome-nautilus-scripts-meld/" title="nautilus脚本应用实例之一：用meld比较选中的文件或文件夹">nautilus脚本应用实例之一：用meld比较选中的文件或文件夹</a></li><li><a href="http://www.huangwei.me/blog/2010/08/27/wangwang-linux-im/" title="无需安装阿里旺旺即可聊天的方法">无需安装阿里旺旺即可聊天的方法</a></li><li><a href="http://www.huangwei.me/blog/2010/08/21/security-as-a-slogan/" title="以安全的名义">以安全的名义</a></li><li><a href="http://www.huangwei.me/blog/2010/08/04/firefox-extension-install-bug/" title="Firefox扩展安装时来源域检查bug一枚">Firefox扩展安装时来源域检查bug一枚</a></li><li><a href="http://www.huangwei.me/blog/2010/08/02/perl-gtk2-libnotify/" title="[CodeSnippet]Perl实现Gtk任务栏的消息提示">[CodeSnippet]Perl实现Gtk任务栏的消息提示</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.huangwei.me/blog/2010/08/02/ssh-security-harden/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[已验证]qemu和vmware冲突</title>
		<link>http://www.huangwei.me/blog/2010/07/29/qemu-vmware-conflict/</link>
		<comments>http://www.huangwei.me/blog/2010/07/29/qemu-vmware-conflict/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 11:34:28 +0000</pubDate>
		<dc:creator>c4pr1c3</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[qemu]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[vmware]]></category>
		<category><![CDATA[wine]]></category>
		<category><![CDATA[zerowine]]></category>

		<guid isPermaLink="false">http://www.huangwei.me/blog/?p=571</guid>
		<description><![CDATA[<a href="http://creativecommons.org/licenses/by/3.0/deed.zh"><strong>版权声明</strong></a><strong>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></strong>

已验证冲突的平台环境
<strong>OS</strong>: Ubuntu 10.04.1 LTS 32bit
<strong>Platform</strong>: thinkpad x201i
<strong>VMWare</strong>: 7.0.0 build-203739
<strong>qemu</strong>: QEMU PC emula[......]<p class='read-more'><a href='http://www.huangwei.me/blog/2010/07/29/qemu-vmware-conflict/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<div style="margin-top: 2px;">
<A href="http://creativecommons.org/licenses/by/3.0/deed.zh"><FONT color=#11779f><STRONG>版权声明</STRONG></FONT></A><FONT color=#11779f><STRONG>：可以任意转载，转载时请务必以超链接形式标明文章原始出处和<a href="http://www.huangwei.me/blog/">作者信息</a></STRONG></FONT>
</div>
<h2>已验证冲突的平台环境</h2>
<p><strong>OS</strong>: Ubuntu 10.04.1 LTS 32bit</p>
<p><strong>Platform</strong>: thinkpad x201i</p>
<p><strong>VMWare</strong>: 7.0.0 build-203739</p>
<p><strong>qemu</strong>: QEMU PC emulator version 0.12.3 (qemu-kvm-0.12.3), Copyright (c) 2003-2008 Fabrice Bellard</p>
<h2>具体症状</h2>
<p>在终端运行qemu后出现：</p>
<p>kvm: unhandled exit 5<br />
 kvm_run returned -22</p>
<p> 或者</p>
<p>kvm: unhandled exit 7<br />
 kvm_run returned -22</p>
<h2>其他-1</h2>
<p>在Ubuntu下用zerowine自动化分析Windows下的程序行为，发现qemu总是异常僵死。尝试了多种环境配置和不同的启动参数均未果，最终发现了原因之所在。</p>
<h2>其他-2</h2>
<p>在Ubuntu 10.04上用apt-get安装kvm-pxe时会出现apt-get错误，如下：</p>
<p>dpkg: error processing /var/cache/apt/archives/kvm-pxe_5.4.4-1ubuntu1.1_all.deb (&#8211;install):<br />
 unable to open &#8216;/usr/share/kvm/pxe-e1000.bin.dpkg-new&#8217;: No such file or directory</p>
<p>通过apt-file命令（需要另外安装，默认lucid没有安装这个程序）可以找到所缺失的这个文件在哪个deb包里！</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ apt-file search pxe-e1000.bin
kvm-pxe: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>kvm<span style="color: #000000; font-weight: bold;">/</span>pxe-e1000.bin
kvm-pxe: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>qemu<span style="color: #000000; font-weight: bold;">/</span>pxe-e1000.bin</pre></div></div>

<p>但是只要一用apt-get install去安装就会报上面的错误。Google后得知，这是一个迄今为止未得到<a href="https://bugs.launchpad.net/ubuntu/+source/dpkg/+bug/574524" target="_blank">官方修复的bug</a>！</p>
<p>原因就在于系统在安装qemu和kvm的时候，已经建立了一个链接，由/usr/share/kvm指向/usr/share/qemu！</p>
<p>解决方法很简单，删除/usr/share/kvm这个链接就可以了。</p>
<div style="margin-top: 15px; ">
<hr style="border: 1px solid #cccccc;"/>
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.huangwei.me/blog/">猪在笑</a> <a href="http://www.huangwei.me/blog/">[ http://www.huangwei.me/blog/ ]</a><br/><strong>本文链接地址:</strong> <a href="http://www.huangwei.me/blog/2010/07/29/qemu-vmware-conflict/">http://www.huangwei.me/blog/2010/07/29/qemu-vmware-conflict/</a></p>
<hr style="border: 1px solid #cccccc;"/>
</div>
<div  class="related_post_title">您可能还对以下文章感兴趣</div><ul class="related_post"><li><a href="http://www.huangwei.me/blog/2010/08/30/nautilus-scripts-mount-iso/" title="nautilus脚本应用实例之二：右键菜单挂载/卸载ISO">nautilus脚本应用实例之二：右键菜单挂载/卸载ISO</a></li><li><a href="http://www.huangwei.me/blog/2010/08/30/gnome-nautilus-scripts-meld/" title="nautilus脚本应用实例之一：用meld比较选中的文件或文件夹">nautilus脚本应用实例之一：用meld比较选中的文件或文件夹</a></li><li><a href="http://www.huangwei.me/blog/2010/08/27/wangwang-linux-im/" title="无需安装阿里旺旺即可聊天的方法">无需安装阿里旺旺即可聊天的方法</a></li><li><a href="http://www.huangwei.me/blog/2010/08/02/perl-gtk2-libnotify/" title="[CodeSnippet]Perl实现Gtk任务栏的消息提示">[CodeSnippet]Perl实现Gtk任务栏的消息提示</a></li><li><a href="http://www.huangwei.me/blog/2010/08/02/sniffer-with-perl-pcap/" title="[CodeSnippet]Perl抓包分析之DNS debug">[CodeSnippet]Perl抓包分析之DNS debug</a></li><li><a href="http://www.huangwei.me/blog/2010/02/20/ubuntu-keyboard-shortcuts/" title="Ubuntu中你可能不知道的一些有用的键盘快捷键">Ubuntu中你可能不知道的一些有用的键盘快捷键</a></li><li><a href="http://www.huangwei.me/blog/2010/01/10/linux%e4%b8%8bpptp-vpn-3%e5%88%86%e9%92%9f%e5%bf%ab%e9%80%9f%e9%85%8d%e7%bd%ae/" title="Linux下PPTP VPN 3分钟快速配置">Linux下PPTP VPN 3分钟快速配置</a></li><li><a href="http://www.huangwei.me/blog/2009/11/22/ubuntu%e5%b0%8f%e6%8a%80%e5%b7%a7%e7%b3%bb%e5%88%97%e4%b9%8b%e5%9b%9b%e7%b3%bb%e7%bb%9f%e5%90%af%e5%8a%a8%e4%bc%98%e5%8c%96%e4%b9%8bbootchart/" title="[Ubuntu小技巧系列之四]系统启动优化之bootchart">[Ubuntu小技巧系列之四]系统启动优化之bootchart</a></li><li><a href="http://www.huangwei.me/blog/2009/07/19/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aa%e5%9c%a8%e7%ba%bf%e5%a4%87%e4%bb%bd%e5%92%8c%e6%96%87%e4%bb%b6%e5%90%8c%e6%ad%a5%e7%9a%84%e7%bd%91%e7%ab%99/" title="[推荐]一个在线备份和文件同步的网站">[推荐]一个在线备份和文件同步的网站</a></li><li><a href="http://www.huangwei.me/blog/2009/06/11/ubuntu%e5%b0%8f%e6%8a%80%e5%b7%a7%e7%b3%bb%e5%88%97%e4%b9%8b%e4%b8%89%e8%b7%a8%e5%b9%b3%e5%8f%b0%e5%8e%8b%e7%bc%a9%e6%96%87%e4%bb%b6%e8%a7%a3%e5%8e%8b%e7%bc%a9%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98/" title="[Ubuntu小技巧系列之三]跨平台压缩文件解压缩乱码问题的解决">[Ubuntu小技巧系列之三]跨平台压缩文件解压缩乱码问题的解决</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.huangwei.me/blog/2010/07/29/qemu-vmware-conflict/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
