<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6453178722308719861</id><updated>2011-04-22T10:29:31.456+08:00</updated><category term='spoofing'/><category term='asym key'/><category term='Sam Rohn'/><category term='rectangle cover'/><category term='rail fence'/><category term='hidden msg'/><category term='javascript'/><category term='sym key'/><category term='python'/><category term='trick'/><category term='pc tree'/><category term='ajax'/><category term='clique'/><category term='network sec'/><category term='caesar'/><category term='set cover'/><category term='online judge'/><category term='pil'/><category term='xss'/><category term='webapp sec'/><category term='sniffing'/><category term='crypto'/><category term='stegano'/><title type='text'>csKa blog</title><subtitle type='html'>A boy like acm prog, Web Design, and webapp sec (novice).&lt;br&gt;
Learning PY and JS and learning to be a computer scientist.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-285194454921255083</id><published>2008-06-03T01:51:00.000+08:00</published><updated>2008-06-03T01:52:49.026+08:00</updated><title type='text'>Move to WordPress</title><content type='html'>&lt;p&gt;I was writing blog about interesting security stuff before in blogspot.&lt;/p&gt; &lt;p&gt;However, it seems that WordPress is a more interesting place to writing on&lt;/p&gt; &lt;p&gt;(Mostly because its beautiful themes)&lt;/p&gt; &lt;p&gt;I just start writing there, enjoy and feel free to visit my new blog.&lt;/p&gt; New blog:&lt;br /&gt;http://cskane.wordpress.com/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-285194454921255083?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/285194454921255083/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=285194454921255083' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/285194454921255083'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/285194454921255083'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2008/06/move-to-wordpress.html' title='Move to WordPress'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-5490459571934217272</id><published>2008-05-23T13:38:00.019+08:00</published><updated>2008-05-25T13:31:56.728+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='ajax'/><category scheme='http://www.blogger.com/atom/ns#' term='xss'/><title type='text'>document.write()</title><content type='html'>These days I am working on Ajax, learning how to do simple HTTP request through Ajax.&lt;br /&gt;Accidentally, I found an interesting property that js has: document.write(). Some of you may already know how to use it to do evil thing, but it is really new to me and I would like to share it with you.&lt;br /&gt;&lt;br /&gt;document.write() is a function in js going to write data into the browsing page. The interesting point of this function is that it will overwrite the original HTML file. Let see an example using it with HTTP request.&lt;br /&gt;Let say we have a &lt;span style="font-weight: bold;"&gt;evil.html&lt;/span&gt; containing a piece of code as follow.&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;function fetch() {&lt;br /&gt;var xmlHttp;&lt;br /&gt;  try {&lt;br /&gt;    xmlHttp = new XMLHttpRequest();&lt;br /&gt;} catch (e) {&lt;br /&gt;  try {&lt;br /&gt;    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");&lt;br /&gt;  } catch (e) {&lt;br /&gt;    try {&lt;br /&gt;      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");&lt;br /&gt;    } catch (e) {&lt;br /&gt;      alert("You Win!");&lt;br /&gt;      return false;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;xmlHttp.onreadystatechange = function() {&lt;br /&gt;  if (xmlHttp.readyState == 4) {&lt;br /&gt;    document.write(xmlHttp.responseText);&lt;br /&gt;    document.close();&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;xmlHttp.open("GET", "index.html", true);&lt;br /&gt;xmlHttp.send(null);&lt;br /&gt;return true;&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;body onload="javascript:fetch()"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;The &lt;span&gt;index.html&lt;/span&gt; file that &lt;span&gt;evil.html&lt;/span&gt; want to get is a normal page. Once a user going to browse &lt;span&gt;evil.html&lt;/span&gt;, the script will replace &lt;span&gt;evil.html&lt;/span&gt; as &lt;span&gt;index.html&lt;/span&gt;. The code above is no harm at all. It tried to request the index.html under the same directory. However, it can easily be used to do malicious thing. Consider we add some code before getting the index.html, eg.&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;userInfoRequest = new XMLHttpRequest();&lt;br /&gt;userInfoRequest.onreadystatechange = function() {&lt;br /&gt;if (xmlHttp.readyState == 4) {&lt;br /&gt;  var content = userInfoRequest.responseText;&lt;br /&gt;  /* send the content to somewhere hacker want to store it */&lt;br /&gt;}&lt;br /&gt;}userInfoRequest.open("GET", "user_info.html", true);&lt;br /&gt;userInfoRequest.send(null);&lt;/pre&gt;&lt;/blockquote&gt;You can imagine what's going on with this piece of code. I am going to find a vulnerable site that allow me to demo this malicious code. I will back on this topic soon.&lt;br /&gt;&lt;br /&gt;Should you have any comment or idea or whatever interesting stuff, please feel free to share with me.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-5490459571934217272?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/5490459571934217272/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=5490459571934217272' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/5490459571934217272'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/5490459571934217272'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2008/05/documentwrite.html' title='document.write()'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-8866984603640631136</id><published>2008-01-01T00:16:00.000+08:00</published><updated>2008-01-01T15:28:07.903+08:00</updated><title type='text'>Minimum Cut</title><content type='html'>Minimum cut problem usually refer to &lt;a href="http://en.wikipedia.org/wiki/Minimum_cut"&gt;s-t minimum cut&lt;/a&gt;, which can be solved by using maximum flow algorithm (eg. &lt;a href="http://en.wikipedia.org/wiki/Ford-Fulkerson_algorithm" title="Ford-Fulkerson algorithm"&gt;Ford-Fulkerson&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Edmonds-Karp_algorithm" title="Edmonds-Karp algorithm"&gt;Edmonds-Karp&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Relabel-to-front_algorithm" title="Relabel-to-front algorithm"&gt;relabel-to-front&lt;/a&gt;, ... etc.). The problem discuss in this article is &lt;a href="http://en.wikipedia.org/wiki/Cut_%28graph_theory%29"&gt;general minimum cut problem&lt;/a&gt;. Given an undirected graph &lt;span style="font-style: italic;"&gt;G = (V, E)&lt;/span&gt;, a cut is to split the nodes of the graph into two set S and T. Any edge &lt;span style="font-style: italic;"&gt;(u, v)&lt;/span&gt; in &lt;span style="font-style: italic;"&gt;E&lt;/span&gt; with either &lt;span style="font-style: italic;"&gt;u&lt;/span&gt; in &lt;span style="font-style: italic;"&gt;S&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;v&lt;/span&gt; in &lt;span style="font-style: italic;"&gt;T&lt;/span&gt; or &lt;span style="font-style: italic;"&gt;u&lt;/span&gt; in &lt;span style="font-style: italic;"&gt;T&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;v&lt;/span&gt; in &lt;span style="font-style: italic;"&gt;S&lt;/span&gt; is a cut edge, which is belongs to the cut set. In weighted undirected graph, a cut is minimum if the sum of weight of its set is the smallest among all possible cut set.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Gomory-Hu tree&lt;/span&gt;. This algorithm is used to construct a general graph into a tree, weight of edges of the tree correspond to the weight of the cut set to disconnect adjacent vertices. The idea of this algorithm is very simple. At the beginning, pick two vertices arbitrarily, and compute the minimum cut between them. Then separate the graph into two groups, contract the edges in the cut set into a new edge &lt;span style="font-style: italic;"&gt;e'&lt;/span&gt;, and the weight of &lt;span style="font-style: italic;"&gt;e'&lt;/span&gt; is the weight of the cut set. After that, in each iteration, pick two vertices from the same group, and find the minimum cut between them, then separate the group into two and contract the edges as before. It is obvious that this algorithm only need &lt;span style="font-style: italic;"&gt;O(n)&lt;/span&gt; iterations of computing minimum cut. There are many variations of this algorithm to get a better time complexity, you can google it if you are interested in.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Stoer-Wagner's min-cut algorithm&lt;/span&gt;. This is the algorithm I implemented these days. The algorithm is based on a theorem. Let &lt;span style="font-style: italic;"&gt;s&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;t&lt;/span&gt; be two vertices of graph &lt;span style="font-style: italic;"&gt;G = (V, E)&lt;/span&gt;. Let &lt;span style="font-style: italic;"&gt;G/{s, t}&lt;/span&gt; be the graph obtained by contracting s and t. Then, a minimum cut of &lt;span style="font-style: italic;"&gt;G&lt;/span&gt; can be obtained by taking the smaller of minimum &lt;span style="font-style: italic;"&gt;s-t&lt;/span&gt; cut and minimum cut of &lt;span style="font-style: italic;"&gt;G/{s, t}&lt;/span&gt;. By this theorem, Stoer and Wagner comes up an algorithm. In each iteration of the algorithm, get two vertices which have a minimum cut to separate them, then contract these two vertices. This algorithm follows the theorem stated above. If the minimum cut is not current &lt;span style="font-style: italic;"&gt;s-t&lt;/span&gt; cut, then it should be in the graph &lt;span style="font-style: italic;"&gt;G/{s, t}&lt;/span&gt;. The following is the pseudo code of this algorithm.&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;MinCutPhase(G, w, a):&lt;/span&gt;&lt;br /&gt; A &lt;- {a}&lt;br /&gt; while (A != V)&lt;br /&gt;  x &lt;- Most Tightly Connected Vertex&lt;br /&gt;  if (|A| == |V| - 2)&lt;br /&gt;   s &lt;- x&lt;br /&gt;  if (|A| == |V| - 1)&lt;br /&gt;   t &lt;- x&lt;br /&gt;   CurrentCut &lt;- (A, complement of A)&lt;br /&gt;  add x to A&lt;br /&gt; Contract(s, t)&lt;br /&gt; return CurrentCut&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;MinCut (G, w, a):&lt;/span&gt;&lt;br /&gt; while (|V| &gt; 1)&lt;br /&gt;  CurrentCut &lt;- MinCutPhase(G, w, a)&lt;br /&gt;  if (w(CurrentCut) &lt; w(MinimumCut))&lt;br /&gt;   MinimumCut &lt;- CurrentCut&lt;/span&gt;&lt;/pre&gt;&lt;/blockquote&gt;In the pseudo code above, the definition of &lt;span style="font-style: italic;"&gt;most tightly connected vertex x&lt;/span&gt; is:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;x&lt;/span&gt; not in &lt;span style="font-style: italic;"&gt;A&lt;/span&gt; s.t.&lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;w(A, x)&lt;/span&gt; = max { &lt;span style="font-style: italic;"&gt;w(A, y) &lt;/span&gt;| &lt;span style="font-style: italic;"&gt;y&lt;/span&gt; not in &lt;span style="font-style: italic;"&gt;A&lt;/span&gt; }&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;The only thing that we need to care is the correctness of the MinCutPhase function, and it can be proved by induction. This algorithm also need &lt;span style="font-style: italic;"&gt;O(n)&lt;/span&gt; iterations to compute MinCutPhase(). If priority queue is used for getting the most tightly connected vertex in each iteration in MinCutPhase, in total it needs &lt;span style="font-style: italic;"&gt;O(nlogn)&lt;/span&gt; time. For updating the weights of all the edges from the selected vertex to any vertices not in A, in overall it takes &lt;span style="font-style: italic;"&gt;O(m)&lt;/span&gt; time. As a result, this algorithm run in &lt;span style="font-style: italic;"&gt;O(nm + n&lt;sup&gt;2&lt;/sup&gt;logn)&lt;/span&gt; time.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Related Problems&lt;/span&gt;:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=2914"&gt;Minimum Cut&lt;/a&gt; (from &lt;a href="http://acm.pku.edu.cn/"&gt;acm.pku.edu.cn&lt;/a&gt;)&lt;/li&gt;&lt;li&gt;&lt;a href="http://icpcres.ecs.baylor.edu/onlinejudge/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=21&amp;amp;page=show_problem&amp;amp;problem=1930"&gt;Bomb, Divide and Conquer&lt;/a&gt; (from &lt;a href="http://icpcres.ecs.baylor.edu/onlinejudge/"&gt;acm.uva.es&lt;/a&gt;)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Reference&lt;/span&gt;:&lt;br /&gt;&lt;ul&gt;&lt;li&gt; Stoer, M. and Wagner, F. 1997. &lt;span style="font-weight: bold;"&gt;A simple min-cut algorithm&lt;/span&gt;. &lt;i&gt;J. ACM&lt;/i&gt; 44, 4 (Jul. 1997), 585-591. DOI= http://doi.acm.org/10.1145/263867.263872&lt;/li&gt;&lt;li&gt;Anne Loomis, &lt;a href="http://www.cs.dartmouth.edu/%7Eac/Teach/CS105-Winter05/Notes/loomis-scribe.ps"&gt;Min cut&lt;/a&gt;, CS 105 (Winter 2005), &lt;a href="http://www.cs.dartmouth.edu/"&gt;Computer Science, &lt;/a&gt;&lt;a href="http://www.dartmouth.edu/"&gt;Dartmouth College&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-8866984603640631136?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/8866984603640631136/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=8866984603640631136' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/8866984603640631136'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/8866984603640631136'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2008/01/minimum-cut.html' title='Minimum Cut'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-4815669339019093132</id><published>2007-12-19T20:57:00.000+08:00</published><updated>2007-12-19T21:27:09.517+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='stegano'/><category scheme='http://www.blogger.com/atom/ns#' term='pil'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>Answer of yesterday's game</title><content type='html'>Although it is not 24 hours yet, I still want to give the answer and solution to you.&lt;br /&gt;As some of you may know, what I did is to hide the most significant 4-bits/ 3-bits of an image to the least significant bits of each pixel of the photo. It is the reason why the photo did not change much after this modification. The reverse is also very intuitive, I will leave it to you.&lt;br /&gt;&lt;br /&gt;Here is the image hidden in each photo.&lt;br /&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Encode&lt;/td&gt;&lt;td&gt;Decode&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_k39Y3MRj0MA/R2fv412ZJZI/AAAAAAAAAsg/mebkw-tDc-Y/s1600-h/encode_road.bmp"&gt;&lt;img style="cursor: pointer; width: 133px; height: 200px;" src="http://2.bp.blogspot.com/_k39Y3MRj0MA/R2fv412ZJZI/AAAAAAAAAsg/mebkw-tDc-Y/s400/encode_road.bmp" alt="" id="BLOGGER_PHOTO_ID_5145344859101013394" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_k39Y3MRj0MA/R2kXl12ZJaI/AAAAAAAAAso/rJAjwIgNBZ4/s1600-h/decode_road.bmp"&gt;&lt;img style="cursor: pointer; width: 133px; height: 200px;" src="http://4.bp.blogspot.com/_k39Y3MRj0MA/R2kXl12ZJaI/AAAAAAAAAso/rJAjwIgNBZ4/s400/decode_road.bmp" alt="" id="BLOGGER_PHOTO_ID_5145669988125320610" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_k39Y3MRj0MA/R2fsnF2ZJXI/AAAAAAAAAsQ/Sw8v0nK9jss/s1600-h/encode_ball.bmp"&gt;&lt;img style="cursor: pointer; width: 200px; height: 200px;" src="http://3.bp.blogspot.com/_k39Y3MRj0MA/R2fsnF2ZJXI/AAAAAAAAAsQ/Sw8v0nK9jss/s400/encode_ball.bmp" alt="" id="BLOGGER_PHOTO_ID_5145341255623452018" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_k39Y3MRj0MA/R2kX-V2ZJbI/AAAAAAAAAsw/j2u_28hogoU/s1600-h/decode_ball.bmp"&gt;&lt;img style="cursor: pointer; width: 200px; height: 200px;" src="http://2.bp.blogspot.com/_k39Y3MRj0MA/R2kX-V2ZJbI/AAAAAAAAAsw/j2u_28hogoU/s400/decode_ball.bmp" alt="" id="BLOGGER_PHOTO_ID_5145670409032115634" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_k39Y3MRj0MA/R2fuol2ZJYI/AAAAAAAAAsY/4JVtM60dNag/s1600-h/encode_spiral.bmp"&gt;&lt;img style="cursor: pointer; width: 200px; height: 200px;" src="http://1.bp.blogspot.com/_k39Y3MRj0MA/R2fuol2ZJYI/AAAAAAAAAsY/4JVtM60dNag/s400/encode_spiral.bmp" alt="" id="BLOGGER_PHOTO_ID_5145343480416511362" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_k39Y3MRj0MA/R2kYVl2ZJcI/AAAAAAAAAs4/qnEnNSHA4V0/s1600-h/decode_spiral.bmp"&gt;&lt;img style="cursor: pointer; width: 200px; height: 200px;" src="http://3.bp.blogspot.com/_k39Y3MRj0MA/R2kYVl2ZJcI/AAAAAAAAAs4/qnEnNSHA4V0/s400/decode_spiral.bmp" alt="" id="BLOGGER_PHOTO_ID_5145670808464074178" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/tbody&gt;&lt;/table&gt;photos taken by &lt;a href="http://www.flickr.com/photos/nylocations/" title="Link to Sam Rohn - Location Scout's photos"&gt;Sam Rohn - Location Scout&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Here is my &lt;a href="http://appsrv.cse.cuhk.edu.hk/%7Ehkho5/FunGame/stega.py"&gt;source code&lt;/a&gt;, which is written in python. If you want to run this code, you need to have the package &lt;a href="http://www.pythonware.com/products/pil/"&gt;Python Imaging Library (PIL)&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Reference:&lt;/span&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Steganography"&gt;http://en.wikipedia.org/wiki/Steganography&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.pythonware.com/products/pil/"&gt;http://www.pythonware.com/products/pil/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://petitcolas.net/fabien/steganography/"&gt;http://petitcolas.net/fabien/steganography/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://utilitymill.com/utility/Steganography_Encode"&gt;http://utilitymill.com/utility/Steganography_Encode&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-4815669339019093132?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/4815669339019093132/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=4815669339019093132' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/4815669339019093132'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/4815669339019093132'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2007/12/answer-of-yesterdays-game.html' title='Answer of yesterday&apos;s game'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_k39Y3MRj0MA/R2fv412ZJZI/AAAAAAAAAsg/mebkw-tDc-Y/s72-c/encode_road.bmp' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-631974130875384099</id><published>2007-12-17T22:04:00.000+08:00</published><updated>2007-12-19T21:25:52.150+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='stegano'/><category scheme='http://www.blogger.com/atom/ns#' term='hidden msg'/><category scheme='http://www.blogger.com/atom/ns#' term='Sam Rohn'/><title type='text'>Steganography Study</title><content type='html'>I have promised to give a funny game yesterday. However, actually, it is not that easy to make the game. This game does not have a very strict rule, and it is not really a game. This game just want to give an opportunity for me and you to get more familiar with &lt;a style="font-weight: bold;" href="http://en.wikipedia.org/wiki/Steganography"&gt;steganography&lt;/a&gt;. I will provide three photos below, and what you need to do is try to get back the images hidden in these photos. I will give the solutions and the program to fetch the hidden images tomorrow.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_k39Y3MRj0MA/R2fv412ZJZI/AAAAAAAAAsg/mebkw-tDc-Y/s1600-h/encode_road.bmp"&gt;&lt;img style="cursor: pointer;" src="http://2.bp.blogspot.com/_k39Y3MRj0MA/R2fv412ZJZI/AAAAAAAAAsg/mebkw-tDc-Y/s400/encode_road.bmp" alt="" id="BLOGGER_PHOTO_ID_5145344859101013394" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_k39Y3MRj0MA/R2fuol2ZJYI/AAAAAAAAAsY/4JVtM60dNag/s1600-h/encode_spiral.bmp"&gt;&lt;img style="cursor: pointer;" src="http://1.bp.blogspot.com/_k39Y3MRj0MA/R2fuol2ZJYI/AAAAAAAAAsY/4JVtM60dNag/s400/encode_spiral.bmp" alt="" id="BLOGGER_PHOTO_ID_5145343480416511362" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_k39Y3MRj0MA/R2fsnF2ZJXI/AAAAAAAAAsQ/Sw8v0nK9jss/s1600-h/encode_ball.bmp"&gt;&lt;img style="cursor: pointer;" src="http://3.bp.blogspot.com/_k39Y3MRj0MA/R2fsnF2ZJXI/AAAAAAAAAsQ/Sw8v0nK9jss/s400/encode_ball.bmp" alt="" id="BLOGGER_PHOTO_ID_5145341255623452018" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;photos taken by &lt;a href="http://www.flickr.com/photos/nylocations/" title="Link to Sam Rohn - Location Scout's photos"&gt;Sam Rohn - Location Scout&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Hint: 4-bit/ 3-bit pixels of the hidden image is inside the given photos.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-631974130875384099?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/631974130875384099/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=631974130875384099' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/631974130875384099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/631974130875384099'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2007/12/entry-for-game.html' title='Steganography Study'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_k39Y3MRj0MA/R2fv412ZJZI/AAAAAAAAAsg/mebkw-tDc-Y/s72-c/encode_road.bmp' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-3626540789338032941</id><published>2007-12-16T21:54:00.000+08:00</published><updated>2007-12-16T23:36:31.185+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='stegano'/><category scheme='http://www.blogger.com/atom/ns#' term='asym key'/><category scheme='http://www.blogger.com/atom/ns#' term='network sec'/><category scheme='http://www.blogger.com/atom/ns#' term='crypto'/><category scheme='http://www.blogger.com/atom/ns#' term='sym key'/><category scheme='http://www.blogger.com/atom/ns#' term='rail fence'/><category scheme='http://www.blogger.com/atom/ns#' term='caesar'/><title type='text'>Cryptographic Techniques</title><content type='html'>Today, I would like to discuss some technical terms which are related to cryptography. Cryptography is the art of achieving security by encoding messages to make them non-readable. In general, we say that a message need to be encode is called plain text, while the encoded message is called cipher text. There are two primary ways to encode a plain text message, &lt;span style="font-weight: bold;"&gt;Substitution&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;Transposition.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The earliest substitution scheme is called &lt;a style="font-weight: bold;" href="http://en.wikipedia.org/wiki/Caesar_cipher"&gt;Caesar Cipher&lt;/a&gt;, proposed by Julius Caesar. This encryption algorithm is to replace each alphabet in the message with the alphabet three places down the line. (ie. A replaced by D, B replaced by E, ... Z replaced by C).&lt;br /&gt;For further information about substitution techniques, please visit &lt;a href="http://en.wikipedia.org/wiki/Substitution_cipher"&gt;Substitution cipher&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Rail Fence Technique&lt;/span&gt; is an example of transposition. This algorithm first write down the plain text message as a sequence of diagonals, then read the plain text written as a sequence of rows. eg. Original plain text message: what the hell you are doing&lt;br /&gt;Ｗ　Ａ　Ｔ　Ｅ　Ｅ　Ｌ　Ｏ　Ａ　Ｅ　Ｏ　Ｎ&lt;br /&gt;　Ｈ　Ｔ　Ｈ　Ｈ　Ｌ　Ｙ　Ｕ　Ｒ　Ｄ　Ｉ　Ｇ&lt;br /&gt;and the result cipher text is "&lt;span style="font-weight: bold;"&gt;wateeloaeonhthhlyurdig&lt;/span&gt;". Other transposition technique is quite similar to Rail Fence Technique, here is more examples of &lt;a href="http://en.wikipedia.org/wiki/Transposition_cipher"&gt;Transposition cipher&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Every encryption and decryption process has two aspects, the algorithm and the key used for encryption and decryption. There are two cryptographic mechanisms, depending on what keys are used. Symmetric Key Cryptography, is the mechanisms that using the same key for both encryption and decryption. In opposite, the mechanisms use different keys for encryption and decryption is called Asymmetric Key Cryptography.&lt;br /&gt;&lt;br /&gt;In &lt;span style="font-weight: bold;"&gt;symmetric key cryptography&lt;/span&gt;, the problem is key distribution. Since the key is to decrypt the message in the receiver side, how can the key distributed securely to receiver? Whitefield Diffie and Martin Hellman developed an amazing solution for key distribution problem in 1976. The solution is called &lt;a style="font-weight: bold;" href="http://en.wikipedia.org/wiki/Diffie-Hellman"&gt;Diffie-Hellman key exchange algorithm&lt;/a&gt;. The algorithm is very easy to understand, here is how it works. First, if &lt;span style="font-style: italic;"&gt;A&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;B&lt;/span&gt; want to exchange message, they first come up with two large prime numbers, n and g. These two numbers need not be kept secret. Then &lt;span style="font-style: italic;"&gt;A&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;B&lt;/span&gt; choose two large random number &lt;span style="font-style: italic;"&gt;x&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;y&lt;/span&gt; respectively, then calculate two numbers &lt;span style="font-style: italic;"&gt;v&lt;/span&gt;&lt;sub style="font-style: italic;"&gt;A&lt;/sub&gt;&lt;span style="font-style: italic;"&gt; = g&lt;/span&gt;&lt;sup style="font-style: italic;"&gt;x &lt;/sup&gt;&lt;span style="font-style: italic;"&gt; mod n&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;v&lt;/span&gt;&lt;sub style="font-style: italic;"&gt;B&lt;/sub&gt; = g&lt;sup style="font-style: italic;"&gt;y&lt;/sup&gt;&lt;span style="font-style: italic;"&gt; mod n&lt;/span&gt; respectively. After that, A and B exchange v&lt;sub&gt;A&lt;/sub&gt; and v&lt;sub&gt;B&lt;/sub&gt;. At last, A will get the secret K1 = v&lt;sub&gt;B&lt;/sub&gt;&lt;sup&gt;x&lt;/sup&gt; mod n, B will get the secret K2 = v&lt;sub&gt;A&lt;/sub&gt;&lt;sup&gt;y&lt;/sup&gt; mod n. At last, K1 is equal to K2, and the key has been exchanged. However, this algorithm raises another problem, it is caused by the first step. If the third party, user C, intercept the message and get the value n and g. then C can continue the whole process to get further data exchange between A and B, because C holds the keys to communicate to A and B. However, A and B will never know that their data has been hijacked. This problem is called man-in-the-middle attack.&lt;br /&gt;&lt;br /&gt;In &lt;span style="font-weight: bold;"&gt;asymmetric key cryptography&lt;/span&gt;, the problems mentioned above will not exist. When A try to communicate with others, it can ask the trusted third party T, to get a pair of key, one is called public key, which will be distributed to those who want to send data A. The other is called private key, which is held by A to decrypt the message. The other name of this cryptography mechanism is called &lt;a href="http://en.wikipedia.org/wiki/Public-key_cryptography"&gt;Public-key cryptography&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Another message encoding technique is called &lt;a style="font-weight: bold;" href="http://en.wikipedia.org/wiki/Steganography"&gt;steganography&lt;/a&gt;. This technique is to hide the message that is to be kept secret inside other messages.&lt;br /&gt;&lt;br /&gt;ps. I will provide a fun game tomorrow.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-3626540789338032941?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/3626540789338032941/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=3626540789338032941' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/3626540789338032941'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/3626540789338032941'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2007/12/cryptographic-techniques.html' title='Cryptographic Techniques'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-7319052281581827286</id><published>2007-12-15T23:51:00.000+08:00</published><updated>2007-12-16T23:39:31.193+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sniffing'/><category scheme='http://www.blogger.com/atom/ns#' term='network sec'/><category scheme='http://www.blogger.com/atom/ns#' term='spoofing'/><title type='text'>Cryptography and Network Security</title><content type='html'>I am reading this book "&lt;a href="http://highered.mcgraw-hill.com/sites/0070494835/information_center_view0/"&gt;Cryptography and Network Security&lt;/a&gt;" (Seems Amazon does not have this book, please tell me if you find it in Amazon). Seriously, I want to learn network security, and that's why I resume this blog for making notes when I am reading it.&lt;br /&gt;Hope you enjoy and rise questions or comments if you have any.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Chapter 1: Introduction&lt;/span&gt;&lt;br /&gt;In chapter 1, it describes some basic principles of security, and attacks related to each principle. There are mainly five principles of security, they are confidentiality, authentication, integrity, availability and non-repudiation.&lt;br /&gt;&lt;br /&gt;The principle of &lt;span style="font-weight: bold;"&gt;confidentiality&lt;/span&gt; specifies that only the sender and the intended recipents should be able to access the contents of a  message. Confidentiality gets compromised if an unauthorized person is able to get the message. The simple example is, if user A want to send a message to user B, another user C capture the message without permission or knowledge of A and B. This type of attack is called interception.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Authentication&lt;/span&gt; mechanisms help establish proof of identities. The authentication ensures that the sender of a message is correctly identified. If user C sends a message to B. However, C has posed as user A when he sent this message to B. User B would not know that the message is come from C, but not A. This kind of attack is called fabrication.&lt;br /&gt;&lt;br /&gt;When the contents of a message is changed after the sender sends it, but before it reaches the receiver, then the &lt;span style="font-weight: bold;"&gt;integrity&lt;/span&gt; of this message is lost. For example, user A transfers HKD $100 dollars to user B through the online Banking System. Unfortunately, user C capture the message and edit the content as "Transfer HKD $1000", both user A and B has no way of knowing that the contents were changed during the message was transferring. This attack is called modification.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Non-repudiation&lt;/span&gt; does not allow the sender of a message to refute the claim of not sending that message.&lt;br /&gt;&lt;br /&gt;The principle of &lt;span style="font-weight: bold;"&gt;availability&lt;/span&gt; states that resources should be available to authorized parties at all times. Due to the intentional actions of an unauthorized user C, an authorized user A may not be able to contact a server B, this is an attack called interruption.&lt;br /&gt;&lt;br /&gt;Theoretically, attacks can be divided into two categories, &lt;span style="font-weight: bold;"&gt;passive attack&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;active attack&lt;/span&gt;. passive attack is not easy to detect because attacker does not attempt to perform any modification to the data. Obviously, active attack is the opposite of passive attack, it is based on modification of the original message, and this kind of attack is easy to detect but difficult to prevent. The following two are examples of each attack.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;IP Sniffing&lt;/span&gt; is a passive attack on an ongoing conversation. An attacker can simply observe packets they pass by. There are two ways to prevent attackers from sniffing packets. The first is encode the data before sending it, second is the transmission link itself can be encoded.&lt;br /&gt;&lt;br /&gt;In &lt;span style="font-weight: bold;"&gt;IP Spoofing&lt;/span&gt;, an attacker sends packets with an incorrect source address. When this happens, the receiver has no way to know that the sender is fake, and he send replies back to the forged address, and not to the attacker. However the attacker can intercept the reply to get information he needs for hijacking attacks, or just want to cause the Denial of Service by these messages.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-7319052281581827286?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/7319052281581827286/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=7319052281581827286' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/7319052281581827286'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/7319052281581827286'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2007/12/cryptography-and-network-security.html' title='Cryptography and Network Security'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-1680579919974061691</id><published>2007-09-27T18:54:00.000+08:00</published><updated>2007-09-27T19:05:31.798+08:00</updated><title type='text'>Next Topic: Searching</title><content type='html'>The next topic planning to do is Searching.&lt;br /&gt;There are some basic searching method need to get familiar with.&lt;br /&gt;Breath First Search, Depth First Search&lt;br /&gt;A*, IDA*, Bi-directional BFS&lt;br /&gt;&lt;br /&gt;Progress: (1/11)&lt;br /&gt;DFS &lt;span style="color: rgb(255, 0, 0);"&gt;*DONE*&lt;/span&gt;: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=1011"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=1011&lt;/a&gt;&lt;br /&gt;BFS: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=1324"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=1324&lt;/a&gt;&lt;br /&gt;BFS: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=2044"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=2044&lt;/a&gt;&lt;br /&gt;BFS: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=2286"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=2286&lt;/a&gt;&lt;br /&gt;IDA*: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=1945"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=1945&lt;/a&gt;&lt;br /&gt;A*: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=2449"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=2449&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Reference: &lt;/span&gt;&lt;a href="http://acm.pku.edu.cn/JudgeOnline/showcontest?contest_id=1144"&gt;http://acm.pku.edu.cn/JudgeOnline/showcontest?contest_id=1144&lt;/a&gt;&lt;br /&gt;DFS + prune: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=1190"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=1190&lt;/a&gt;&lt;br /&gt;Search: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=1084"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=1084&lt;/a&gt;&lt;br /&gt;DFS: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=2989"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=2989&lt;/a&gt;&lt;br /&gt;Search: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=1167"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=1167&lt;/a&gt;&lt;br /&gt;Search: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=1069"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=1069&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-1680579919974061691?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/1680579919974061691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=1680579919974061691' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/1680579919974061691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/1680579919974061691'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2007/09/next-topic-searching.html' title='Next Topic: Searching'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-6640323095043611593</id><published>2007-09-22T19:34:00.000+08:00</published><updated>2007-09-24T21:26:24.488+08:00</updated><title type='text'>New ACM Season</title><content type='html'>The new ACM Season has been started.&lt;br /&gt;This is my last time to join this competition, I am trying to forget everything and focus on ACM this semester.&lt;br /&gt;Guys, pray for me. I want to go World Final, once only, but not more.&lt;br /&gt;&lt;br /&gt;Here is the list I am planning to finish it this month (still have many other problems need to solve next month).&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Progress (11/18)&lt;/span&gt;&lt;br /&gt;Euler graph &lt;span style="color: rgb(255, 0, 0);"&gt;*DONE*&lt;/span&gt;: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=2337"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=2337&lt;/a&gt;&lt;br /&gt;Cut Edge: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=3177"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=3177&lt;/a&gt;&lt;br /&gt;2-connected Component &lt;span style="color: rgb(255, 0, 0);"&gt;*DONE*&lt;/span&gt;: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=2942"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=2942&lt;/a&gt;&lt;br /&gt;Min degree bounded ST: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=1639"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=1639&lt;/a&gt;&lt;br /&gt;Min Ratio ST &lt;span style="color: rgb(255, 0, 0);"&gt;*DONE*&lt;/span&gt;: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=2728"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=2728&lt;/a&gt;&lt;br /&gt;SP &lt;span style="color: rgb(255, 0, 0);"&gt;*DONE*&lt;/span&gt;: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=3013"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=3013&lt;/a&gt;&lt;br /&gt;Difference Constraint &lt;span style="color: rgb(255, 0, 0);"&gt;*DONE*&lt;/span&gt;: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=1275"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=1275&lt;/a&gt;&lt;br /&gt;Bellman-Ford &lt;span style="color: rgb(255, 0, 0);"&gt;*DONE*&lt;/span&gt;: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=1252"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=1252&lt;/a&gt;&lt;br /&gt;Network Flow &lt;span style="color: rgb(255, 0, 0);"&gt;*DONE*&lt;/span&gt;: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=1459"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=1459&lt;/a&gt;&lt;br /&gt;Network Flow: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=2391"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=2391&lt;/a&gt;&lt;br /&gt;Bipartite Matching &lt;span style="color: rgb(255, 0, 0);"&gt;*DONE*&lt;/span&gt;: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=1325"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=1325&lt;/a&gt;&lt;br /&gt;Bipartite Matching &lt;span style="color: rgb(255, 0, 0);"&gt;*DONE*&lt;/span&gt;: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=2226"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=2226&lt;/a&gt;&lt;br /&gt;Weighted Matching &lt;span style="color: rgb(255, 0, 0);"&gt;*DONE*&lt;/span&gt;: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=2195"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=2195&lt;/a&gt;&lt;br /&gt;Weighted Matching: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=2516"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=2516&lt;/a&gt;&lt;br /&gt;Least Common Ancester: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=1986"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=1986&lt;/a&gt;&lt;br /&gt;2-SAT &lt;span style="color: rgb(255, 0, 0);"&gt;*DONE*&lt;/span&gt;: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=2723"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=2723&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;    Reference&lt;/span&gt;: &lt;a href="http://home.ustc.edu.cn/%7Ezhuhcheng/ACM/2-SAT.PPT"&gt;http://home.ustc.edu.cn/~zhuhcheng/ACM/2-SAT.PPT&lt;/a&gt;&lt;br /&gt;2-SAT: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=2749"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=2749&lt;/a&gt;&lt;br /&gt;Minimum Spanning Arborescence: &lt;a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=3164"&gt;http://acm.pku.edu.cn/JudgeOnline/problem?id=3164&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;    Reference&lt;/span&gt;: Chu-Liu-Edmonds algorithm&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-6640323095043611593?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/6640323095043611593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=6640323095043611593' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/6640323095043611593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/6640323095043611593'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2007/09/new-acm-season.html' title='New ACM Season'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-3131375927315586266</id><published>2007-05-29T20:56:00.000+08:00</published><updated>2007-05-29T23:46:18.464+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='set cover'/><category scheme='http://www.blogger.com/atom/ns#' term='clique'/><category scheme='http://www.blogger.com/atom/ns#' term='rectangle cover'/><title type='text'>Covering Rectilinear Polygons by Rectangles</title><content type='html'>Covering Rectilinear Polygons by Rectangles is a category of problems, the general definition of the problem: A board &lt;i&gt;B&lt;/i&gt; is a finite set of unit squares lying in the plane whose corners have integer coordinates. A rectangle of &lt;i&gt;B&lt;/i&gt; is a rectangular subset of &lt;i&gt;B&lt;/i&gt;. A rectangle cover of &lt;i&gt;B&lt;/i&gt; is a collection of rectangles whose union equals &lt;i&gt;B&lt;/i&gt;.The rectangles of a cover may overlap, but each of them must be wholly contained in the board.&lt;br /&gt;&lt;br /&gt;This problem obviously is NP-Complete, I am still thinking of the proof. The first idea come up is that it is finding &lt;a href="http://en.wikipedia.org/wiki/Clique_problem"&gt;maximal cliques&lt;/a&gt; on the graph &lt;i&gt;G(B)&lt;/i&gt;, &lt;i&gt;G(B)&lt;/i&gt; is a graph whose nodes represent squares in &lt;i&gt;B&lt;/i&gt;. Two square &lt;i&gt;u&lt;/i&gt;, &lt;i&gt;v&lt;/i&gt; are adjacent in &lt;i&gt;G&lt;/i&gt; if &lt;i&gt;Rec(u, v)&lt;/i&gt; in &lt;i&gt;B&lt;/i&gt;. The other similar NP-complete problem to rectangle covering, is &lt;a href="http://en.wikipedia.org/wiki/Set_cover_problem"&gt;set cover problem&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;There are some specialized problems. For example, the given board &lt;i&gt;B&lt;/i&gt; must be convex and no hole inside the board.&lt;br /&gt;&lt;br /&gt;Since the problem is NP-complete problem, most of the attention is focus on the approximability of the problem. &lt;a href="http://en.wikipedia.org/wiki/Paul_Erd%C5%91s"&gt;Erdos&lt;/a&gt; asked if Theta / Alpha &lt;b&gt;[1]&lt;/b&gt; is bounded, but it still cannot be proved yet.&lt;br /&gt;&lt;br /&gt;This problem is quite interesting and applicable, one of its application is an operation used by microelectronics industry. A layer of an &lt;a href="http://en.wikipedia.org/wiki/Integrated_circuit"&gt;integrated circuit&lt;/a&gt; is to be printed on a photographic plate. The printing is done by flashing rectangles onto the plate and as few rectangles as possible.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;[1] &lt;/span&gt;Theta is the rectangle of &lt;span style="font-style: italic;"&gt;B&lt;/span&gt;; Alpha is anti-rectangle of &lt;span style="font-style: italic;"&gt;B&lt;/span&gt;, ie. a set of squares in B that no two of which are contained in any rectangle.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-3131375927315586266?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/3131375927315586266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=3131375927315586266' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/3131375927315586266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/3131375927315586266'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2007/05/covering-rectilinear-polygons-by.html' title='Covering Rectilinear Polygons by Rectangles'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-6662170100638890329</id><published>2007-05-05T20:30:00.000+08:00</published><updated>2007-05-29T23:43:41.220+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pc tree'/><title type='text'>A report for PC tree</title><content type='html'>The beta version of the PC tree report is finished. The topic is "PC tree and its application". This report first discuss the use of PC tree for testing consecutive-ones property of a 0-1 matrix. Then discuss its further application on interval graph recognition and planarity testing.&lt;br /&gt;&lt;br /&gt;However, I start writing terribly when describing the application. If you don't understand what they are talking about, please feel free to ask me, I will fix it asap, but not today XD&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.cse.cuhk.edu.hk/%7Ehkho5/proj.pdf"&gt;PC tree and its application&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-6662170100638890329?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/6662170100638890329/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=6662170100638890329' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/6662170100638890329'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/6662170100638890329'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2007/05/report-for-pc-tree.html' title='A report for PC tree'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-7411405461082721080</id><published>2007-04-28T22:22:00.000+08:00</published><updated>2007-05-29T23:44:10.508+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='online judge'/><category scheme='http://www.blogger.com/atom/ns#' term='webapp sec'/><title type='text'>Online judge security problem</title><content type='html'>These few days, I am trying to use Python to rewrite the core of a online judging system (I use C to implement it before).&lt;br /&gt;First, let me brief describe what is included in the core system.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Compile program&lt;/li&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;distinguish what programming language the user is using; (basically it only support Pascal, C and C++)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;use the corresponding compiler to compile the source code;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;limit the size of the objective program it can generate;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;report the compilation is success or not.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;li&gt;Judge program&lt;/li&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;run the compiled objective program with specific test input;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;limit its running time, memory used when it is executing;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;restrict its function call (or system call); (more on this later)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;compare its output with the test output;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;or, special judge if necessary.&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;I would like to discuss why we need to restrict its function call. Actually, it is both a security issue and prevent on cheating.&lt;br /&gt;Let's discuss the prevention on cheating first. Obviously, if the user know the judge system architecture, one way to cheat is to open the test output file and print it, then he must get an Accept on the task. Or, if the system has stored other users solution, the cheater may hack in and use the solution as his own, even get a copy.&lt;br /&gt;&lt;br /&gt;The most serious problem is that, the hacker may write a program which is trying to damage the operating system (OS). He may delete files, change the ownership of files, even get copy of some private files, then he can do some further attack. How horrible it is!&lt;br /&gt;&lt;br /&gt;What most commonly use in C is a function ptrace (if I remember correctly, it only available &lt;a href="http://en.wikipedia.org/wiki/*nix"&gt;*nix&lt;/a&gt; system). How it works is as follow.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;ptrace is called in a child process and stating that ptracing on itself;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;then parent process keep ptracing on its child process, for each signal the child process send out, parent process is first capture it before it send the signal away;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;at this point, the parent process is trying to recognize what child is doing by reading this signal, if its child is a bad guy, parent will kill him immediately;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;otherwise, parent will allow the child continue its process.&lt;/li&gt;&lt;/ul&gt;Actually, ptrace itself is also a very useful tool for hacking program. If the system allow ptrace call, hacker can write a program by using ptrace and stop some of your applications in OS and fetch the private information.&lt;br /&gt;&lt;br /&gt;However, I am still trying to figure out how to do the same thing in Python. Actually, I cannot find something in Python which is similar to ptrace.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-7411405461082721080?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/7411405461082721080/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=7411405461082721080' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/7411405461082721080'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/7411405461082721080'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2007/04/online-judge-security-problem.html' title='Online judge security problem'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-6224719687501940627</id><published>2007-04-11T22:55:00.000+08:00</published><updated>2007-05-29T23:44:51.349+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pc tree'/><title type='text'>PC-tree</title><content type='html'>&lt;h2&gt;Definition:&lt;/h2&gt;A circular-arc graph is the intersection graph of a family of arcs of a circle.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Problem definition:&lt;/h2&gt;Given a graph G = (V, E), determine whether the graph is a circular-arc graph.&lt;br /&gt;&lt;br /&gt;PC-tree is a data structure used to solve the above problem, discovered by Hsu and McConnell. PC-tree is an unrooted tree, its previous version is called &lt;a href="http://en.wikipedia.org/wiki/PQ_tree"&gt;PQ-tree&lt;/a&gt; which is discovered by Booth and Lueker in 1976. This article will focus on PC-tree only, because PC-tree is generalization of PQ-tree, which means any problem that can be solved by PQ-tree can reduce to PC-tree problems.&lt;br /&gt;&lt;br /&gt;Each circular-arc graph can be represented by a clique matrix. Consider circular arc its corresponding circular-arc graph and clique matrix as follow:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_k39Y3MRj0MA/RioXngA73nI/AAAAAAAAAA4/hM3coqvk51w/s1600-h/circular_arc.PNG"&gt;&lt;img style="cursor: pointer;" src="http://2.bp.blogspot.com/_k39Y3MRj0MA/RioXngA73nI/AAAAAAAAAA4/hM3coqvk51w/s400/circular_arc.PNG" alt="" id="BLOGGER_PHOTO_ID_5055879499052998258" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;By theorem, a graph is circular-arc iff. its clique matrix must a circular-ones property (proof provide later). Now the problem is focusing on how to check a matrix contains circular one property. PC-tree take the place to solve this problem. Let me introduce what is a PC-tree first.&lt;br /&gt;&lt;br /&gt;PC-tree has two kinds of internal node, P-node and C-node (that's why it is called PC-tree). The children of P-node can be arranged in any order (ie. all permutations). Other than P-node, the children of C-node can only be arranged in the original order or its reverse (ie. if it's leaves is "ABC", another possible ordering is "CBA"). PC-tree is built by considering the rows of clique matrix one by one. The outline of the algorithm is as follow:&lt;br /&gt;&lt;blockquote&gt;for each row in clique matrix {&lt;br /&gt;&lt;li&gt;assign the value to each row symbol;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;find a Terminal Path to separate 0s and 1s;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;align all 1s and 0s to the same side;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;split each node on the path into two nodes, one connect to the leaves with 1s and one connect to 0s;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;delete the edges of the path and replace with a C-node x;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;contract all edges from x to C-node neighbors, and any node has only 2 neighbors.&lt;/li&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;The circular-ones ordering can be discovered from the graph by reading the leaves on PC-tree in clockwise or anti-clockwise. Like the following:&lt;br /&gt;&lt;b&gt;img provide later&lt;/b&gt;&lt;br /&gt;The time complexity of the &lt;i&gt;O(|E|)&lt;/i&gt; (proof provide later).&lt;br /&gt;&lt;br /&gt;Further application is: &lt;i&gt;scheduling jobs, minimum coloring, maximum cliques, planarity test, consecutive-ones&lt;/i&gt;, ...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-6224719687501940627?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/6224719687501940627/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=6224719687501940627' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/6224719687501940627'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/6224719687501940627'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2007/04/pc-tree.html' title='PC-tree'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_k39Y3MRj0MA/RioXngA73nI/AAAAAAAAAA4/hM3coqvk51w/s72-c/circular_arc.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-4905671227669475436</id><published>2007-04-09T21:13:00.000+08:00</published><updated>2007-05-29T23:45:02.270+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='webapp sec'/><title type='text'>Cross-Site Request Forgeries (CSRF/ XSRF)</title><content type='html'>Today, I google with the word "&lt;a href="http://www.google.com/search?client=safari&amp;rls=en&amp;amp;q=XSRF&amp;ie=UTF-8&amp;amp;oe=UTF-8"&gt;XSRF&lt;/a&gt;", some of you may know what it is, and it is not new. However, it is very amazing to me, because I did not think of using HTML code like this.&lt;br /&gt;&lt;br /&gt;If you don't know what it is, let me introduce to you. If not, please state the mistake if any. &lt;a href="http://en.wikipedia.org/wiki/CSRF"&gt;XSRF&lt;/a&gt;, obviously is a webapp attack method. It is not only applied to HTML, but all &lt;a href="http://en.wikipedia.org/wiki/Markup_language"&gt;markup language&lt;/a&gt;.&lt;br /&gt;Let's see an example then you may know what the problem is.&lt;br /&gt;&lt;blockquote&gt;&amp;lt;img src="http://www.bookstore.com/order.php?isbn=817525766-0&amp;amp;quantity=100&amp;submit=yes" height=0 width=0 /&amp;gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Although &lt;i&gt;img&lt;/i&gt; is not including an image, the HTTP request is still send to the server. By setting the height and width of the &lt;i&gt;img&lt;/i&gt; or using CSS style, the broken image can be hidden, the user even don't know such request has been sent. XSRF can force the user to updateing their profile, post new message or thread unknowingly. Sounds like not so dangerous, however it is more worse than that.&lt;br /&gt;&lt;h2&gt;Difference between XSS and XSRF&lt;/h2&gt;Cross-Site Scripting (&lt;a href="http://en.wikipedia.org/wiki/XSS"&gt;XSS&lt;/a&gt;) and XSRF are quite similar, isn't it? Actually they are not the same. XSS is try to either abuse client-side active scripting holes, or send privileged information to unknown site by inserting active code in HTML document.&lt;br /&gt;&lt;br /&gt;XSRF is not rely on client-side active scripting, it try to take unwanted, unapproved actions on a site where the user has some authority.&lt;br /&gt;&lt;br /&gt;It is difficult to filter content, because the XSRF attack may look like this:&lt;br /&gt;&lt;blockquote&gt;&amp;lt;img src="http://itisnotanattack.com/logo.jpg" height=0 width=0 /&amp;gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;When your client requests &lt;i&gt;logo.jpg&lt;/i&gt;, the file does not exist, but &lt;i&gt;itisnotanattack.com&lt;/i&gt; server will redirect you to somewhere it like to &lt;b&gt;show&lt;/b&gt; you.&lt;br /&gt;&lt;br /&gt;XSRF can also be used to attack servers behind firewalls. It is not just public webapps that are at risk.&lt;br /&gt;&lt;blockquote&gt;&amp;lt;img src="http://intranet/admin/purgeDB?confirm=yes" /&amp;gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;If the attackers knows enough to make a URL and can get the admin open this file, then everything is done. Now you know how funny (dangerous) it is.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-4905671227669475436?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/4905671227669475436/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=4905671227669475436' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/4905671227669475436'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/4905671227669475436'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2007/04/cross-site-request-forgeries-csrf-xsrf.html' title='Cross-Site Request Forgeries (CSRF/ XSRF)'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-4396466908219431618</id><published>2007-04-06T20:00:00.000+08:00</published><updated>2007-05-29T23:45:15.632+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='webapp sec'/><category scheme='http://www.blogger.com/atom/ns#' term='trick'/><title type='text'>Hide disclaimer in CSE personal hp</title><content type='html'>The day before yesterday, Billy try to hide the disclaimer in his personal homepage in CSE.&lt;br /&gt;Tom suggested that the html file without "&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;" can avoid the disclaimer include in the file.&lt;br /&gt;However, clearly, it is not satisfy the rule of &lt;a href="http://validator.w3.org/"&gt;W3C&lt;/a&gt;.&lt;br /&gt;The file is obviously not complete.&lt;br /&gt;&lt;br /&gt;Actually, I still cannot get the idea how it write the disclaimer in my file.&lt;br /&gt;I think the page has been pass to some program to add the disclaimmer before including in response packet.&lt;br /&gt;What it added to my file is as follow:&lt;br /&gt;&lt;blockquote&gt;&amp;lt;link ... href="/css/disclaimer.css" ... &amp;gt;&lt;br /&gt;       &amp;lt;script ... src="/js/disclaimer.js" ... &amp;gt;&amp;lt;/script&amp;gt;&lt;/blockquote&gt;&lt;br /&gt;and&lt;br /&gt;&lt;blockquote&gt;        &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;       &amp;lt;div id="cse-disclaimer"&amp;gt;&lt;br /&gt;...&lt;br /&gt;       &amp;lt;/div&amp;gt;&amp;lt;!-- #cse-disclaimer --&amp;gt;&lt;/blockquote&gt;&lt;br /&gt;The .js file has a function disclaimer(), it may called at the end of the page (before &amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;), this function will enable visibility of the disclaimer block.&lt;br /&gt;&lt;br /&gt;What I did to block the disclaimer again is very simple, create a .js file, content is similar to disclaimer.js.&lt;br /&gt;When the body is being loaded, call the block function in my .js file, and it will disable the visibility of the disclaimer.&lt;br /&gt;Is it easy? Yes, it is. However I spend whole day to test it, because I am not familar with JS.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-4396466908219431618?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/4396466908219431618/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=4396466908219431618' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/4396466908219431618'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/4396466908219431618'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2007/04/blocking-disclaimer-in-cse-personal-hp.html' title='Hide disclaimer in CSE personal hp'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6453178722308719861.post-255985568383742218</id><published>2007-04-06T18:06:00.000+08:00</published><updated>2007-04-06T20:28:43.459+08:00</updated><title type='text'>Start this blog for what?</title><content type='html'>I am thinking these few day, if I should create this for making note on the interesting thing related to prog or security.&lt;br /&gt;(I expect more on security. it is very new and interesting to me)&lt;br /&gt;&lt;br /&gt;Hope I can post something everyday. :D&lt;br /&gt;Please feel free to share your opinion&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6453178722308719861-255985568383742218?l=cskane.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cskane.blogspot.com/feeds/255985568383742218/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6453178722308719861&amp;postID=255985568383742218' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/255985568383742218'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6453178722308719861/posts/default/255985568383742218'/><link rel='alternate' type='text/html' href='http://cskane.blogspot.com/2007/04/start-this-blog-for-what.html' title='Start this blog for what?'/><author><name>Kane</name><uri>http://www.blogger.com/profile/05553019518962086936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry></feed>
