
Level20.
level20의 계정으로 접속하여 hint를 확인해보면 다음과 같습니다.

코드를 보았을 때, bleh라는 80byte짜리 배열을 선언합니다. BOF를 하려면 RET를 조작해야 하는데, fgets 함수로79byte만 입력받게 되어 있으므로 BOF공격은 힘들 것 같습니다. printf(bleh)는 FSB취약점이 존재하므로, FSB를 이용해 공격을 시도해야 할 것 같습니다.

%x 를 대입해본 결과, 예상한대로 FSB취약점이 존재함을 알 수 있습니다. gdb를 이용해 분석을 시도해 보려 했지만, main함수가 존재하지 않아 분석이 불가능합니다. 따라서, .dtors영역을 이용해 FSB공격을 하겠습니다.

출력된 주소인 0x08049594는 __DTOR__LIST__의 주소입니다. __DTOR__END__의 심볼을 덮어써야 하기 때문에, +4만큼 떨어진 주소 0x08049598을 이용합니다. 그 후, 환경변수에 쉘코드를 올린 후, 주소를 확인합니다.

bleh[80]이 스택상으로 얼마만큼 이동후에 존재하는지 알아보기 위해 다음과 같이 입력해보았습니다.

12byte를 이동한 후에 bleh[80]이 시작됨을 알 수 있습니다.
payload를 구성하여 대입한 결과는 다음과 같습니다.

No comments:
Post a Comment