太湖杯writeup

5gstudent發表於2020-11-22

“太湖杯”線上賽和決賽都結束了,放上我們的線上賽web題的writeup

CheckInGame

checkInGame本題是個js遊戲

設定個斷點後,之後修改時間即可,然後把遊戲玩完就行。

ezWeb

本題是模板注入,過濾了{}和"",用︷︸和無引號的payload繞過就行了

CrossFire

聯合注入雙寫繞過。load_file直接讀原始碼。

<?php
    error_reporting(0);
    session_start();
    include('config.php');

    $upload = 'upload/'.md5("shuyu".$_SERVER['REMOTE_ADDR']);
    @mkdir($upload);
    file_put_contents($upload.'/index.html', '');
    
    if(isset($_POST['submit'])){
        $allow_type=array("jpg","gif","png","bmp","tar","zip");
        $fileext = substr(strrchr($_FILES['file']['name'], '.'), 1);
        if ($_FILES["file"]["error"] > 0 && !in_array($fileext,$type) && $_FILES["file"]["size"] > 204800){
            die('upload error');
        }else{
            $filename=addslashes($_FILES['file']['name']);
            $sql="insert into img (filename) values ('$filename')";
            $conn->query($sql);
            $sql="select id from img where filename='$filename'";
            $result=$conn->query($sql);


            if ($result->num_rows > 0) {
                while($row = $result->fetch_assoc()) {
                    $id=$row["id"];
                }
            move_uploaded_file($_FILES["file"]["tmp_name"],$upload.'/'.$filename);
            header("Location: index.php?id=$id");
            }
        }
    }

    elseif (isset($_GET['id'])){
        $id=addslashes($_GET['id']);
        $sql="select filename from img where id=$id";
        $result=$conn->query($sql);
        if ($result->num_rows > 0) {
            while($row = $result->fetch_assoc()) {
                $filename=$row["filename"];
            }
        $img=$upload.'/'.$filename;
        echo "<img src='$img'/>";
        }
    }

    elseif (isset($_POST['submit1'])){
        $allow_type=array("jpg","gif","png","bmp","tar","zip");
        $fileext = substr(strrchr($_FILES['file']['name'], '.'), 1);
        if ($_FILES["file"]["error"] > 0 && !in_array($fileext,$type) && $_FILES["file"]["size"] > 204800){
            die('upload error');
        }else{
            $filename=addslashes($_FILES['file']['name']);
            move_uploaded_file($_FILES["file"]["tmp_name"],$upload.'/'.$filename);
            @exec("cd /tmp&&python3 /tar.py ".escapeshellarg('/var/www/html/'.$upload.'/'.$filename));
            }
        }
?>

config.php

$conn=mysqli_connect("localhost","root","root","shuyu"); 
if (mysqli_connect_error($conn))
{ 
    echo "???? MySQL ???: " . mysqli_connect_error(); 
} 
foreach ($_GET as $key => $value) {
	 $value= str_ireplace('\'','',$value);
	 $value= str_ireplace('"','',$value);
     $value= str_ireplace('union','',$value);
     $value= str_ireplace('select','',$value);
     $value= str_ireplace('from','',$value);
     $value= str_ireplace('or','',$value);
	 $_GET[$key] =$value;
 }
?>

完後檔案上傳結合目錄穿越拿shellflag{332a580f-b254-48fd-91b4-1d4fb6ad14fb}

ezMd5

http://122.112.253.121:10032/robots.txt

發現有個可疑目錄,開啟後是一個檔案,明顯是pwn題

然後利用棧溢位可以覆蓋返回值username =240610708password=CCCCCCCCCCBBBBBBBBBBBBBBBBBBBBBBQNKCDZO

相關文章