[GoogleCTF2019 Quals]Bnv

我们打开页面,没发现有啥信息,我们进行抓包

image-20240919204517785

我们看到json格式的,将json改为xml格式,尝试xxe注入

1
2
Content-type: application/json
Content-type: application/xml

首先构造DTD,声明实体b和元素message

其实之前做得题目都是不用申明元素的,这里如果不申明会报

xxe

[Black Watch 入群题]Web

我们点击热点进行抓包

image-20240909211806163

看url,我们考虑在id处进行注入

image-20240909211939251

有注入点,通过测试,我们发现过滤了空格

mysql

[HFCTF2020]BabyUpload

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
<?php
error_reporting(0);
session_save_path("/var/babyctf/");
session_start();
require_once "/flag";
highlight_file(__FILE__);
if($_SESSION['username'] ==='admin')
{
$filename='/var/babyctf/success.txt';
if(file_exists($filename)){
safe_delete($filename
die($flag);
}
}
else{
$_SESSION['username'] ='guest';
}
$direction = filter_input(INPUT_POST, 'direction');
$attr = filter_input(INPUT_POST, 'attr');
$dir_path = "/var/babyctf/".$attr;
if($attr==="private"){
$dir_path .= "/".$_SESSION['username'];
}
if($direction === "upload"){
try{
if(!is_uploaded_file($_FILES['up_file']['tmp_name'])){
throw new RuntimeException('invalid upload');
}
$file_path = $dir_path."/".$_FILES['up_file']['name'];
$file_path .= "_".hash_file("sha256",$_FILES['up_file']['tmp_name']);
if(preg_match('/(\.\.\/|\.\.\\\\)/', $file_path)){
throw new RuntimeException('invalid file path');
}
@mkdir($dir_path, 0700, TRUE);
if(move_uploaded_file($_FILES['up_file']['tmp_name'],$file_path)){
$upload_result = "uploaded";
}else{
throw new RuntimeException('error while saving');
}
} catch (RuntimeException $e) {
$upload_result = $e->getMessage();
}
} elseif ($direction === "download") {
try{
$filename = basename(filter_input(INPUT_POST, 'filename'));
$file_path = $dir_path."/".$filename;
if(preg_match('/(\.\.\/|\.\.\\\\)/', $file_path)){
throw new RuntimeException('invalid file path');
}
if(!file_exists($file_path)) {
throw new RuntimeException('file not exist');
}
header('Content-Type: application/force-download');
header('Content-Length: '.filesize($file_path));
header('Content-Disposition: attachment; filename="'.substr($filename, 0, -65).'"');
if(readfile($file_path)){
$download_result = "downloaded";
}else{
throw new RuntimeException('error while saving');
}
} catch (RuntimeException $e) {
$download_result = $e->getMessage();
}
exit;
}
?>

前面部分设置了session存储路径,启动了session并根目录下包含flag

1
2
3
4
5
error_reporting(0);
session_save_path("/var/babyctf/");
session_start();
require_once "/flag";

接下来判断session的username是否为admin,如果是,则判断/var/babyctf下是否存在

success.txt,如果存在,删除文件并输出flag,否则设置usename为guest

upload

[WMCTF2020]Make PHP Great Again 2.0

require_once 表达式和 require 表达式完全相同,唯一区别是 PHP 会检查该文件是否已经被包含过,如果是则不会再次包含。

由于 require_once 包含的软链接层数较多时 once 的 hash 匹配会直接失效造成重复包含。

php特性

[SWPU2019]Web4

打开页面发现一个登录框,输入账号和密码后没有反应

我们f12打开页面源码,发现js代码

image-20240908201027925

js主要功能是将username和password以json格式然后发给index.php?r=Login/Login。

我们进行抓包

sql注入json

[GWCTF 2019]mypassword(xss)

打开题目,后先查看源码有没有什么有用的东西,发现了login.php、register.php以及login.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
//login.js
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split('; ');
var cookie = {};
for (var i = 0; i < cookies.length; i++) {
var arr = cookies[i].split('=');
var key = arr[0];
cookie[key] = arr[1];
}
if(typeof(cookie['user']) != "undefined" && typeof(cookie['psw']) != "undefined"){
document.getElementsByName("username")[0].value = cookie['user'];
document.getElementsByName("password")[0].value = cookie['psw'];
}
}

代码会把cookie中的username和password填进当前表单

注册登录,根据题目提示这应该不是sql注入题目

xss

[RoarCTF 2019]Online Proxy

http://t.csdnimg.cn/hrdF4

我们f12看到页面源码

image-20240906200203907

我们测试一下,先输入 1’ or ‘1 此时我们的current IP就等于它,让后我们再随便换一个其他的东西,只要和刚才那个不一样就可以,比如111,那么我们的current IP就成了:111,而last IP就是1’ or ‘1,此时1’ or ‘1已经写入了数据库 .因为第一次和第二次传输的IP不一样,所以服务器并不会从数据库找last IP,它会把上次的IP(1’or ‘1)直接显示为last IP,让后存入数据库。那么我们再传一次111,因为和currnet IP相同,那么last IP就会从数据库里寻找,也就是会执行1’or‘1,结果为一。

题解sql注入