<?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>onHacks &#187; Testing</title>
	<atom:link href="http://onhacks.org/lang/zh-hk/tag/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://onhacks.org</link>
	<description>On Hacking Across Boundaries</description>
	<lastBuildDate>Wed, 02 Jun 2010 05:48:30 +0000</lastBuildDate>
	<language>zh-hk</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>檢測虛擬機和蜜罐方法的概念</title>
		<link>http://onhacks.org/lang/zh-hk/2009/08/21/concept-of-virtual-machines-and-honeypots-detection-techniques</link>
		<comments>http://onhacks.org/lang/zh-hk/2009/08/21/concept-of-virtual-machines-and-honeypots-detection-techniques#comments</comments>
		<pubDate>Fri, 21 Aug 2009 09:00:30 +0000</pubDate>
		<dc:creator>log0</dc:creator>
				<category><![CDATA[Honeypot]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://onhacks.org/?p=522</guid>
		<description><![CDATA[在 &#8220;誰在入侵我的系統?&#8221; 裡，我講述了如何用 Nmap 地簡單檢測出一個蜜罐，在上一篇亦簡單的交待了。如何做是有趣的，但更有趣的是為甚麼能做到，我們應該要學會了解背後原理才算真正成長了。那麼， 為甚麼檢測方法能檢測出蜜罐呢？ 首先，問自己： 如何分辯人和電腦？ 圖片文字 (CAPTCHA) 的答案是：讓目標去認出一些文字。若能認出，大概是人，否則就是電腦。其中的概念為電腦不能有效地認出圖篇中的文字。 抽像少許，我們要求目標去做一些人類能輕易做到的事，但電腦則不能。利用這點，若果過關了，就是人類，否則不是。 CAPTCHA 可以用來分辯電腦和人類。那麼怎樣分辯出真的服務和模擬服務？ 同理，技術層面上，模擬服務和真的服務有不同之處，這不同之處正是用來區分兩者的要訣。利用這一點，就能分辯出兩者了。 以一個實際例子說明吧。有些人很喜歡問： 如何分析一段不在虛擬機運行的惡意代碼？我的 VMware 不行，難道要用實體機？ 等等！但它會在 VirtualBox 裡運行！Eh? 去找一個 SdBot 。它們大多數有 能測出虛擬機 的能力，至使在虛擬機中不會運行。你在 VMware 裡頭試試下，是 VMware。之後，用 VirtualBox 再試試。不過，我已測過了，信我的結果的話，能可以省省時間看下去了。 所以，他們問錯問題了！應該問： 為甚麼 SdBot 能區分虛擬機和實體機？ 它能夠做到是因為在技術性層面上，虛擬機和實體機有不同之處。這是和真的服務和虛擬服務同出一轍的。當我說的技術性層面的不同之處，就是說實現方法不同。 準確來說，SdBot 能在 VirtualBox 但不能在 VMware 裡運行意味著 SdBot 是能檢測 VMware，但並不是防所有虛擬機的。 看看： 同一個動作，VMware 可能會使用寄存器 (register) 但實體機不會。 VMware 有一個 dhcpd 來分派 [...]]]></description>
			<content:encoded><![CDATA[




















<p><span lang="zh-hk">在 &#8220;<a href="http://onhacks.org/lang/zh-hk/2009/07/12/%e8%aa%b0%e5%9c%a8%e5%85%a5%e4%be%b5%e6%88%91%e7%9a%84%e7%b3%bb%e7%b5%b1" target="_blank">誰在入侵我的系統?</a>&#8221; 裡，我講述了如何用 Nmap 地簡單檢測出一個蜜罐，在<a href="http://onhacks.org/lang/zh-hk/2009/08/13/one-method-to-detect-low-interaction-honeypots" target="_blank">上一篇</a>亦簡單的交待了。如何做是有趣的，但更有趣的是為甚麼能做到，我們應該要學會了解背後原理才算真正成長了。那麼，</span></p>
<p><span lang="zh-hk">為甚麼檢測方法能檢測出蜜罐呢？</span></p>
<p><span lang="zh-hk">首先，問自己：</span></p>
<p><span lang="zh-hk">如何分辯人和電腦？</span></p>
<p><span lang="zh-hk">圖片文字 (CAPTCHA) 的答案是：讓目標去認出一些文字。若能認出，大概是人，否則就是電腦。其中的概念為電腦不能有效地認出圖篇中的文字。</span></p>
<p><span lang="zh-hk">抽像少許，我們要求目標去做一些人類能輕易做到的事，但電腦則不能。利用這點，若果過關了，就是人類，否則不是。</span></p>
<p><span lang="zh-hk">CAPTCHA 可以用來分辯電腦和人類。那麼怎樣分辯出真的服務和模擬服務？</span></p>
<p><span lang="zh-hk">同理，<strong>技術層面上，模擬服務和真的服務有不同之處，這不同之處正是用來區分兩者的要訣</strong>。利用這一點，就能分辯出兩者了。</span></p>
<p><span lang="zh-hk">以一個實際例子說明吧。有些人很喜歡問：</span></p>
<p><span lang="zh-hk"><strong>如何分析一段不在虛擬機運行的惡意代碼？</strong>我的 VMware 不行，難道要用實體機？</span></p>
<p><span lang="zh-hk">等等！但它會在 VirtualBox 裡運行！Eh?</span></p>
<p><span lang="zh-hk">去找一個 SdBot 。它們大多數有 能測出虛擬機 的能力，至使在虛擬機中不會運行。你在 VMware 裡頭試試下，是 VMware。之後，用 VirtualBox 再試試。不過，我已測過了，信我的結果的話，能可以省省時間看下去了。</span></p>
<p><span lang="zh-hk">所以，他們問錯問題了！應該問：</span></p>
<p><span lang="zh-hk"><strong>為甚麼 SdBot 能區分虛擬機和實體機？</strong></span></p>
<p><span lang="zh-hk">它能夠做到是因為在技術性層面上，虛擬機和實體機有不同之處。這是和真的服務和虛擬服務同出一轍的。當我說的技術性層面的不同之處，就是說實現方法不同。</span></p>
<p><span lang="zh-hk">準確來說，SdBot 能在 VirtualBox 但不能在 VMware 裡運行意味著 SdBot 是能檢測 VMware，但並不是防所有虛擬機的。</span></p>
<p><span lang="zh-hk">看看：</span></p>
<ul>
<li><span lang="zh-hk">同一個動作，VMware 可能會使用寄存器 (register) 但實體機不會。</span></li>
<li><span lang="zh-hk">VMware 有一個 dhcpd 來分派 IP 給虛擬機，這是實體機大多數沒有的。</span></li>
<li><span lang="zh-hk">有些處理器命令 VMware 沒有支持。</span></li>
</ul>
<p><span lang="zh-hk">和之前講述的一樣道理。</span></p>
<p><span lang="zh-hk">所以，所謂的不會在虛擬機運行的惡意代碼，正確來說是不在某種虛擬機下運行而已。在其他沒能檢測出的虛擬機 (VirtualBox, Xen, etc) 等就<strong>會</strong>運行了。當然，那檢測方法可能一次過能檢測出多種虛擬機。</span></p>
<p><span lang="zh-hk">總結就是，如果要在虛擬機下運行 SdBot 的話，你不用用實體機這麼麻煩，只要找出一個不被檢出的環境或關掉它的檢測方法就好了。這就是箇中道理了，這亦是如何檢測出其他蜜罐的概念。努力找蜜罐吧！</span></p>





















]]></content:encoded>
			<wfw:commentRss>http://onhacks.org/lang/zh-hk/2009/08/21/concept-of-virtual-machines-and-honeypots-detection-techniques/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>檢測出低互動性蜜罐方法之一</title>
		<link>http://onhacks.org/lang/zh-hk/2009/08/13/one-method-to-detect-low-interaction-honeypots</link>
		<comments>http://onhacks.org/lang/zh-hk/2009/08/13/one-method-to-detect-low-interaction-honeypots#comments</comments>
		<pubDate>Thu, 13 Aug 2009 13:51:46 +0000</pubDate>
		<dc:creator>log0</dc:creator>
				<category><![CDATA[Honeypot]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://onhacks.org/?p=536</guid>
		<description><![CDATA[在 &#8220;誰在入侵我的系統?&#8220;, 我提到過用 Nmap 的服務分析來找找有趣的發現。以下為結果： 這是沒有用到服務分析的 (淨化了)： # Nmap 4.90RC1 scan initiated Sat Jul 11 00:39:13 2009 as: nmap -oN result.sS.txt -v -sS &#60;XXXXXX&#62; Host &#60;xxxxxx&#62; (aaa.bbb.ccc.ddd) is up (0.092s latency). Interesting ports on &#60;xxxxxx&#62; (aaa.bbb.ccc.ddd): Not shown: 550 filtered ports, 434 closed ports PORT     STATE SERVICE 21/tcp   open  ftp 22/tcp   open  ssh 25/tcp   open  [...]]]></description>
			<content:encoded><![CDATA[

<p><span lang="zh-hk">在 &#8220;<a href="http://onhacks.org/lang/zh-hk/2009/07/12/%e8%aa%b0%e5%9c%a8%e5%85%a5%e4%be%b5%e6%88%91%e7%9a%84%e7%b3%bb%e7%b5%b1" target="_blank">誰在入侵我的系統?</a>&#8220;, 我提到過用 Nmap 的服務分析來找找有趣的發現。以下為結果：</span></p>
<p><span lang="zh-hk">這是沒有用到服務分析的 (淨化了)：</span></p>


<blockquote><p># Nmap 4.90RC1 scan initiated Sat Jul 11 00:39:13 2009 as: nmap -oN result.sS.txt -v -sS &#60;XXXXXX&#62;</p>
<p>Host &#60;xxxxxx&#62; (aaa.bbb.ccc.ddd) is up (0.092s latency).<br />
Interesting ports on &#60;xxxxxx&#62; (aaa.bbb.ccc.ddd):<br />
Not shown: 550 filtered ports, 434 closed ports<br />
PORT     STATE SERVICE<br />
21/tcp   open  ftp<br />
22/tcp   open  ssh<br />
25/tcp   open  smtp<br />
110/tcp  open  pop3<br />
139/tcp  open  netbios-ssn<br />
143/tcp  open  imap<br />
443/tcp  open  https<br />
465/tcp  open  smtps<br />
993/tcp  open  imaps<br />
995/tcp  open  pop3s<br />
1023/tcp open  netvenuechat<br />
1025/tcp open  NFS-or-IIS<br />
2103/tcp open  zephyr-clt<br />
2105/tcp open  eklogin<br />
2107/tcp open  unknown<br />
3372/tcp open  msdtc<br />
Read data files from: /usr/local/share/nmap<br />
# Nmap done at Sat Jul 11 00:41:08 2009 &#8212; 1 IP address (1 host up) scanned in 114.52 seconds</p></blockquote>

<p><span lang="zh-hk">以下為用到服務分析的：</span></p>

<blockquote><p># Nmap 4.90RC1 scan initiated Sat Jul 11 00:43:00 2009 as: nmap -oN result.sS.O.sV.txt -O -sV -v -sS &#60;xxxxxx&#62;<br />
Increasing send delay for aaa.bbb.ccc.ddd from 0 to 5 due to 24 out of 79 dropped probes since last increase.<br />
Initiating OS detection (try #1) against &#60;xxxxxx&#62; (aaa.bbb.ccc.ddd)<br />
Retrying OS detection (try #2) against &#60;xxxxxx&#62; (aaa.bbb.ccc.ddd)<br />
Host &#60;xxxxxx&#62; (aaa.bbb.ccc.ddd) is up (0.091s latency).<br />
Interesting ports on &#60;xxxxxx&#62; (aaa.bbb.ccc.ddd):<br />
Not shown: 550 filtered ports, 434 closed ports<br />
PORT     STATE SERVICE       VERSION<br />
21/tcp   open  ftp           <strong>Nepenthes HoneyTrap fake vulnerable ftpd</strong><br />
22/tcp   open  ssh           OpenSSH 5.1p1 Debian 5ubuntu1 (protocol 2.0)<br />
25/tcp   open  smtp<strong>?</strong><br />
110/tcp  open  pop3<strong>?</strong><br />
139/tcp  open  netbios-ssn<strong>?</strong><br />
143/tcp  open  imap<strong>?</strong><br />
443/tcp  open  ssh           OpenSSH 5.1p1 Debian 5ubuntu1 (protocol 2.0)<br />
465/tcp  open  smtps<strong>?</strong><br />
993/tcp  open  imaps<strong>?</strong><br />
995/tcp  open  pop3s<strong>?</strong><br />
1023/tcp open  netvenuechat<strong>?</strong><br />
1025/tcp open  NFS-or-IIS<strong>?</strong><br />
2103/tcp open  zephyr-clt<strong>?</strong><br />
2105/tcp open  eklogin<strong>?</strong><br />
2107/tcp open  unknown<br />
3372/tcp open  msdtc<strong>?</strong><br />
4 services unrecognized despite returning data. If you know the service/version, please submit the following fingerprints at http://www.insecure.org/cgi-bin/servicefp-submit.cgi :</p>
<p>&#8230;<br />
&#8230;</p>
<p>Read data files from: /usr/local/share/nmap<br />
OS and Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .<br />
# Nmap done at Sat Jul 11 00:48:38 2009 &#8212; 1 IP address (1 host up) scanned in 338.94 seconds</p></blockquote>


<p><span lang="zh-hk">Nmap 服務分析會去猜測服務的版本和背後的服務，它對這些半假半真的服務打了個問號，這是因為低互動性蜜罐只是模擬真實服務的一部分，就是說沒有模仿的基本部份會被 Nmap 認為是奇怪的部份，明明就像偏偏不是。若果你見到類似的分析，大概也能相信這是假的，甚至是蜜罐。這當然只是其中的一種方法，你還可以想想其他方法。</span></p>
<p><span lang="zh-hk">當然，這不是針只對 Nepenthes 的方法，他也有效的。下一篇將會講述如何檢測虛擬機、蜜罐以及如何對付不在虛擬機運行的惡意代碼。</span></p>


<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 1547px; width: 1px; height: 1px;">http://onhacks.org/lang/zh-hk/2009/07/12/%e8%aa%b0%e5%9c%a8%e5%85%a5%e4%be%b5%e6%88%91%e7%9a%84%e7%b3%bb%e7%b5%b1</div>
]]></content:encoded>
			<wfw:commentRss>http://onhacks.org/lang/zh-hk/2009/08/13/one-method-to-detect-low-interaction-honeypots/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to examine a bad word filter?</title>
		<link>http://onhacks.org/lang/zh-hk/2009/05/31/how-to-examine-a-bad-word-filter</link>
		<comments>http://onhacks.org/lang/zh-hk/2009/05/31/how-to-examine-a-bad-word-filter#comments</comments>
		<pubDate>Sun, 31 May 2009 00:02:16 +0000</pubDate>
		<dc:creator>.hac</dc:creator>
				<category><![CDATA[Email]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Analysis]]></category>
		<category><![CDATA[Black box]]></category>
		<category><![CDATA[Filtering]]></category>

		<guid isPermaLink="false">http://onhacks.org/?p=352</guid>
		<description><![CDATA[Testing something is always a good practice before learning how to hack something, the methodologies we use in testing sometimes are applicable in hacking. So, I am planning to write some entries related to testing in the coming few months. See if we can have discover a systematic way to hack. Here is the first [...]]]></description>
			<content:encoded><![CDATA[<p>Testing something is always a good practice before learning how to hack something, the methodologies we use in testing sometimes are applicable in hacking. So, I am planning to write some entries related to testing in the coming few months. See if we can have discover a systematic way to hack. Here is the first challenge, it is very simple.</p>
<p><strong>Problem</strong><br />
Network managers always want to or are forced to control the information flowing around a network. Most of the time, filtering is a good way to do the control. Inside this big category, we always like to use block list to prevent information comes in or goes out, to and from the network.</p>
<p><strong>Scenarios</strong><br />
Flora doesn&#8217;t want her daughter wallow in Japan pop star. Flora knows that her daughter always navigate to some sites with domain name ending as &#8216;.jp&#8217;, she is looking for a tool that can control what kinds of websites their PC can reach.</p>
<p>IT administrator in PC middle school discovered that their mail system started receiving porn advertisement and students are trying to share these links through the mail system, they are planning to have a filter that can block all such mail flows.</p>
<p>Justin loves blogging so much, he is writing them weekly. He loves to collect and read feedbacks from the audiences. However, he hates those spammer pasting unrelated advertisement on his posts. He want to figure out a way to stop them appearing from other audiences.</p>
<p><strong>Solution</strong><br />
The trivial filtering solution to help these people out is bad word filtering. The basic idea is the same as general block list, users can specify the tokens they want to look for when deciding to block the information. In general, there are at least two different definitions to distinguish whether we found the bad word or not. Given an input message M,</p>
<ol>
<li>Split the message M into a sequence of words Ws, we found a bad word bW is in the message only if Ws contains bW.</li>
<li>Take the message M as an input stream, we found a bad word bW when there is a list of consecutive characters equals bW.</li>
</ol>
<p>Both definition has there own advantages and disadvantages, but we will keep this discussion later since the current topic is how to test the filter. Let&#8217;s say we pick the first definition for our filter, then what should we test? (Take some time to think about scenarios before continue reading)</p>
<p><strong>Functional Test</strong><br />
According the input of this filter (input message M), we can design few functional test cases. Basic scenarios are,</p>
<ul>
<li>empty message [Expected: Accept];</li>
<li>only a word (either good or bad word) [Expected: good - Accept, bad - Reject];</li>
<li>two words (good and bad) with different delimiter [Expected: Depends on how the feature define delimiter];</li>
<li>a list of word and contains (0, 1, 2, all) bad words [Expected: all reject];</li>
<li>a bad word is embedded in a word (eg. assume evil is bad word, message conatins residentevil.com) [Expect: By design, this message will be accepted]</li>
</ul>
<p>Beside these functional test cases, we should to have a lengthy message to check boundary cases of the feature. Assume the longest message we accept is N characters, we need to have message with length N, N+1 and N+2. On the other hand, globalization and localization test may be required, depends on who is your target user.</p>
<p><strong>Security Concern</strong><br />
Then we would ask: is there other way to bypass the filter (eg. message using different encoding)? Is it possible to have code injection or script injection attack? Who can use the feature? Where is the bad word list? Who have rights to touch the list? These are security concerns when testing the feature. Drawing a data flow diagram always help to identify what kind of security issues we may have. However, this post only focus on functional testing a feature. May be next time we can discuss how to design security test cases of a feature.</p>
<p><strong>Conclusion</strong><br />
We have only discussed some elementary skills to design the test plan of a feature. You can consider what kind of input the feature can have, both valid and invalid input. Output is another way to discover new scenarios, output is anything that the feature shown. Since we assumed that this filter only say accept or reject of a message and throw some exceptions (eg. input size exceed), the test cases we found here are almost dominated by what we found with the input. Now, you are able to test your program more systematically!</p>
<p>Have a good weekend!</p>
<p><strong>Practice (Just for fun)</strong><br />
Should you want to have some practice, we can discuss how to test an IP block list filter. Here is a simple definition:</p>
<p><strong>INPUT</strong>: Only allow IPv4 address, one at a time<br />
<strong>IMPLEMENTATION</strong>: An IP block list is stored as a text file in the same folder of the filter, user need to directly modify the text file if he want to Add/Remove/Edit an IP address in the block list. The filter will perform a binary search to see if the input address is on the list. If it is, then it will announce reject, otherwise output accept.<br />
<strong>OUTPUT</strong>: Accept/ Reject the address</p>
]]></content:encoded>
			<wfw:commentRss>http://onhacks.org/lang/zh-hk/2009/05/31/how-to-examine-a-bad-word-filter/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
