Index

1. Problem information

2. Problem solving

3. Review


 

 

 

[Problem information]


 

 

 

[Problem solving]

1. I accessed to the server using SSH. But the server required a password. There was a hint about password in problem information. It said "flag.txt file will contain the password". So I put the contents of the flag file obtained from the Operation RCity0 problem as a password.

 

 

2. I determined which files or directories exist in the current path. There were three directorys. In particular, there was a directory named flag. I accessed to it, but there was no files in it.

 

 

3. Then I checked the directory named 'maybe here'. There was a 'fl ag.txt' file in it. So I checked what was in there. 


 

 

 

[Review]

It's easy.

'Wargame & CTF > RACCOON CITY' 카테고리의 다른 글

[RACCOON CITY] Operation RCity5  (0) 2024.02.09
[RACCOON CITY] Operation RCity4  (0) 2024.02.08
[RACCOON CITY] Operation RCity3  (0) 2024.02.08
[RACCOON CITY] Operation RCity2  (0) 2024.02.06
[RACCOON CITY] Operation RCity0  (0) 2024.02.05

Index

1. Problem information

2. Problem solving

3. Review


 

 

 

[Problem information]


 

 

 

[Problem solving]

1. Let's access to the server using SSH. The ssh command consists of: ssh Username@Address-p Port 

 

 

2. I used the ls command to see which files exist in the current path. There was a file named flag.

 

 

3. Then I checked the contents of the flag file through the cat command.


 

 

 

[Review]

So far, I have mainly solved problems accessed through netcat rather than SSH. it was a beneficial time to get used to SSH.

'Wargame & CTF > RACCOON CITY' 카테고리의 다른 글

[RACCOON CITY] Operation RCity5  (0) 2024.02.09
[RACCOON CITY] Operation RCity4  (0) 2024.02.08
[RACCOON CITY] Operation RCity3  (0) 2024.02.08
[RACCOON CITY] Operation RCity2  (0) 2024.02.06
[RACCOON CITY] Operation RCity1  (0) 2024.02.06
  • Problem path
  • Problem information
  • Problem solving

 

 

 

[Problem path]

https://dreamhack.io/wargame/challenges/1113

 

php7cmp4re

Description php 7.4로 작성된 페이지입니다. 알맞은 Input 값을 입력하고 플래그를 획득하세요. 플래그 형식은 DH{} 입니다.

dreamhack.io


 

 

 

[Problem information]


 

 

 

[Problem solving]

1. First, I accessed the web server. There was a page where you can get input1 and input2.

 

 

2. Second, I downloaded the problem file. There were three php files in it. When I checked the code, the check.php file  specified the conditions of input1 and input2.

 

 

3. It seems that the flag is echoed only when both input1 and input2 conditions are suitable. The conditions are summarized in the following table.

Input Length Size
input_1        input_1 < 4    input_1 < "8" && input_1 < "7.A" && input_1 > "7.9"
input_2 input_2 < 3 && input_2 > 1 input_2 < 74 && input_2 > "74"

 

Looking at input1, I guessed that it was an ASCII code value because it was compared with the letters "8", "7.A", and "7.9". Therefore, referring to the ASCII code table, it was confirmed that the number of characters ranging from 

7.: to 7.@, which is larger than the letter 9 and smaller than the letter A, and has less than 4 characters, can be put into input1. It has been confirmed that input2 can contain numbers ranging from 7: to 7~, which are 2 characters and larger 

than the letter 4 and smaller than the number 4.

 

 

4. I simply put in the input value according to the conditions.

 

The flag was derived as follows.

 

'Wargame & CTF > dreamhack' 카테고리의 다른 글

[Webhacking] what-is-my-ip  (0) 2024.03.30
[Webhacking] Type c-j  (0) 2023.09.29
[Webhacking] Flying Chars  (0) 2023.08.22
[Webhacking] devtools-sources  (0) 2023.08.21
[Webhacking] session-basic  (0) 2023.08.13

  • 문제경로
  • 문제정보
  • 문제풀이

 

 

 

[문제경로]

https://dreamhack.io/wargame/challenges/960

 

Type c-j

Description php로 작성된 페이지입니다. 알맞은 Id과 Password를 입력하여 플래그를 획득하세요. 플래그의 형식은 DH{...} 입니다.

dreamhack.io


 

 

 

[문제정보]


 

 

 

[문제풀이]

1. 우선 웹서버에 접속했다. ID와 Password를 입력받을 수 있는 페이지가 있다. 

 

 

2. 얻을 수 있는 특별한 정보가 없어 소스코드를 다운로드하였다. 3개의 php 파일이 있는데 코드를 확인해 보니 check.php 파일을 통해서 ID와 Password를 얻을 수 있었다.

 

check.php 파일의 소스코드에서 ID와 Password를 얻을 수 있는 코드를 확인해 봤다. getRandStr() 함수를 호출하여 나온 값이 id에 저장되고 sha1("1") 함수를 호출해서 나온 값은 pw에 저장되는 것을 알 수 있다.

 

 

3. id 값을 먼저 구하기 위해서 getRandStr() 함수가 있는 코드로 가봤다. 어떠한 연산을 수행해서 결과적으로 randomString을 리턴하는 것을 알 수 있다.

 

randomString 값을 구하기 위해서 getRandStr() 함수를 호출하고 반환되는 값을 ID 변수에 저장한 후 해당 변수의 값을 출력하는 코드를 구성했다.

 

그리고 이 코드를 온라인 컴파일러에 돌렸더니 다음과 같은 ID 값이 출력되었다. 

 

ID 값이 맞는지 확인하기 위해서 다음 코드를 보면 알 수 있다. 입력한 id가 주어진 id와 같고, id의 길이가 10자리라면 ID pass를 출력한다는 것이다. 

 

그래서 ID 값에 구한 값을 넣고 Password에 아무 값이나 집어넣어 제출했다.

 

ID가 맞다는 것을 알 수 있다.

 

 

4. 이제 Password 값을 구해야 한다. pw 변수에는 sha1("1") 함수의 결과 값이 저장된다. (sha1 함수는 "Secure Hash Algorithm 1"의 약자로, 입력 데이터를 메시지 다이제스트라는 해시 값으로 만드는 암호화 해시 함수이며 보통 16진수 40자리로 랜더링 된다.) 온라인으로 SHA1 해시를 생성해 주는 사이트에서 1을 입력하고 생성한 결과는 다음과 같다.

 

나온 해시 값은 총 40자리이다. 그런데 소스코드에서 pw는 8자리 이어야 flag 출력이 가능하다. 

 

그냥 해시 값 앞 8자리를 pw에 넣어보기로 했다. 

 

바로 FLAG가 도출된 것을 확인할 수 있다. 

 

 

 

Reference:  https://www.mycompiler.io/ko/new/php

                        https://www.convertstring.com/ko/Hash/SHA1

                        https://ko.wikipedia.org/wiki/SHA-1

'Wargame & CTF > dreamhack' 카테고리의 다른 글

[Webhacking] what-is-my-ip  (0) 2024.03.30
[Webhacking] php7cmp4re  (0) 2024.01.30
[Webhacking] Flying Chars  (0) 2023.08.22
[Webhacking] devtools-sources  (0) 2023.08.21
[Webhacking] session-basic  (0) 2023.08.13
  • 문제경로
  • 문제풀이

 

 

 

[문제경로]

https://webhacking.kr/challenge/js-3/

 

Challenge 16

 

webhacking.kr

 

 

 

[문제풀이]

1. 문제에 접속하면 다음과 같은 이미지가 들어있다.

 

 

2. Ctrl+U를 통해 소스 코드를 확인해 봤다.

<html>
<head>
<title>Challenge 16</title>
# 배경색을 검정으로 하고, 이벤트 핸들러 onload가 실행될때 kk함수를 호출하고, 이벤트 핸들러 onkeypress가 실행될때 mv함수를 호출한다.
<body bgcolor=black onload=kk(1,1) onkeypress=mv(event.keyCode)>
<font color=silver id=c></font>
<font color=yellow size=100 style=position:relative id=star>*</font>
<script> 
document.body.innerHTML+="<font color=yellow id=aa style=position:relative;left:0;top:0>*</font>";
function mv(cd){
  kk(star.style.left-50,star.style.top-50);
# 100에 해당하는 키를 입력했을시 "*"이 오른쪽으로 50px 이동한다.
  if(cd==100) star.style.left=parseInt(star.style.left+0,10)+50+"px"; 
# 97에 해당하는 키를 입력했을시 "*"이 왼쪽으로 50px 이동한다.
  if(cd==97) star.style.left=parseInt(star.style.left+0,10)-50+"px";
# 119에 해당하는 키를 입력했을시 "*"이 위쪽으로 50px 이동한다.  
  if(cd==119) star.style.top=parseInt(star.style.top+0,10)-50+"px";
# 115에 해당하는 키를 입력했을시 아래로 "*"이 50px 이동한다.  
  if(cd==115) star.style.top=parseInt(star.style.top+0,10)+50+"px";
# 124에 해당하는 키를 입력했을시 .php 경로로 이동한다.
  if(cd==124) location.href=String.fromCharCode(cd)+".php"; // do it!
}
# "*" 모양의 특성을 정의하는 것이다. 색상이 무작위로 설정, 생성되는 위치 설정, 이벤트 핸들러 onmouseover이 실행되면서 생성된 "*"의 내용을 비운다.
function kk(x,y){
  rndc=Math.floor(Math.random()*9000000);
  document.body.innerHTML+="<font color=#"+rndc+" id=aa style=position:relative;left:"+x+";top:"+y+" onmouseover=this.innerHTML=''>*</font>";
}
</script>
</body>
</html>

124에 해당하는 키를 입력하면 .php 경로로 이동하면서 문제가 풀릴 것으로 예측된다.

 

 

3. 먼저 숫자에 해당하는 키가 있어야 하니 아스키 코드를 생각해 봤다. 

100 d
97 a
119 w
115 s
124 |

즉 124에 해당하는 "|" 키를 입력하면 문제가 풀릴 것이다.

 

입력하니 .php 경로로 이동하면서 문제가 해결되었다.

'Wargame & CTF > Webhacking.kr' 카테고리의 다른 글

[Webhacking.kr] old-26  (0) 2024.04.13
[Webhacking.kr] old-06  (0) 2024.04.10
[Webhacking.kr] old-15  (0) 2023.09.17
[Webhacking.kr] old-17  (0) 2023.09.17
[Webhacking.kr] old-03  (0) 2023.09.15
  • 문제경로
  • 문제풀이

 

 

 

[문제경로]

https://webhacking.kr/challenge/js-2/

 

Challenge 15

 

webhacking.kr

 

 

 

[문제풀이]

1.  문제에 접속하면 다음과 같은 페이지가 나온다.

OK를 클릭하면 웹사이트의 홈으로 돌아간다.

 

 

2. Ctrl+U를 통해 소스 코드를 확인해 봤다.

<html>
<head>
<title>Challenge 15</title>
</head>
<body>
<script>
  alert("Access_Denied");
# "Access_Denied"라는 경고창을 띄움
  location.href='/';
# 웹사이트의 루트 경로로 이동한다. 즉 현재 페이지를 닫지 않는한 해당 페이지는 루트 경로로 이동
  document.write("<a href=?getFlag>[Get Flag]</a>");
# 현재 페이지의 URL 뒤에 '?getFlag' 파라미터를 추가 
</script>
</body>

현재 페이지의 URL 뒤에 "?getFlag"를 넣으면 Flag를 얻으면서 문제가 해결될 것이다.

 

 

3. 현재 페이지의 링크 뒤에 "?getFlag"를 넣었다.

 

엔터를 쳤더니 문제가 풀렸다.

 

'Wargame & CTF > Webhacking.kr' 카테고리의 다른 글

[Webhacking.kr] old-06  (0) 2024.04.10
[Webhacking.kr] old-16  (0) 2023.09.22
[Webhacking.kr] old-17  (0) 2023.09.17
[Webhacking.kr] old-03  (0) 2023.09.15
[Webhacking.kr] old-01  (0) 2023.09.15
  • 문제경로
  • 문제풀이

 

 

 

[문제경로]

https://webhacking.kr/challenge/js-4/

 

Challenge 17

 

webhacking.kr

 

 

 

[문제풀이]

1. 문제에 접속하면 입력하여 제출가능한 form이 하나 존재한다.

 

 

2. Ctrl+U를 통해 소스 코드를 확인해 봤다.

<html>
<head>
<title>Challenge 17</title>
</head>
<body bgcolor=black>
<font color=red size=10></font>
<p>
<form name=login>
# 입력 가능한 form 생성
<input type=passwd name=pw><input type=button onclick=sub() value="check">
# form 안에 비밀번호를 입력받는 "pw" 입력 필드와 클릭 가능한 check 버튼 생성
</form>
<script>
unlock=100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10*100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10*100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10*100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10/100*10*10+1/10-10+10+50-9*8+7-6+5-4*3-2*1*10*100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10+100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10-100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10/100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10/100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10/100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10/100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10/100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10/100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10/100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10/100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10/100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10*100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10*100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10*100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10*100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10*100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10*100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10*100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10+9999999;
# 수식의 결과가 "unlock"에 저장
function sub(){ if(login.pw.value==unlock){ location.href="?"+unlock/10; } else{ alert("Wrong"); } }
# check 버튼 클릭 시에 실행되는 함수로 입력한 "pw"값이 "unlock"값과 일치하면 다른 URL로 이동하고 그렇지 않을 경우 Wrong이라는 경고창을 띄운다. 
</script>

"unlock" 값이 "pw"값과 일치해야 문제가 풀릴 것이다. 따라서 "unlock"값을 구해볼 것이다.

 

 

3. 계산식을 복사해서 개발자 도구의 콘솔창에서 실행시켜 결과 값을 출력해 봤다.

 

출력된 결과인 "7809297.1"을 "pw" 입력창에 넣고 check 버튼을 클릭했더니 문제가 풀렸다.

'Wargame & CTF > Webhacking.kr' 카테고리의 다른 글

[Webhacking.kr] old-06  (0) 2024.04.10
[Webhacking.kr] old-16  (0) 2023.09.22
[Webhacking.kr] old-15  (0) 2023.09.17
[Webhacking.kr] old-03  (0) 2023.09.15
[Webhacking.kr] old-01  (0) 2023.09.15
  • 문제경로
  • 문제풀이

 

 

 

[문제경로]

https://webhacking.kr/challenge/web-03/

 

Challenge 3

 

webhacking.kr


 

 

 

[문제풀이]

1. 첫 페이지에 Nonogram 이 있어서 간단하게 해결했다.

 

 

2.  두 번째 페이지는 다음과 같이 입력하고 제출할 수 있는 환경으로 구성되어 있다.

 

이것만으로는 정보가 부족하여 Ctrl+U를 통해 소스 코드를 확인해 봤다.

<html>
<head>
<title>Challenge 3</title>
</head>
<body>
<center>Nonogram</center>
<p>
<hr>

<form name=kk method=get action=index.php>
</form>
<form method=post action=index.php>
<input type=hidden name=answer value=1010100000011100101011111>
# 사용자에게 표시되지 않는 숨겨진 입력 필드를 생성, 입력 필드의 이름을 answer로 설정, answer의 기본값을 "1010100000011100101011111"로 설정
Clear!<br>enter your name for log : 
# 텍스트 표시
<input type=text name=id maxlength=10 size=10>
# 텍스트 입력 필드 생성, 입력 필드의 이름을 "id"로 설정, 입력 가능한 최대 문자 수를 10으로 제한, 입력 필드의 사이즈를 10으로 설정
<input type=submit value='submit'>
# 제출 버튼 생성, 버튼의 텍스트를 "submit"으로 설정

입력 필드가 가시적인 필드와 비가시적인 필드로 구분된 것을 알 수 있다.

 

 

3. 사용자에게 보이는 입력 필드 "id"에 SQL Injection을 시도해 봤다.

 

시도한 결과는 다음과 같다.

가시적인 입력 필드 "id"에 집어넣은 값이 그대로 출력되고, 비가시적인 입력 필드 "answer"의 기본 값도 그대로 넘어간 것을 확인할 수 있다.

 

 

4. 그러면 Burp Suite로 비가시적인 입력 필드 "answer"의 값에다 SQL Injection을 시도해 보겠다.

 

Forward 하자마자 문제가 해결되었다.

 

 

'Wargame & CTF > Webhacking.kr' 카테고리의 다른 글

[Webhacking.kr] old-06  (0) 2024.04.10
[Webhacking.kr] old-16  (0) 2023.09.22
[Webhacking.kr] old-15  (0) 2023.09.17
[Webhacking.kr] old-17  (0) 2023.09.17
[Webhacking.kr] old-01  (0) 2023.09.15

+ Recent posts