๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • Welcome.
:: DreamHack ๐Ÿšฉ/wargame - reverse

[ dreamhack ] - [ reversing | rev-basic-5 ]

by EunBird 2022. 5. 31.

https://dreamhack.io/wargame/challenges/19/

 

rev-basic-5

Reversing Basic Challenge #5 ์ด ๋ฌธ์ œ๋Š” ์‚ฌ์šฉ์ž์—๊ฒŒ ๋ฌธ์ž์—ด ์ž…๋ ฅ์„ ๋ฐ›์•„ ์ •ํ•ด์ง„ ๋ฐฉ๋ฒ•์œผ๋กœ ์ž…๋ ฅ๊ฐ’์„ ๊ฒ€์ฆํ•˜์—ฌ correct ๋˜๋Š” wrong์„ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์ด ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. ํ•ด๋‹น ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ๋ถ„์„ํ•˜์—ฌ correct๋ฅผ ์ถœ

dreamhack.io

 

rev-basic-5 ๋ฌธ์ œ๋„ ์ด์ „๊นŒ์ง€์˜ rev-basic ๋ฌธ์ œ๋“ค๊ณผ ๋น„์Šทํ•œ ์œ ํ˜•์ด๋‹ค.

 

Correct ๋ฌธ์ž์—ด์„ ์ฐพ์•„์„œ ๋”ฐ๋ผ๊ฐ€๋ณธ๋‹ค.
main ํ•จ์ˆ˜์—์„œ ์ฐธ์กฐ๋˜์—ˆ์Œ์„ ํ™•์ธ.
๋””์ปดํŒŒ์ผ๋œ ์ฝ”๋“œ ํ™•์ธ.
sub_140001000 ํ•จ์ˆ˜ ํ™•์ธ.

if ์ ˆ์˜ ์กฐ๊ฑด๋ฌธ์„ ํ™•์ธํ•ด๋ณด๋ฉด,

*(unsigned __int8 *)(a1 + i + 1) + *(unsigned __int8 *)(a1 + i) != byte_140003000[i]

๋ผ๊ณ  ๋˜์–ด ์žˆ๋Š”๋ฐ, 

 

์ด๋ฅผ ๋ณด๊ธฐ ํŽธํ•˜๊ฒŒ ์ •๋ฆฌํ•˜์ž๋ฉด,

 

a1[i+1] + a1[i] != byte_140003000[i]

 

์ด๋‹ค.

 

์ฆ‰, 

a1[i+1] + a1[i] = byte_140003000[i]
์ด๋ผ๋Š” ์˜๋ฏธ ์ด๋ฏ€๋กœ 

์ˆ˜ํ•™์ ์œผ๋กœ ์ƒ๊ฐํ–ˆ์„ ๋•Œ, ์ดํ•ญํ•˜๋ฉด


a1[i] = byte_140003000[i] - a1[i+1] 

๊ฐ€ ๋œ๋‹ค.

 

 

๊ทธ๋Ÿผ byte_140003000 ์— ์ €์žฅ๋œ ๋ฌธ์ž๋“ค์„ ํ™•์ธํ•ด๋ณด์ž.


ADh, D8h, CBh, CBh, 9Dh, 
97h, CBh, C4h, 92h, A1h, 
D2h, D7h, D2h, D6h, A8h, 
A5h, DCh, C7h, ADh, A3h, 
A1h, 98h, 4Ch, 00h

 

์ด๋ ‡๊ฒŒ 24๊ฐœ ์ฆ‰, 0x18 ๊ฐœ ์ด๋‹ค.

 

์ด๋•Œ, ๋งˆ์ง€๋ง‰ ๋ฌธ์ž๊ฐ€ 0x00 ์ด๋ฏ€๋กœ 

๋’ค์—์„œ ๋ถ€ํ„ฐ ํ•˜๋‚˜์”ฉ ๊ตฌํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ์œผ๋กœ ๋ณด์ธ๋‹ค.

C๋กœ ์ž‘์„ฑํ•ด ๋ณด์•˜๋‹ค.

#include<stdio.h>
int main(){
        int byte[] = {
                0xAD, 0xD8, 0xCB, 0xCB, 0x9D,
                0x97, 0xCB, 0xC4, 0x92, 0xA1,
                0xD2, 0xD7, 0xD2, 0xD6, 0xA8,
                0xA5, 0xDC, 0xC7, 0xAD, 0xA3,
                0xA1, 0x98, 0x4C, 0x0
                };
        int input[24];
        int last = 0;

        int i;
        for (i=23 ; 0<=i ; i--){
                last = byte[i] - last;
                input[i] = last;

        }

        int j;
        for (j=0 ; j <24 ; j++){
                printf("%c", input[j]);
        }
        printf("\n");
        return 0;
}

 

์ด๋ ‡๊ฒŒ ๊ตฌํ•˜๋ฉด 

FLAG ๋Š” All_l1fe_3nds_w1th_NULL 

์ด๋‹ค.

728x90

':: DreamHack ๐Ÿšฉ > wargame - reverse' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[ dreamhack ] - [ reversing | rev-basic-7]  (0) 2022.06.01
[ dreamhack ] - [ reversing | rev-basic-6]  (0) 2022.05.31
[ dreamhack ] - [ reversing | rev-basic-4 ]  (0) 2022.05.30
reversing | [CodeEngn] Malware L07  (0) 2022.05.30
[dreamhack] - [reversing | rev-basic-2]  (0) 2022.05.30

๋Œ“๊ธ€