网安教育
培养网络安全人才
技术交流、学习咨询
字符串操作
concat
1mysql> select concat('hel','lo','world');
2+----------------------------+
3| concat('hel','lo','world') |
4+----------------------------+
5| helloworld |
6+----------------------------+
71 row in set (0.00 sec)
concat_ws
1mysql> select concat_ws('+', 'hello', 'world');
2+----------------------------------+
3| concat_ws('+', 'hello', 'world') |
4+----------------------------------+
5| hello+world |
6+----------------------------------+
71 row in set (0.00 sec)
substr或substring或mid
1mysql> select substring('www.baidu.com','5',5);
2+----------------------------------+
3| substring('www.baidu.com','5',5) |
4+----------------------------------+
5| baidu |
6+----------------------------------+
71 row in set (0.00 sec)
left
1mysql> select left('flag{this_is_test}', 5);
2+-------------------------------+
3| left('flag{this_is_test}', 5) |
4+-------------------------------+
5| flag{ |
6+-------------------------------+
71 row in set (0.00 sec)
right
1mmysql> select right('flag{this_is_test}', 5);
2+--------------------------------+
3| right('flag{this_is_test}', 5) |
4+--------------------------------+
5| test} |
6+--------------------------------+
71 row in set (0.00 sec)
substring_index
1mysql> select substring_index('flag{111111-222222-333333}','-',1);
2+-----------------------------------------------------+
3| substring_index('flag{111111-222222-333333}','-',1) |
4+-----------------------------------------------------+
5| flag{111111 |
6+-----------------------------------------------------+
71 row in set (0.00 sec)
8
9mysql> select substring_index('flag{111111-222222-333333}','-',-1);
10+------------------------------------------------------+
11| substring_index('flag{111111-222222-333333}','-',-1) |
12+------------------------------------------------------+
13| 333333} |
14+------------------------------------------------------+
151 row in set (0.00 sec)
16
17mysql> select substring_index('flag{111111-222222-333333}','-',-2);
18+------------------------------------------------------+
19| substring_index('flag{111111-222222-333333}','-',-2) |
20+------------------------------------------------------+
21| 222222-333333} |
22+------------------------------------------------------+
231 row in set (0.00 sec)
char_length()/character_length() 和 length()/octet_length()
1mysql> select char_length('你好');
2+-----------------------+
3| char_length('你好') |
4+-----------------------+
5| 2 |
6+-----------------------+
71 row in set (0.00 sec)
8
9mysql> select length('你好');
10+------------------+
11| length('你好') |
12+------------------+
13| 6 |
14+------------------+
151 row in set (0.01 sec)
char_length()/character_length() 计算的是字符的个数,而length()/octet_length() 计算的是字节的长度
将 colname 列的双引号换成单引号
1replace(colname,'"',''');
locate
locate(substr, str)
1mysql> select locate('bar', 'foobar');
2+-------------------------+
3| locate('bar', 'foobar') |
4+-------------------------+
5| 4 |
6+-------------------------+
71 row in set (0.00 sec)
8
9mysql> select locate('xbar', 'foobar');
10+--------------------------+
11| locate('xbar', 'foobar') |
12+--------------------------+
13| 0 |
14+--------------------------+
151 row in set (0.00 sec)
locate(substr, str, pos)/position
1mysql> select locate('bar', 'foobarbar', 5);
2+-------------------------------+
3| locate('bar', 'foobarbar', 5) |
4+-------------------------------+
5| 7 |
6+-------------------------------+
71 row in set (0.00 sec)
instr
1mysql> select instr('123', '12');
2+--------------------+
3| instr('123', '12') |
4+--------------------+
5| 1 |
6+--------------------+
71 row in set (0.00 sec)
8
9mysql> select instr('123', '4');
10+-------------------+
11| instr('123', '4') |
12+-------------------+
13| 0 |
14+-------------------+
151 row in set (0.00 sec)
find_in_set
1mysql> select find_in_set('a','a,b,c,d,e');
2+------------------------------+
3| find_in_set('a','a,b,c,d,e') |
4+------------------------------+
5| 1 |
6+------------------------------+
71 row in set (0.00 sec)
like
常用通配符:
1% : 匹配0个或任意多个字符
2
3_ : 匹配任意一个字符
4
5escape : 转义字符,可匹配%和_
regexp/rlike
常用通配符
1. : 匹配任意单个字符
2
3* : 匹配0个或多个前一个得到的字符
4
5[] : 匹配任意一个[]内的字符,[ab]*可匹配空串、a、b、或者由任意个a和b组成的字符串。
6
7^ : 匹配开头,如^s匹配以s或者S开头的字符串。
8
9$ : 匹配结尾,如s$匹配以s结尾的字符串。
10
11{n} : 匹配前一个字符反复n次。
字符串区分大小写比较
1mysql> select 'A' = binary 'a';
2+------------------+
3| 'A' = binary 'a' |
4+------------------+
5| 0 |
6+------------------+
71 row in set (0.01 sec)
elt
1elt(N ,str1 ,str2 ,str3 ,…)
若 N = 1 ,则返回值为 str1 ,若 N = 2 ,则返回值为 str2 ,以此类推。 若 N 小于 1 或大于参数的数目,则返回值为 NULL 。
1mysql> SELECT ELT(3,'hello','halo','test','world');
2+--------------------------------------+
3| ELT(3,'hello','halo','test','world') |
4+--------------------------------------+
5| test |
6+--------------------------------------+
71 row in set (0.00 sec)
在盲注中的应用
1mysql> select elt(1,0);
2+----------+
3| elt(1,0) |
4+----------+
5| 0 |
6+----------+
71 row in set (0.00 sec)
8
9mysql> select elt(1,1);
10+----------+
11| elt(1,1) |
12+----------+
13| 1 |
14+----------+
151 row in set (0.00 sec)
field
1FIELD(str, str1, str2, str3, ……)
字段str按照字符串str1,str2,str3,str4的顺序返回查询到的结果集。如果表中str字段值不存在于str1,str2,str3,str4中的记录,放在结果集最前面返回。
当然这是正常的用法,还可以理解为这个函数返回的是str 在后面这些字符串中的索引。
1mysql> select field('halo','hello','test','world');
2+--------------------------------------+
3| field('halo','hello','test','world') |
4+--------------------------------------+
5| 0 |
6+--------------------------------------+
71 row in set (0.00 sec)
8
9mysql> select field('halo','hello','test','halo','world');
10+---------------------------------------------+
11| field('halo','hello','test','halo','world') |
12+---------------------------------------------+
13| 3 |
14+---------------------------------------------+
151 row in set (0.00 sec)
在盲注中的应用
1mysql> select field(1,0);
2+------------+
3| field(1,0) |
4+------------+
5| 0 |
6+------------+
71 row in set (0.00 sec)
8
9mysql> select field(1,1);
10+------------+
11| field(1,1) |
12+------------+
13| 1 |
14+------------+
151 row in set (0.00 sec)
这里的第二个参数决定了这条语句的执行结果。
条件表达式
if(condition,result1,result2)
当 condition 结果为真时返回 result1 否则返回 result2,这常常用作我们盲注的开关函数
1mysql> select if(1,1,0);
2+-----------+
3| if(1,1,0) |
4+-----------+
5| 1 |
6+-----------+
71 row in set (0.00 sec)
8
9mysql> select if(0,1,0);
10+-----------+
11| if(0,1,0) |
12+-----------+
13| 0 |
14+-----------+
151 row in set (0.00 sec)
基本形式:
1case(…)when…then…else…end
两种变体:
1case expr when val1 then result1 when val2 then result2 else result3 end;
先会判断 expr 的结果 ,再根据该结果是 val1 还是 val2 或者其他,来执行不同的语句。
1case when condition1 then result1 when condition2 result2 else result3 end;
直接根据不同情况进行选择。
比如可以构造这样一条注入语句:
1select * from test where id =-1 union select 1,case when username like 'a%' then 0 else 2222222222222222222 end,3,4 from tdb_admin
子查询
这一块我还没太看明白,先把模板贴下来
模板一
1select ... from ... where col = [any|all](select...);
模板二
1select ....from ... where col [not]in(select...);
模板三
1select row(value1,valu2...) = [any/some](select col1,col2...);
模板四
1select ... from ...where col [not]exists(select...);
模板五
1select ... from (select ...) as name where ...
文: CA01H’S BLOG
文章链接:https://ca0y1h.top/Web_security/basic_learning
战疫期间,开源聚合网络安全基础班、实战班线上全面开启,学网络安全技术、升职加薪……有兴趣的可以加入开源聚合网安大家庭,一起学习、一起成长,考证书求职加分、升级加薪,有兴趣的可以咨询客服小姐姐哦!
加QQ(1271375291)找小姐姐私聊哦
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论