<?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>小棗棧 &#187; modsecurity</title>
	<atom:link href="http://www.joe-ho.com/tag/modsecurity/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joe-ho.com</link>
	<description>What I called myself is small potato. 一個士麼普爹圖既生活點滴</description>
	<lastBuildDate>Wed, 08 Feb 2012 01:47:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Slitaz Apache 與 mod_security</title>
		<link>http://www.joe-ho.com/slitaz-apache-%e8%88%87-mod_security/</link>
		<comments>http://www.joe-ho.com/slitaz-apache-%e8%88%87-mod_security/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 16:27:54 +0000</pubDate>
		<dc:creator>Joe Ho</dc:creator>
				<category><![CDATA[電腦]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[modsecurity]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.joe-ho.com/?p=1284</guid>
		<description><![CDATA[<p>近日對 Slitaz 既興趣越來越高, 但係原來佢都係有唔完美缺點既. 佢既優點當然係容量小, 電腦硬件要求低. 正正因為容量小, 軟件包支援亦相對少, 而且就算有支援亦並非代表可以有功能上既擴展. 例如, 沒有 mod_security 軟件包提供, 要各位努力 compile. 雖然 modsecurity 有完善既說明文件, 但在 Slitaz 身上卻變成有點困難. 下文會先列出必須既軟件, 最後才將安裝步驟簡單列出.</p> <p>在 Slitaz, 先安裝套件: slitaz-toolchain, gcc, apache-dev, apr-dev, lua-dev, curl-dev, apr-util-dev, pcre-dev, libxml2-dev, expat-dev</p> <p>用 modsecurity  網站所提及既步驟便可: 1. 先解壓 source; 2. cd ./apache2; 3. 執行 ./configure; 4. 執行 make; 5. 執行 make test; [...]]]></description>
			<content:encoded><![CDATA[<p>近日對 Slitaz 既興趣越來越高, 但係原來佢都係有唔完美缺點既. 佢既優點當然係容量小, 電腦硬件要求低. 正正因為容量小, 軟件包支援亦相對少, 而且就算有支援亦並非代表可以有功能上既擴展. 例如, 沒有 mod_security 軟件包提供, 要各位努力 compile. 雖然 modsecurity 有完善既說明文件, 但在 Slitaz 身上卻變成有點困難. 下文會先列出必須既軟件, 最後才將安裝步驟簡單列出.</p>
<p>在 Slitaz, 先安裝套件:<br />
slitaz-toolchain, gcc, apache-dev, apr-dev, lua-dev, curl-dev, apr-util-dev, pcre-dev, libxml2-dev, expat-dev</p>
<p>用 modsecurity  網站所提及既步驟便可:<br />
1. 先解壓 source;<br />
2. cd ./apache2;<br />
3. 執行 ./configure;<br />
4. 執行 make;<br />
5. 執行 make test;<br />
6. mlogc 因為還未找到方法安裝, 所以在此省略;<br />
7. 執行 make install 安裝 apache module 至/usr/share/apache/modules/mod_security2.so<br />
8. 修改 apache 設定檔, 在 LoadModule 段最後一行加入 LoadModule security2_module share/apache/modules/mod_security2.so;<br />
9. 重啟 apache</p>
<p>下一步便是加入 mod_security rules set 及進一步針對自己需要修改 rules set. 因為小弟仲未完全掌握, 所以就請各位多多交流.</p>
<p><span style="text-decoration: underline;">English Version:</span><br />
mini-Howto Slitaz apache with mod_security</p>
<p>I know it is quite straight forward, but it&#8217;s a good way for my reference.</p>
<ol>
<li>install Slitaz</li>
<li>install apache, you may got a ssl cert. problem by default, please read my other article or search in web</li>
<li>install the following packages:<br />
slitaz-toolchain, gcc, apache-dev, apr-dev, lua-dev, curl-dev, apr-util-dev, pcre-dev, libxml2-dev, expat-dev</li>
<li>download the mod_security source from the official web site &#8211; http://www.modsecurity.org</li>
<li>unzip the tarball</li>
<li>cd to ./apache2</li>
<li>make</li>
<li>make test</li>
<li>mlogc is optional, so ignored it</li>
<li>make install</li>
<li>copy mod_security module to /usr/share/apache/modules/mod_security2.so</li>
<li>edit apache config, in the last line of LoadModule, add an extra entry:<br />
LoadModule security2_module share/apache/modules/mod_security2.so;</li>
<li>save the changes in config file</li>
<li>restart apache</li>
</ol>
<p>The final stage will be applied the rule sets and fine tune it. As my skill is also limited on this, it&#8217;s welcome you all to share with me.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">/usr/share/apache/modules/mod_security2.so</div>
]]></content:encoded>
			<wfw:commentRss>http://www.joe-ho.com/slitaz-apache-%e8%88%87-mod_security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ModSecurity2 Configuration</title>
		<link>http://www.joe-ho.com/modsecurity2-configuration/</link>
		<comments>http://www.joe-ho.com/modsecurity2-configuration/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 16:31:22 +0000</pubDate>
		<dc:creator>Joe Ho</dc:creator>
				<category><![CDATA[電腦]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[modsecurity]]></category>

		<guid isPermaLink="false">http://www.joe-ho.com/?p=863</guid>
		<description><![CDATA[<p>Question2: I am hosting my own Blog, and every time I add a post I keep getting a not implemented error. Why is this happening? And how can I disable it for my posts? (I.e: disabling ModSecurity2 for a specific file).</p> <p>Answer2: This is happening because ModSecurity thinks that you are trying to inject some code to [...]]]></description>
			<content:encoded><![CDATA[<p>Question2: I am hosting my own Blog, and every time I add a post I keep getting a not implemented error. Why is this happening? And how can I disable it for my posts? (I.e: disabling ModSecurity2 for a specific file).</p>
<p>Answer2: This is happening because ModSecurity thinks that you are trying to inject some code to the PHP files of your Blog based on the pretested rules BreachSecurity provides with the ModSecurity2 package. It is called &#8220;False Positives&#8221;, because it is a false alert (you are only posting a new post) and it&#8217;s positive because it matched one of the rules that ModSecurity2 depends on.</p>
<p>Disabling it shall need some work from your side, because as I told in the beginning, ModSecurity2 does not work like ModSecurity Version1, and disabling it in version 1 was much easier, but here in ModSecurity2 it is really much more powerful. First you need to monitor your Apache error log files. So let us start the following:</p>
<p># tail -f /var/log/httpd/error_log</p>
<p>I shall assume that we have the Blog parked on the domain www.example.com. Open your favorite browser and goto:</p>
<p>http://www.example.com/wp-admin/post-new.php</p>
<p>And write the same post you got an error from. Now you shall get the same error, right? Great, now lets go and check what our error log has reported us. We shall see something like this:</p>
<p>[Mon Sep 22 11:01:12 2008] [error] [client 211.158.21.152] ModSecurity: Access denied with code 501 (phase 2). Pattern match &#8220;^(?:ht|f)tp:/&#8221; at ARGS:referredby. [file "/etc/httpd/conf.d/modsecurity2/optional_rules/modsecurity_crs_42_tight_security.conf"] [line "32"] [id "950117"] [msg "Remote File Inclusion Attack"] [severity "CRITICAL"] [hostname "www.example.com"] [uri "/wp-admin/post-new.php"] [unique_id "dGP7GXAAA8AAAPQC4AAEAAFZ"]</p>
<p>Hey, wait a minute, What are these????</p>
<p>This is actually a single line of error. Let me explain the important parts of it, and what we shall need to disable this alert from happening in the future. I am interested now in:</p>
<p>1st: 211.158.21.152 this is the IP of the host who because of him the alert was raised.<br />
2nd: modsecurity_crs_42_tight_security.conf is the file that includes the rule.<br />
3rd: ModSecurity classified this as a Remote File Inclusion Attack.<br />
4th: www.example.com is the domain where the problem came from (in case you are hosting more domains on the same server).<br />
5th: The file that made the alert is /wp-admin/post-new.php.<br />
Finally: id, This is the important thing for us here, because we shall be using this number which is actually a rule number from the ModSecurity rule set.</p>
<p>Great we have the id let us disable this error from happening again. Goto Apache&#8217;s main config file and edit it:</p>
<p># vim /etc/httpd/conf/httpd.conf</p>
<p>Add the following lines to disable the error above:</p>
<p>&lt;LocationMatch &#8220;/wp-admin/post-new.php&#8221;&gt;<br />
SecRuleRemoveById 950117<br />
&lt;/LocationMatch&gt;</p>
<p>Now save, close the file and reload Apache.</p>
<p>Try making the same post again. If everything went well then great, if you get another error? then go back to the log files and get the id and add it to the SecRuleRemoveById we wrote above.</p>
<p>Notes:<br />
1- If you are hosting more than one domain on the server (VirtualHosting), then it is better to add the lines above to the configuration file of that domain.</p>
<p>2- You can also solve this error by witting your own rules, but it is not quite easy and you need some knowledge in writing Regex codes, and to be more precise you need to know how to write Perl Compatible Regular Expression (PCRE), which ModSecurity rules are written with.</p>
<p>If you are looking for further documentation, then the main site is always a good place to look in:</p>
<p>http://www.modsecurity.org/documentation/modsecurity-apache/2.5.6/html-multipage/installation.html</p>
<p>So that&#8217;s it <img src='http://www.joe-ho.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Quoted from:<br />
<a href="http://www.binary-zone.com/Projects/modsecurity2-eng.pdf">http://www.binary-zone.com/Projects/modsecurity2-eng.pdf</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joe-ho.com/modsecurity2-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

