본문 바로가기

Reversing

KnightCTF 2022 Baby Shark writeup

반응형

KnightCTF-2022 Baby Shark writeup

 

 

이번 문제는 KnightCTF 2023을 준비하는 과정에서 github에 있는 문제를 다운로드하여서 풀었다. 먼저 문제 파일은 https://github.com/sajjadium/ctf-archives/tree/main/KnightCTF/2022/rev/babyshark 

위 링크에서 다운로드 하면 된다.  파일은 jar 파일이고 필자는 jadx로 디컴파일 했다.

 

디컴파일해서 파일구조를 보면 굉장히 간단하다. 코드를 쭉 둘러보자.

 

 

main()

package kctf;

/* loaded from: babyshark.jar:kctf/Main.class */
public class Main {
    public static void main(String[] args) throws Exception {
        Sound s = new Sound();
        s.play();
    }
}

메인 함수를 보면 Sound 객체를 생성하고 play 메서드를 실행한다.

 

 

Sound Class

package kctf;

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;

/* loaded from: babyshark.jar:kctf/Sound.class */
public class Sound {
    public void play() throws Exception {
        try {
            AudioInputStream audioIn = AudioSystem.getAudioInputStream(getClass().getClassLoader().getResource("audio.wav").toURI().toURL());
            Clip clip = AudioSystem.getClip();
            clip.open(audioIn);
            clip.start();
            while (true) {
                System.out.println("Baby shark do doo dooo doo");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

사운드 객체를 보면 딱히 flag와 관련있는 행동은 안 하고 진짜 음악만 플레이한다.

 

 

 

Flag Class

package kctf.flag;

/* loaded from: babyshark.jar:kctf/flag/Flag.class */
public class Flag {
    private static final int count = 0;
    private static final String flag = "KCTF{this_is_not_the_flag}";
    private static final String comment = "You thought this was the flag? LOL";
}

Flag 클래스를 보면 fake flag가 있다. 단서가 부족해서 다른 곳도 둘러봤다.

 

 

Strings Class

package kctf.constants;

/* loaded from: babyshark.jar:kctf/constants/Strings.class */
public class Strings {
    public static final String _0xf1a6 = "7P0HJKddEnGG==";
    public static final String _0xflac = "LoE2301mP00FZFWeEQJJR==";
    public static final String _0xface = "N5tFdK18ZKN0442LDVZXSWE7k71Dfr==";
    public static final String _0xfj23 = "ns3PTTDkVYsslUI==";
    public static final String _0xfka6 = "rN88230S8892KL332GDxV1DK=";
    public static final String _0xflag = "S0NURns3SDE1X1dANV8zNDVZX1IxNkg3P30=";
}

Strings 클래스를 보니 딱봐도 base64로 인코딩 된 문자가 있다. 그중 마지막인 0xflag가 거슬린다. 

 

 

자존감 지킴이 문제인 것 같다. 간단한 문제였다.

728x90