<?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-1842708781054412084</id><updated>2011-11-28T08:00:09.895+08:00</updated><title type='text'>Malseven Blog</title><subtitle type='html'>Anything about computer security...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://malseven.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1842708781054412084/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://malseven.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Michael Lim Choon Hong</name><uri>http://www.blogger.com/profile/17236909243704315119</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>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1842708781054412084.post-6685639004019391435</id><published>2010-03-24T15:52:00.021+08:00</published><updated>2010-03-26T11:13:44.135+08:00</updated><title type='text'>PHPIDS in CodeIgniter by using Hook</title><content type='html'>&lt;div style="text-align: left;"&gt;I have been busy for a while, especially with programming stuffs and some personal things. Recently I look into the XSS filtering in CodeIgniter. There is a quick configuration to protect your application from all XSS attack. It is powerful but you will certainly need to put in some extra logic to suit your own needs, for example if you have rich text input or textarea in your web application that only allows certain characters.&lt;br /&gt;&lt;br /&gt;I found out there is a PHP script which can be used to block malicious inputs (both XSS and SQL Injection typical strings) effectively - &lt;a href="http://www.phpids.org/"&gt;PHPIDS&lt;/a&gt;. I was thinking to integrate it into my CI web application later on. Download the file from the site and extract all the files into a directory in the root directory of your CI web application'directory.&lt;br /&gt;&lt;br /&gt;NOTE: Make sure you add the redirect rule to &lt;span style="font-style: italic; font-weight: bold;"&gt;phpids&lt;/span&gt; in your .htaccess file which can be found in CI's directory.&lt;br /&gt;&lt;br /&gt;The question is -&gt; do I still need to add codes to validate the inputs on each and every of my web forms? In this case, using the Hooks in CI will save up your development time. So I set up a &lt;span style="font-style: italic; font-weight: bold;"&gt;post_controller_constructor&lt;/span&gt; hook in my CI web application.&lt;br /&gt;&lt;br /&gt;First I create a file called PHPIDSHook.php in &lt;span style="font-style: italic; font-weight: bold;"&gt;System-&gt;Application-&gt;Hooks&lt;/span&gt; directory.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;PHPIDSHook.php - Source Code&lt;/span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;require_once (dirname(__FILE__) . '/../../../phpids/lib/IDS/Init.php');&lt;br /&gt;&lt;br /&gt;class PHPIDSHook&lt;br /&gt;{&lt;br /&gt; function run()&lt;br /&gt; {&lt;br /&gt;  $request = array($_GET, =&gt; $_GET, 'POST' =&gt; $_POST);&lt;br /&gt;&lt;br /&gt;  $init = IDS_Init::init(dirname(__FILE__) . '/../../../phpids/lib/IDS/Config/Config.ini.php');&lt;br /&gt;&lt;br /&gt;  $init-&gt;config['General']['base_path'] = '/phpids/lib/IDS/';&lt;br /&gt;  $init-&gt;config['General']['filter_type'] = 'xml';&lt;br /&gt;  $init-&gt;config['Caching']['caching'] = 'none';&lt;br /&gt;&lt;br /&gt;  // Initiate the PHPIDS and fetch the results&lt;br /&gt;  $ids = new IDS_Monitor($request, $init);&lt;br /&gt;  $result = $ids-&gt;run();&lt;br /&gt;&lt;br /&gt;  if (!$result-&gt;isEmpty())&lt;br /&gt;  {&lt;br /&gt;   require_once (dirname(__FILE__) . '/../../../phpids/lib/IDS/Log/File.php');&lt;br /&gt;   require_once (dirname(__FILE__) . '/../../../phpids/lib/IDS/Log/Composite.php');&lt;br /&gt;&lt;br /&gt;   $compositeLog = new IDS_Log_Composite();&lt;br /&gt;   $compositeLog-&gt;addLogger(IDS_Log_File::getInstance($init));&lt;br /&gt;   $compositeLog-&gt;execute($result);&lt;br /&gt;&lt;br /&gt;   echo "WARNING: XSS/SQL Injection attack is detected!";&lt;br /&gt;   exit();&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Next you will need to set your hook setting by modifying &lt;span style="font-weight: bold; font-style: italic;"&gt;hooks.php&lt;/span&gt; which is located in &lt;span style="font-weight: bold; font-style: italic;"&gt;System-&gt;Config-&gt;Hooks&lt;/span&gt;. Add these line of codes into that file:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$hook['post_controller_constructor'] = array(&lt;br /&gt;                             'class'    =&gt; 'PHPIDSHook',&lt;br /&gt;                             'function' =&gt; 'run',&lt;br /&gt;                             'filename' =&gt; 'PHPIDSHook.php',&lt;br /&gt;                             'filepath' =&gt; 'hooks',&lt;br /&gt;                             );&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Finally, go to System-&gt;Config-&gt;Config.php to set&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;$config['enable_hooks'] = TRUE;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You have done it. To verify your CI's hooking is working, put any XSS or SQL injection string in any input field of your web form. You should get a alert box by now.&lt;br /&gt;&lt;br /&gt;Cheers!&lt;br /&gt;Signing off...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1842708781054412084-6685639004019391435?l=malseven.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://malseven.blogspot.com/feeds/6685639004019391435/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://malseven.blogspot.com/2010/03/phpids-in-codeigniter-by-using-hook.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1842708781054412084/posts/default/6685639004019391435'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1842708781054412084/posts/default/6685639004019391435'/><link rel='alternate' type='text/html' href='http://malseven.blogspot.com/2010/03/phpids-in-codeigniter-by-using-hook.html' title='PHPIDS in CodeIgniter by using Hook'/><author><name>Michael Lim Choon Hong</name><uri>http://www.blogger.com/profile/17236909243704315119</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-1842708781054412084.post-7356349383349948142</id><published>2009-10-28T14:55:00.016+08:00</published><updated>2009-10-28T19:13:33.940+08:00</updated><title type='text'>Introduction to PDF Exploits</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_o_qCi04IymE/Sugb8LwiGxI/AAAAAAAAARA/pb67ToIno5w/s1600-h/pdf.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 124px; height: 124px;" src="http://1.bp.blogspot.com/_o_qCi04IymE/Sugb8LwiGxI/AAAAAAAAARA/pb67ToIno5w/s400/pdf.jpg" alt="" id="BLOGGER_PHOTO_ID_5397594874165992210" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Before we look into  PDF Exploits, we should see the basic structure of a typical PDF document. I spent quite some time to really deep into this. Basically the PDF document consists of four important parts which are the header, body, cross-reference tables (XREF tables) and also trailers.&lt;br /&gt;&lt;br /&gt;Header are the placeholder for the document's information. The body consists of stream of objects which are actually forms the visible objects on the PDF document. They are the forms, buttons, etc. on the document. The XREF tables contain an object reference and byte offset in the body stream which provide access to the objects without the need to read the entire file. And, trailer provides the means for locating the XREF table, document root catalog dictionary, and other objects. That's the basic explanation for those elements.&lt;br /&gt;&lt;br /&gt;What are the streams? They are objects which consist of a sequence of bytes. These bytes are the text/binary data like embedded images or any other media objects in the document. The interesting part is they can be compressed or encoded! There are several types of encoding algorithm such as&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;FlateDecode&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;ASCIIHexDecode&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;ASCII85Decode&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;LZWDecode&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;RunLengthDecode&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;CCITTFaxDecode&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;JBIG2Decode&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;DCDTDecode&lt;/span&gt;&lt;br /&gt;, etc.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Those are the filters that the malware writers will use to conceal their payloads inside the innocent PDF. These encoding algorithms also can be combined. Most of the malware writers embed shell codes inside the PDF's stream objects so that they are more difficult to be detected by antivirus.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_o_qCi04IymE/SufyDgJBG5I/AAAAAAAAAQw/bCkBpx9w9gk/s1600-h/ScreenHunter_04+Oct.+28+15.30.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 235px;" src="http://1.bp.blogspot.com/_o_qCi04IymE/SufyDgJBG5I/AAAAAAAAAQw/bCkBpx9w9gk/s400/ScreenHunter_04+Oct.+28+15.30.jpg" alt="" id="BLOGGER_PHOTO_ID_5397548820408114066" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;What we could see is just some raw bytes inside the streams. Flash objects also can be embedded inside the PDF documents.&lt;br /&gt;&lt;br /&gt;So if one day you suddenly receive a PDF, don't simply open it. Scan with antivirus before opening it. Alternatively, you can use &lt;a href="http://www.foxitsoftware.com/pdf/reader/"&gt;Foxit PDF Reader&lt;/a&gt; to view the PDF as most of the PDF exploits are targeting Adobe PDF Reader's users.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1842708781054412084-7356349383349948142?l=malseven.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://malseven.blogspot.com/feeds/7356349383349948142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://malseven.blogspot.com/2009/10/introduction-to-pdf-exploits.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1842708781054412084/posts/default/7356349383349948142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1842708781054412084/posts/default/7356349383349948142'/><link rel='alternate' type='text/html' href='http://malseven.blogspot.com/2009/10/introduction-to-pdf-exploits.html' title='Introduction to PDF Exploits'/><author><name>Michael Lim Choon Hong</name><uri>http://www.blogger.com/profile/17236909243704315119</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://1.bp.blogspot.com/_o_qCi04IymE/Sugb8LwiGxI/AAAAAAAAARA/pb67ToIno5w/s72-c/pdf.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1842708781054412084.post-958577018830267934</id><published>2009-10-27T14:55:00.000+08:00</published><updated>2009-10-27T14:57:26.198+08:00</updated><title type='text'>My PGP Key</title><content type='html'>My new PGP public key is:&lt;br /&gt;&lt;br /&gt;-----BEGIN PGP PUBLIC KEY BLOCK-----&lt;br /&gt;Version: GnuPG v2.0.12 (MingW32)&lt;br /&gt;&lt;br /&gt;mQGiBEql74cRBACAPQRa7j2XpY7tMgYWDOTymkyZlfwkymLBxepsSM3F+PCXVf3A&lt;br /&gt;bVhD0ACCHgs9kwYBzmIm/8fL12BPRYiG4z1Gq/b2fXFnJzl+UTuKDVjyV3rgaEcE&lt;br /&gt;M42698stVC7VwP/ncNHzw3NfIKRsMbP2idwn962mCBu9vj7j8Gs8IjAUxwCg8ImD&lt;br /&gt;frVkfbkmdF1ZAH7n2q4nLf0D/3QfUpufTZRIISul9en5jgYAR//z88HqrhGiMB+6&lt;br /&gt;6N5X/hZ0UqDolgdQ2wR0rXkhmwJLBpw9mTj6jTThquunhPsPvMvwNlKzzpvV+low&lt;br /&gt;Row3sVeg88xRle7xvc89fQZs1rQq/pE0IghDkxdjY9bfPsbcrFaLA8+Ns9d/borp&lt;br /&gt;L8j7A/0X6otgqcdq1W7TW+vQRi+96LgPZA0EVVyj+FXj1KOB9A+K8gkzQx4ovDIe&lt;br /&gt;4Jar17XATgQ63uJeGPL0hiv+8M1atykaldBYU28f22XAE9T+s6ozGjgROtE3QD7Z&lt;br /&gt;M1ZoVI6cC7BV7c0oQAD8CTQSyqjk1CBN+vYZx+C5J8Kx8/rnEbQvTWljaGFlbCBM&lt;br /&gt;aW0gQ2hvb24gSG9uZyA8bGltY2hvb25ob25nQGdtYWlsLmNvbT6IYgQTEQIAIgUC&lt;br /&gt;SqXvhwIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQ/hP28ml1enwTEgCg&lt;br /&gt;smVLqYUx0T8EIqHc17t47nF9WHUAn238MnX062e6wZfUBisf6noYPcV7uQENBEql&lt;br /&gt;74cQBACifHv76a3bM8WJdYAI9Qhl1kxSB3FPkRfkYFDOsp1GsRE0hul5gjf34230&lt;br /&gt;LKCA7DAlcUGLAg5JGFFxySPufd3w2QMNU42+8w2QVjRWmyGyDBnim+6x4ShcfDHF&lt;br /&gt;GWn8JoXjrgAEzHhBUjh9KV3vSxjcnxah3kXyGDzboaw6f8WY6wADBQP/YH2zXkjI&lt;br /&gt;xJ5gCw36NV8PQCuVq7vo+BNf0dLVUEek5d2EKZNuDhNEK17tgwBM1AwIaRP7aG4o&lt;br /&gt;Rhds1NAIy4f5P//UXJpqFIX2eHNgPA6+LOx18Nnne+GnGMCNl0Jl/NQ9z/y8n60j&lt;br /&gt;sxYUvBOpq+3pKCtOpYbbq7mSkyDSErv1iDeISQQYEQIACQUCSqXvhwIbDAAKCRD+&lt;br /&gt;E/byaXV6fJSCAJ4kuMVTHKiUljFC1nVBM0cDFWoMVQCeIb7+6pKdY5DdmvtGY9+K&lt;br /&gt;+rF0UII=&lt;br /&gt;=t6qa&lt;br /&gt;-----END PGP PUBLIC KEY BLOCK-----&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1842708781054412084-958577018830267934?l=malseven.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://malseven.blogspot.com/feeds/958577018830267934/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://malseven.blogspot.com/2009/10/my-pgp-key.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1842708781054412084/posts/default/958577018830267934'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1842708781054412084/posts/default/958577018830267934'/><link rel='alternate' type='text/html' href='http://malseven.blogspot.com/2009/10/my-pgp-key.html' title='My PGP Key'/><author><name>Michael Lim Choon Hong</name><uri>http://www.blogger.com/profile/17236909243704315119</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></feed>
