__int64 __fastcall sub_7FA(FILE *in, FILE *out) {
__int64 result; // rax
unsigned __int8 count; // [rsp+17h] [rbp-9h]
int nowChar; // [rsp+18h] [rbp-8h]
int prevChar; // [rsp+1Ch] [rbp-4h]
if (in == NULL || out == NULL) {
*__errno_location() = 2;
result = 0xFFFFFFFFLL;
}
prevChar = -1;
count = 0;
while (1) {
nowChar = fgetc(in);
if (nowChar == -1)
break;
fputc(nowChar, out);
if (nowChar == prevChar) {
count = 0;
while (1) {
nowChar = fgetc(in);
if (nowChar == -1)
break;
if (nowChar != prevChar) {
fputc(count, out);
fputc(nowChar, out);
prevChar = nowChar;
break;
}
if (++count == 0xFF) {
fputc(255, out);
prevChar = -1;
break;
}
}
} else {
prevChar = nowChar;
}
if (nowChar == -1) {
fputc(count, out);
break;
}
}
return 0;
}
참 쉽죠? 이 과정을 자세히 보시면
Run Length Encoding 인코딩 과정임을 알 수 있습니다.
따라서 이를 역으로 돌려서 인코딩을 풀어주시고
image viewer로 raw 데이터를 보기만 하시면
flag get !!
'호그와트' 카테고리의 다른 글
행복한 은행 관리법 (0) | 2022.06.15 |
---|---|
적정한 암호 생성하기 (0) | 2022.06.13 |
beauty 후후훗 (0) | 2022.05.30 |
드림핵 해시 브브라우니 브라운 dreamhack (0) | 2022.05.17 |
드림핵 dreamhack fly to the moon (0) | 2022.05.12 |