<?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>Inliniac &#187; convert</title>
	<atom:link href="http://www.inliniac.net/blog/tag/convert/feed" rel="self" type="application/rss+xml" />
	<link>http://www.inliniac.net/blog</link>
	<description>Everything inline.</description>
	<lastBuildDate>Wed, 11 Jan 2012 19:09:17 +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>Migrating from ModSecurity 1.9.4 to 2.0.4</title>
		<link>http://www.inliniac.net/blog/2007/01/20/migrating-from-modsecurity-194-to-204.html</link>
		<comments>http://www.inliniac.net/blog/2007/01/20/migrating-from-modsecurity-194-to-204.html#comments</comments>
		<pubDate>Sat, 20 Jan 2007 10:34:05 +0000</pubDate>
		<dc:creator>Victor Julien</dc:creator>
				<category><![CDATA[ModSecurity]]></category>
		<category><![CDATA[Sguil]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[rules]]></category>

		<guid isPermaLink="false">http://www.inliniac.net/blog/?p=62</guid>
		<description><![CDATA[ModSecurity 2 has been out for a while now, and although I have played with it some, I never found some time to upgrade my own servers. The upgrading generally went quite smooth, even though ModSecurity 2 changed quite a bit. First of all there are now 5 phases where you can filter. Actually, one [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.modsecurity.org/">ModSecurity</a> 2 has been out for a while now, and although I have played with it some, I never found some time to upgrade my own servers. The upgrading generally went quite smooth, even though ModSecurity 2 changed quite a bit.</p>
<p>First of all there are now 5 phases where you can filter. Actually, one of them only applies to the logging, so you can filter in 4 phases. The phases are headers and body for both request and response traffic. Filtering on specific URIs can be done in phase 1 (request headers), while inspecting a POST payload requires phase 2 (request body).</p>
<p>Next, some shortcuts where removed. In 1.9.4 there was a variable called POST_PAYLOAD, that enabled the user to match against payloads from POST requests easily. Now there is REQUEST_BODY, but since that can be part of non-POST requests as well, you have to use:</p>
<p align="left">
<blockquote><p>SecRule REQUEST_METHOD &#8220;POST&#8221; chain<br />
SecRule REQUEST_BODY &#8220;evil&#8221;</p></blockquote>
<p>instead of:</p>
<p align="left">
<blockquote><p>SecFilterSelective POST_PAYLOAD &#8220;evil&#8221;</p></blockquote>
<p>One other change is visible above already. The keyword to create a rule has been changed from SecFilterSelective to SecRule. Many rules can be converted by just replacing the keyword, but certainly not all. A simple find/replace should not be done without a manual review!</p>
<p>I use a number of custom rules to protect certain parts of my server, so I needed to convert my rules. For most of them it was simply enough to replace SecFilterSelective with SecRule. For a few I had to replace the OUTPUT_STATUS variable with the RESPONSE_STATUS variable, as it is called now.</p>
<p>For one rule however, I had quite some problems to get it running correctly. This was the rule in 1.9.4 syntax:</p>
<p align="left">
<blockquote><p># block wp-login.php<br />
SecFilterSelective REMOTE_ADDR &#8220;!10\.1\.1\.1&#8243; chain<br />
SecFilterSelective REQUEST_URI &#8220;/wp-login.php&#8221; \<br />
log,deny,redirect:http://www.inliniac.net/nologin.html</p></blockquote>
<p>This rule makes sure only 10.1.1.1 can open the login page, everyone else is redirected to a simple html page containing a &#8216;Access Denied &#8211; Logins disabled&#8217; message. I converted it to the following:</p>
<p align="left">
<blockquote>
<p align="left">SecRule REMOTE_ADDR &#8220;!10\.1\.1\.1&#8243; chain<br />
SecRule REQUEST_URI &#8220;/wp-login.php&#8221; \<br />
log,deny,redirect:http://www.inliniac.net/nologin.html</p></blockquote>
<p>Guess what? It didn&#8217;t work. I&#8217;ve spend quite some time trying all kinds of variations of the rule, and finally I found out what the issue is. In 1.9.4 the rule actions, like deny, redirect etc could be in the final rule of a series of chained rules. With 2.0.4 this doesn&#8217;t work correctly. So when I changed the rules to the following, it worked:</p>
<blockquote>
<p align="left"># block wp-login.php<br />
SecRule REMOTE_ADDR &#8220;!10\.1\.1\.1&#8243; \ &#8220;chain,phase:1,log,deny,redirect:http://www.inliniac.net/nologin.html&#8221;<br />
SecRule REQUEST_URI &#8220;/wp-login\.php$&#8221;</p></blockquote>
<p>I haven&#8217;t looked into this further to find out whether this is a bug or a feature.</p>
<p>The last thing that was interesting is the <a href="http://www.inliniac.net/modsec2sguil/">modsec2sguil</a> script. There have been some changes to the alert files. So expect a new version of the script soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.inliniac.net/blog/2007/01/20/migrating-from-modsecurity-194-to-204.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

