[watevrCTF 2019]Timeout

直接打开什么都没有 但是IDA显示了是一个elf文件 所以改个后缀 IDA就可以打开了
main作了一堆反调试处理
由于函数少 很容易在generate里发现flag
image
虽说是道大水题
然而我想尝试动调分析一下它给can_continue赋值后怎么调用到generate的
这里绕过反调试很暴力简单
image
call _signal,call _alarm全部改为call delay再把传入的时间参数置为0
image
这样就能绕过反调试了
接下来f8步过(不要f7...)
还是找不到它怎么进的。。。
这里看了看officialWP
用的是直接给can_continue赋值 然后设置一个跳转 (高级)

from pwn import *

flag = input("flag: ").replace("\n", "")


r = gdb.debug("downloads/timeout", '''
br _start
continue

set {int}0x60105c = 1337
set $pc = 0x4006a6
continue
''')

res = str(r.recv())

print(res)

if flag in res:
    exit(0)
exit(1)

而且题目原本的c代码很简单

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <time.h>

int can_continue = 0;

void delay(unsigned int mseconds)
{
    clock_t goal = mseconds + clock();
    while (goal > clock());
}

void generate(void){
    if(can_continue == 1337){
    char a[] = {'#', '<', 'I', 'd', 'U', '.', 'w', ' ', '-', 's', '?', '}', ',', '8', 'l', 'S', 'T', '*', 'Z', 'j', 'W', ':', 'f', '^', 'M', '6', 'e', 'n', 'p', 'h', 'c', '/', 'O', 'v', '%', 'K', '\x0b', '4', 'L', 'R', 'g', '`', '_', 'E', '{', 'r', ';', '~', 'J', '\n', 'k', 'q', 'C', '$', '\\', '(', '"', '@', '2', 'D', 'b', 'P', '\r', '&', '1', '7', '\x0c', ']', 'y', '>', '=', 'x', 'a', 'V', 'Y', 'A', '[', 'B', 'F', '3', "'", '!', 't', 'Q', 'H', 'u', '0', 'X', 'i', '5', '|', '\t', '9', 'N', '+', 'z', 'm', 'G', ')', 'o', '\0'};
    //map
    //[64, 79, 44, 13, 56, 75, 32, 94, 74, 28, 82, 92, 73, 8, 21, 54, 55, 71, 61, 19, 58, 77, 15, 87, 48, 6, 14, 23, 25, 17, 12, 76, 50, 31, 66, 46, 98, 4, 47, 53, 16, 89, 88, 40, 90, 27, 78, 93, 45, 96, 20, 26, 38, 65, 85, 69, 63, 83, 2, 39, 11, 51, 97, 67, 1, 7, 99, 86, 34, 81, 80, 33, 10, 57, 60, 36, 84, 37, 41, 3, 68, 62, 29, 52, 43, 30, 0, 59, 18, 5, 91, 95, 9, 49, 72, 35, 22, 42, 70, 24]
    char flag[] = {a[6], a[72], a[82], a[26], a[33], a[45], a[44], a[79], a[27], a[30], a[45], a[68], a[82], a[88], a[99], a[27], a[42], a[88], a[9], a[42], a[99], a[33], a[26], a[45], a[45], a[72], a[82], a[26], a[3], a[42], a[68], a[99], a[85], a[82], a[85], a[60], a[26], a[5], a[30], a[99], a[96], a[31], a[6], a[72], a[82], a[30], a[29], a[10], a[33], a[70], a[32], a[61], a[22], a[86], a[74], a[60], a[87], a[51], a[59], a[96], a[86], a[11], '\0'};
    printf("%s\n", flag);
    }
}

void sig(int sign){
	exit(0);
}

int main(void){
  signal(SIGALRM, sig);
  alarm(1);
  delay(6000000);
  can_continue = 1337;
}

可是为什么动调跑不到 啊。。。

posted @ 2023-10-24 18:37  N0zoM1z0  阅读(33)  评论(0编辑  收藏  举报