...
Code Block | ||
---|---|---|
| ||
lazenca0x0@ubuntu:~/Exploit/RaceCondition$ mkdir etc
lazenca0x0@ubuntu:~/Exploit/RaceCondition$ cd etc
lazenca0x0@ubuntu:~/Exploit/RaceCondition/etc$ echo Only Root! > passwd
lazenca0x0@ubuntu:~/Exploit/RaceCondition/etc$ cat passwd
Only Root!
lazenca0x0@ubuntu:~/Exploit/RaceCondition/etc$ sudo chown root:root passwd
lazenca0x0@ubuntu:~/Exploit/RaceCondition/etc$ sudo chmod 644 passwd
lazenca0x0@ubuntu:~/Exploit/RaceCondition/etc$ ls -al passwd
-rw-r--r-- 1 root root 13 Jun 26 00:46 passwd
lazenca0x0@ubuntu:~/Exploit/RaceCondition/etc$ cd ..
lazenca0x0@ubuntu:~/Exploit/RaceCondition$ echo > file |
- 다음과 같이 취약성이 존재하는 코드를 작성합니다.
- access() 함수를 이용하여 쓰기가 가능한지 확인합니다.
- 쓰기가 가능하다면 open(), write() 함수를 이용하여 파일을 읽고 내용을 작성합니다.
- 취약성은 다음과 같은 이유 때문에 발생합니다.
- access() 와 open() 함수는 파일 핸들 대신에 파일 이름을 사용하고 있습니다.
- 해당 함수들이 파일 핸들을 사용하고 있지 않기 때문에 access()함수에 전달된 파일이 open() 파일과 동일하다고 보장할 수 없습니다.
- 공격자가 access() 함수를 호출 한 후에 심볼릭 링크로 파일을 변경하면 open() 함수에 의해 다른 파일을 수정할 수 있습니다.
...