Information Security
[Pwnable.kr] collision 본문
https://pwnable.kr/play.php
pwnable.kr
문제 파일 확인
col.c 파일 확인
#include <stdio.h>
#include <string.h>
unsigned long hashcode = 0x21DD09EC;
unsigned long check_password(const char* p){
int* ip = (int*)p;
int i;
int res=0;
for(i=0; i<5; i++){
res += ip[i];
}
return res;
}
int main(int argc, char* argv[]){
if(argc<2){
printf("usage : %s [passcode]\n", argv[0]);
return 0;
}
if(strlen(argv[1]) != 20){
printf("passcode length should be 20 bytes\n");
return 0;
}
if(hashcode == check_password( argv[1] )){
system("/bin/cat flag");
return 0;
}
else
printf("wrong passcode.\n");
return 0;
}
argv의 length는 20이 넘지 않아야 하며
check_password 함수를 보았을 때 같은 값을 (0,1,2,3,4) 5번 반복해서 더해주는 것을 볼 수 있다
반복한 값 res가 hashcode(0x21DD09EC)와 같다면 flag를 보여준다
21DD09EC/5 = 6C5 CEC8
6C5 CEC8 * 5 = 21DD 09E8
6C5 CEC8 * 4 = 1B17 3B20
21DD09EC = 6C5 CEC8 * 4 + 6C5 CECC
from pwn import *
payload = p32(0x6C5CEC8) * 4 + p32(0x6C5CECC)
argvs = ['/home/col/col', payload]
p = ssh("col", "pwnable.kr", port=2222, password='guest')
p1 = p.process(executable='/home/col/col', argv=argvs)
p1.interactive()
flag 획득
'INTERLUDE > System Hacking' 카테고리의 다른 글
[Pwnable.kr] unexploitable (0) | 2024.01.18 |
---|---|
[Pwnable.kr] bof (0) | 2024.01.18 |
[Pwnable.kr] fd (0) | 2024.01.16 |
[Dreamhack] sint (0) | 2022.11.22 |
[Dreamhack] basic_rop_x86 (0) | 2022.11.17 |