아이디와 비밀번호가 나와있다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
<?php
include "../../config.php";
if($_GET['view_source']) view_source();
if(!$_COOKIE['user']){
$val_id="guest";
$val_pw="123qwe";
for($i=0;$i<20;$i++){
$val_id=base64_encode($val_id);
$val_pw=base64_encode($val_pw);
}
$val_id=str_replace("1","!",$val_id);
$val_id=str_replace("2","@",$val_id);
$val_id=str_replace("3","$",$val_id);
$val_id=str_replace("4","^",$val_id);
$val_id=str_replace("5","&",$val_id);
$val_id=str_replace("6","*",$val_id);
$val_id=str_replace("7","(",$val_id);
$val_id=str_replace("8",")",$val_id);
$val_pw=str_replace("1","!",$val_pw);
$val_pw=str_replace("2","@",$val_pw);
$val_pw=str_replace("3","$",$val_pw);
$val_pw=str_replace("4","^",$val_pw);
$val_pw=str_replace("5","&",$val_pw);
$val_pw=str_replace("6","*",$val_pw);
$val_pw=str_replace("7","(",$val_pw);
$val_pw=str_replace("8",")",$val_pw);
Setcookie("user",$val_id,time()+86400,"/challenge/web-06/");
Setcookie("password",$val_pw,time()+86400,"/challenge/web-06/");
echo("<meta http-equiv=refresh content=0>");
exit;
}
?>
<html>
<head>
<title>Challenge 6</title>
<style type="text/css">
body { background:black; color:white; font-size:10pt; }
</style>
</head>
<body>
<?php
$decode_id=$_COOKIE['user'];
$decode_pw=$_COOKIE['password'];
$decode_id=str_replace("!","1",$decode_id);
$decode_id=str_replace("@","2",$decode_id);
$decode_id=str_replace("$","3",$decode_id);
$decode_id=str_replace("^","4",$decode_id);
$decode_id=str_replace("&","5",$decode_id);
$decode_id=str_replace("*","6",$decode_id);
$decode_id=str_replace("(","7",$decode_id);
$decode_id=str_replace(")","8",$decode_id);
$decode_pw=str_replace("!","1",$decode_pw);
$decode_pw=str_replace("@","2",$decode_pw);
$decode_pw=str_replace("$","3",$decode_pw);
$decode_pw=str_replace("^","4",$decode_pw);
$decode_pw=str_replace("&","5",$decode_pw);
$decode_pw=str_replace("*","6",$decode_pw);
$decode_pw=str_replace("(","7",$decode_pw);
$decode_pw=str_replace(")","8",$decode_pw);
for($i=0;$i<20;$i++){
$decode_id=base64_decode($decode_id);
$decode_pw=base64_decode($decode_pw);
}
echo("<hr><a href=./?view_source=1 style=color:yellow;>view-source</a><br><br>");
echo("ID : $decode_id<br>PW : $decode_pw<hr>");
if($decode_id=="admin" && $decode_pw=="nimda"){
solve(6);
}
?>
</body>
</html>
|
[소스분석]
- 쿠키가 설정되어있지 않다면, user 쿠키 -> guest, password 쿠키 -> 123qwe 로 설정 후,
- user 쿠키와 password 쿠키를 가져와 20번 base64 인코딩 후, 숫자를 키보드상의 기호로 바꾼다 (ex : 1 ->! )
- user 쿠키와 password 쿠키를 가져와 20번 base64 디코딩 후, 키보드상의 기호를 숫자로 바꾼다 (ex : ! -> 1 )
- user 쿠키 == admin, password쿠키 == nimda 일때 문제가 풀린다.
admin 과 nimda 를 base64 로 20번 인코딩 후, 숫자를 키보드상의 기호로 바꾼뒤,
각각 user쿠키, password쿠키값에 넣어주면 문제가 풀릴것이다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import base64
id="admin"
pw="nimda"
for i in range(0,20):
id=base64.b64encode(id)
pw=base64.b64encode(pw)
id=id.replace("1","!");
id=id.replace("2","@");
id=id.replace("3","$");
id=id.replace("4","^");
id=id.replace("5","&");
id=id.replace("6","*");
id=id.replace("7","(");
id=id.replace("8",")");
pw=pw.replace("1","!");
pw=pw.replace("2","@");
pw=pw.replace("3","$");
pw=pw.replace("4","^");
pw=pw.replace("5","&");
pw=pw.replace("6","*");
pw=pw.replace("7","(");
pw=pw.replace("8",")");
print(id+"\n-------------\n")
print(pw)
|
쿠키값을 구하는 소스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F^V@tOVmJFSlZUVVF$UFE9PQ==
둘다 같은값처럼 보이지만, 끝까지 보면 다르다. 다르다고
edit this cookie 로 구한 쿠키값을 넣어주면
admin 으로 로그인이되서 문제가 풀리게된다.