1. 문제
2. 풀이
- 이전 레벨과 비슷한데 정규 표현식으로 ; | & 문자를 막음.
- 우회를 통해서 해야한다.
<?
$key = "";
if(array_key_exists("needle", $_REQUEST)) {
$key = $_REQUEST["needle"];
}
if($key != "") {
if(preg_match('/[;|&]/',$key)) {
print "Input contains an illegal character!";
} else {
passthru("grep -i $key dictionary.txt");
}
}
?>
- 음…. 일단 grep을 사용 어떻게 패스워드를 읽을까
- grep 의 동작을 보면 다음과 같이 검색을 할 수 있다.
- 그럼 grep -i . /etc/natas_webpass/natas11 로 하면 /etc 경로와 dictinary.txt 파일을 모두 탐색할 것이다.
- . 은 파일의 모든 줄에서 모든 줄을 출력해주는 역할을 하고
- /etc/natas_webpass/natas11 로 패스워드를 읽는다.
- 그렇다면 grep을 cat 처럼 사용할 수 있다.
grep [옵션] '패턴' [파일1] [파일2]
. /etc/natas_webpass/natas11
- 끝
'Wargame > natas wargame' 카테고리의 다른 글
Natas Level 8 → Level 9 (0) | 2025.01.08 |
---|---|
Natas Level 7 → Level 8 (0) | 2025.01.08 |
Natas Level 6 → Level 7 (0) | 2025.01.08 |
Natas Level 5 → Level 6 (0) | 2025.01.08 |
Natas Level 4 → Level 5 (0) | 2025.01.08 |