web安全之数据库相关知识

web安全


作者:胖胖的小宇
来源:CSDN
原文:https://blog.csdn.net/m0_38055579/article/details/83545848
版权声明:本文为博主原创文章,转载请附上博文链接!

MySQL注入常用函数

system_user() 系统用户名
concat() 没有分隔符地连接字符串
user() 用户名
concat_ws() 含有分隔符地链接字符串
current_user() 当前用户名
group_concat() 连接一个组的所有字符串,并以逗号分割一条数据
session_user() 链接数据库用户名
load_file() 读取本地文件
database() 数据库名
into outfile 写文件
version() 数据库版本
ascii() 字符串的ASCII代码值
@@datadir 数据库路径
ord() 返回字符串第一个字符发ASCII值
@@basedir 数据库安装路径
mid() 返回一个字符串的一部分
@@version_compile_os 操作系统
substr() 返回一个字符串的一部分
count() 返回执行结果数量
length() 返回字符串的长度
left() 返回字符串最左面的几个字符
sleep() 让此语句运行N秒
floot() 返回小于或等于x的最大整数
if()>SELECT(1>2,2,3);->3
rand() 返回0和1之间的一个整数
char() 返回整数ASCII代码字符组成的字符串
extractvalue()
第一个参数:XML document是string格式
第二个参数:XPath string(XPath格式的字符串)
作用:从目标XML中返回包含所查询的字符串
updatexml()
第一个参数:XML document是String格式
第二个参数:Xpath string
第三个参数:new value,String格式,醍醐你查找到的符合条件的数据
作用:改变文档中符合条件的节点的值
STRCMP() 比较字符串内容 IFNULL() 加入参数1不为NULL,返回值为参数1,否则返回值为参数2
exp() 返回e的x次方

MySQL运算符

in:

mysql> select id ,username from users where username in ('admin','tesdt');
+----+----------+
| id | username |
+----+----------+
|  8 | admin    |
+----+----------+

not in:

mysql> select id ,username from users where username not in ('admin','tesdt');
+----+----------+
| id | username |
+----+----------+
|  1 | Dumb     |
|  2 | Angelina |
|  3 | Dummy    |
|  4 | secure   |
|  5 | stupid   |
|  6 | superman |
|  7 | batman   |
|  9 | admin1   |
| 10 | admin2   |
| 11 | admin3   |
| 12 | dhakkan  |
| 14 | admin4   |
+----+----------+

like

mysql> select id ,username from users where username like 'admin';
+----+----------+
| id | username |
+----+----------+
|  8 | admin    |
+----+----------+
1 row in set (0.00 sec)
mysql> select id ,username from users where username like '%admin%';
+----+----------+
| id | username |
+----+----------+
|  8 | admin    |
|  9 | admin1   |
| 10 | admin2   |
| 11 | admin3   |
| 14 | admin4   |
+----+----------+
5 rows in set (0.00 sec)

regexp

mysql> select user();
+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

mysql> select user() regexp 'root';
+----------------------+
| user() regexp 'root' |
+----------------------+
|                    1 |
+----------------------+
1 row in set (0.00 sec)

mysql> select user() regexp 'root0';
+-----------------------+
| user() regexp 'root0' |
+-----------------------+
|                     0 |
+-----------------------+
1 row in set (0.00 sec)

MySQL逻辑运算

and or

mysql> select * from users where id =1 and 1=2;
Empty set (0.00 sec)

mysql> select * from users where id =1 and 1=1;
+----+----------+----------+
| id | username | password |
+----+----------+----------+
|  1 | Dumb     | Dumb     |
+----+----------+----------+
1 row in set (0.00 sec)

mysql> select * from users where id =1 or 1=2;
+----+----------+----------+
| id | username | password |
+----+----------+----------+
|  1 | Dumb     | Dumb     |
+----+----------+----------+
1 row in set (0.00 sec)

万能密码: ‘or ‘1’ ='1

登录处的SQL语句:select * from users where username= ‘admin’ and pwd= ‘pass’;

加入万能密码后语句:select * from users where username=’ ‘or ‘1’ =‘1’ and pwd =’’ or’1’=‘1’;

你可能感兴趣的:(web安全,白帽子)