[BFA]

 

BFA(Brute Force Attack, 무차별 대입 공격)는 공격 대상 ID를 정해놓고 PW에 대입 가능한 모든 문자열을 일일이 시도해 보는 공격방식이다.

 

 

 

[RBFA]

 

RBFA(Reverse Brute Force Attack)는 BFA와 반대로 PW를 정해놓고, ID를 바꿔가며 시도해 보는 공격이다.

PW가 아닌 ID를 바꾸면서 공격한다는 점에서 이는 불특정 다수의 User들을 대상으로 하는 공격이다.

 

 

 

[사전공격]

 

공격 대상 ID를 정해놓고 PW를 바꿔가며 시도한다는 점에서 BFA와 유사하다.

그러나 사전에 준비한 파일에 있는 PW를 시험하는 공격방식이라는 점에서 차이가 있다.

 

 

 

[크리덴셜 스터핑]

 

다른 웹사이트 등으로 부터 유출된 ID나 비밀번호를 이용해 시험하는 공격이다. 

여러 웹사이트의 ID와 PW를 동일하게 설정해 놓은 이용자들이 많다는 점을 이용한 공격이다.

분야: 침해사고 분석

 

 

 

1. Cat


문제정보가 위와 같이 나와있다.

 

 

문제파일로는 수많은 웹서버 로그가 존재하는

text파일이 주어졌다.

 

 

문제정보에서 공격자가 SQL Injection을

수행했다고 했기에 SQL Injection 할 때 

자주 사용하는 주석인 '--'를 Ctrl+F로 검색을 해봤다. 

5개 정도가 검색이 되었고 동일한 ip주소를 갖고 있으며

SQL 구문을 수행한다는 것을 확인했다.

 

 

따라서 Flag 형식에 맞게 SQL Injection이

시작된 시간과 ip주소를 적어서 제출했더니

문제가 해결되었다.

 

Flag: ELECCON_2023{02:16/47.53.122.78}

 

 

 

2. Hippo


문제정보가 위와 같이 나와있다.

 

 

사람들이 많이 못 풀어서 그런지 힌트를 제공해 줬다.

힌트에서 정답을 다 알려줬다.

 

 

문제파일들이다. 

 

 

공격자가 8월 17일에 공격을 수행했다고 해서 0817 폴더를 열었다.

그런데 폴더 내부에도 여러 개의 파일들이 존재했다.

 

 

또한, 파일을 notepad로 열었을 때

수많은 메일 기록들이 있는 것으로 봤을 때 

힌트를 제공해 주는 게 적절한 선택이었던 것 같다.

안 줬으면 진짜 삽질 많이 했을 듯하다.

 

 

첫 번째 파일을 열어 Ctrl+F로

'mail'이라는 단어를 검색했다.

바로 flag 형식의 메일이 보인다.

 

Flag: ELECCON_2023{f1@g.com}

 

 

 

3. Mouse


문제정보는 위와 같다.

 

 

문제파일을 여니 수많은 

알아볼 수 없는 정보가 있었다.

 

 

Ctrl+F로 'username'과 'password'를 검색했는데 

꽤 많이 있었던 걸로 기억한다.

그런데 그냥 수작업으로 브루트 포스를 했던 기억이..

 

Flag: ELECCON_2023{xonya/0breg0N1964}

  • 문제경로
  • 문제풀이

 

 

 

[문제경로]

https://webhacking.kr/challenge/code-1/

 

Challenge 10

 

webhacking.kr

 

 

 

[문제풀이]

문제에 접속하면 위와 같이

O와 Goal이 있는 것을 볼 수 있다. 

문제가 어떻게 작동하는지 자세히 분석하기 위해

Ctrl+U 단축키를 통해 source code를 확인해 봤다.

 

 

<html>
<head>
<title>Challenge 10</title>
</head>

<body>
<hr style=height:100;background:brown;>
<table border=0 width=1800 style=background:gray>
<tr><td>
<!-- 클릭 가능한 링크를 생성하며 id는 "hackme"로 지정되고 초기 위치는 좌표값(left, top) 0,0으로 설정된다. 해당 링크를 클릭시 좌표값이 1px씩 증가하며 좌표가 "1600px"이 되면 '?go=1600px' 페이지로 이동된다. 마우스를 링크 위에 올리면 'yOu'가 표시되고, 그렇지 않으면 'O'만 화면에 표시된다. -->
<a id=hackme style="position:relative;left:0;top:0" onclick="this.style.left=parseInt(this.style.left,10)+1+'px';if(this.style.left=='1600px')this.href='?go='+this.style.left" onmouseover=this.innerHTML='yOu' onmouseout=this.innerHTML='O'>O</a><br>
<!-- 금색으로 표시된 글자들을 생성하며 오른쪽 끝에 배치되도록 한다. -->
<font style="position:relative;left:1600;top:0" color=gold>|<br>|<br>|<br>|<br>Goal</font>
</td></tr>
</table>
<hr style=height:100;background:brown;>
</body>
</html>

클릭 가능한 링크가 생성되고 

링크의 모양은 마우스가 올려졌을 때

'yOu', 그렇지 않을 때 'O' 모양이다.

링크를 클릭 시 1px만큼 이동하며

1600px가 됐을 때 목표지점으로 이동하며

문제가 해결되는 것 같다.

 

즉 링크를 1599번 클릭해서 Goal에 도착하는 방법과

클라이언트단에서의 source code를 조작하여

한번 클릭 시 1599px 만큼 이동시켜

Goal에 도착하게 하는 방법이 존재하는 것 같다. 

1번째 방법은 힘들게 수작업을 해야 하니

2번째 방법을 사용했다.

 

 

개발자 도구의 요소 탭에서

클릭했을 때 1599px가 움직이도록 설정했다.

(현재 위치 1px도 포함했기에)

 

 

'O' 모양의 링크를 클릭하니

링크의 좌표가 1600px가 되며

문제가 해결되었다.

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

[Webhacking.kr] old-26  (0) 2024.04.13
[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
  • 문제경로
  • 문제풀이

 

 

 

[문제경로]

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

 

Challenge 26

 

webhacking.kr

 

 

 

[문제풀이]

문제에 접속하면 view-source라는 하이퍼링크가 있어서

source code를 확인했다.

 

 

<?php
  include "../../config.php";
  if($_GET['view_source']) view_source();
?><html>
<head>
<title>Challenge 26</title>
<style type="text/css">
body { background:black; color:white; font-size:10pt; }    
a { color:lightgreen; }
</style>
</head>
<body>
<?php
// 만약 id에 "admin"이라는 문자열이 포함되어 있다면 "no!"를 출력하고 스크립트를 종료한다.
  if(preg_match("/admin/",$_GET['id'])) { echo"no!"; exit(); }
// 그렇지 않으면, id를 URL 디코딩한다.
  $_GET['id'] = urldecode($_GET['id']);
// 만약 id가 "admin"과 정확히 일치한다면 solve(26) 함수를 호출한다.
  if($_GET['id'] == "admin"){
    solve(26);
  }
?>
<br><br>
<a href=?view_source=1>view-source</a>
</body>
</html>

사용자로부터 'id'라는 GET 매개변수를 받아와

id에 'admin'이라는 문자열이 포함되어 있으면

"no"를 출력하고 종료된다.

그렇지 않은 경우에는 'id'를 url 디코딩하고

"admin" 문자열과 비교하여 일치하면

solve(26) 함수를 호출하며

문제가 풀리는 구조이다.

 

즉 "admin"이라는 문자열을 url 인코딩해서 'id' 값으로 집어넣으면

url 디코딩 되며 "admin"과 일치하여 문제가 해결될 것이다. 

 

 

url 인코딩 표를 참조해서

"admin"이라는 문자열을 다음과 같이 인코딩했다.

"%61%64%6d%69%6e"

 

 

url 인코딩한 값을 id에 넣어 전송했지만

"no!"라고 화면에 표시된다.

 

 

"%61%64%6d%69%6e" 이 문자열이

처음부터 "admin"으로 인식되는 것이니

다음과 같이 한 번 더 인코딩을 해서 id 값에 집어넣었다.

"%25%36%31%25%36%34%25%36%64%25%36%39%25%36%65"

문제가 해결되었다.

 

 

 

 

Reference:

https://www.eso.org/~ndelmott/url_encode.html

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

[Webhacking.kr] old-10  (0) 2024.04.13
[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
  • 문제경로
  • 문제풀이

 

 

 

[문제경로]

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

 

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

 

webhacking.kr

 

 

 

[문제풀이]

문제 페이지에 접속하면

기본으로 설정된 ID, PW와 view-source 하이퍼링크를 볼 수 있다.

 

 

<?php
include "../../config.php";
if($_GET['view_source']) view_source();

// 만약 사용자 쿠키가 설정되지 않았다면, id와 pw가 default 값으로 설정된다.
if(!$_COOKIE['user']){
  $val_id="guest";
  $val_pw="123qwe";
  
  // id와 pw를 20번씩 base64로 인코딩한다.
  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
// 쿠키로부터 id와 pw를 디코딩한다.
$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);

// id와 pw를 base64로 20번 디코딩한다.
for($i=0;$i<20;$i++){
  $decode_id=base64_decode($decode_id);
  $decode_pw=base64_decode($decode_pw);
}

// 사용자의 id와 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>");

// 디코딩된 id와 pw가 "admin", "nimda"와 일치한다면 solve(6) 함수를 호출한다.
if($decode_id=="admin" && $decode_pw=="nimda"){
  solve(6);
}
?>
</body>
</html>

view-source 하이퍼링크를 클릭해서 code를 확인했다.

 

코드를 해석해 보면 

사용자 쿠키가 설정되지 않았기에

id와 pw가 "guest", "123qwe"으로 설정되고

20번 base64 인코딩 및 특정 문자로 치환하는 과정을 거쳐서 

쿠키값으로 들어오게 된다.

그리고 다시 반대로 쿠키값을 숫자로 치환하고

20번 디코딩하는 과정을 거쳐

문제 페이지에 이를("guest", "123qwe") 출력하고 있음을 알 수 있다.

마지막에는 id와 pw의 값이 "admin", "nimda"와 일치하는지 확인하여

일치한다면 solve(6) 함수를 호출해 문제가 해결되는 것처럼 보인다. 

 

즉 문제를 해결하기 위해서는 id와 pw의 값에 "admin", "nimda"가 들어가면 될 것 같다.

이를 20번 인코딩, 치환 과정을 거쳐서 쿠키에 집어넣어 보자

 

 

// admin 인코딩 및 치환
var a = 'admin';
for (var i = 0; i < 20; i++) {
    a = btoa(a);
}
a = a.replaceAll('1', '!');
a = a.replaceAll('2', '@');
a = a.replaceAll('3', '$');
a = a.replaceAll('4', '^');
a = a.replaceAll('5', '&');
a = a.replaceAll('6', '*');
a = a.replaceAll('7', '(');
a = a.replaceAll('8', ')');
// nimda 인코딩 및 치환
var a = 'nimda';
for (var i = 0; i < 20; i++) {
    a = btoa(a);
}
a = a.replaceAll('1', '!');
a = a.replaceAll('2', '@');
a = a.replaceAll('3', '$');
a = a.replaceAll('4', '^');
a = a.replaceAll('5', '&');
a = a.replaceAll('6', '*');
a = a.replaceAll('7', '(');
a = a.replaceAll('8', ')');

id와 pw의 값을 온라인 base64 도구를 이용해

20번 수작업으로 인코딩하고 값을 치환할 수 있겠지만

힘든 작업이기에 이 과정을 수행하여 출력하는 javascript 코드를 짜보았다. 

 

 

개발자 도구의 콘솔창에서

javascript 코드를 실행하여

결과 값이 출력되었다.

 

 

해당 값을 개발자 도구의

쿠키 설정 부분에 입력했다.

 

 

그리고 문제 페이지를 새로고침 했더니

문제가 해결되었다.

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

[Webhacking.kr] old-10  (0) 2024.04.13
[Webhacking.kr] old-26  (0) 2024.04.13
[Webhacking.kr] old-16  (0) 2023.09.22
[Webhacking.kr] old-15  (0) 2023.09.17
[Webhacking.kr] old-17  (0) 2023.09.17

CSRF is an attack that allows an attacker to insert a script into a browser and exploit a user's authenticated session to request the server side for intended actions(remittance, product purchase, etc.). This is a problem that arises because certain web applications trust users.

 

 

 

Lab: CSRF vulnerability with no defenses

 

 

[Information]

 

 

 

[Problem solving]

1. I accessed the lab and logged in with the following account. "wiener:peter". Then I changed my email and grabbed it as a proxy.

 

2. I checked the POST request related to email change on the Logger tab of Burp Suite and right-clicked to access the CSRF PoC generation tool

 

The HTML code was copied from the CSRF PoC generator, pasted into the body part of the server attack-related page, and the attack was delivered after changing the viewer's email address.

 

The lab was solved.

XSS is an attack that can allow an attacker to insert a script into the target browser to execute arbitrary commands on the client side or steal user information such as cookies or sessions. This is a problem that occurs because users trust certain web applications.

 

 

 

Lab: Reflected XSS into HTML context with nothing encoded

 

 

[Information]

 

 

 

[Problem solving]

1. I found a search form in lab.

 

I have entered "alert()" function javascript code, and serched.

 

The lab was resolved with a warning window reading "You've been hacked".

 

Using javascript's alert function, I created a code as follows.

<!DOCTYPE html>

<head>
	<title>XSS</title>
</head>

<body>
<body background="C:/Users/image.jpg">
<script>alert("You've been hacked");</script>      <!-- alert() function javascript -->
	<h1 style="color:black">shad0w</h1>
	<ok background="C://User/image">
</body>

</html>

 

You can see the alert message.

 

And if you click the OK button, you'll see my nickname.

 

You can also use the alert() function script in the console window of the developer tool.


 

 

 

Lab: Stored XSS into HTML context with nothing encoded

 

 

[Information]

 

 

 

[Problem solving]

1. I checked that there was a section to write comments by accessing the lab and entering the post view. In the comments section I put the alert() script and uploaded it. 

 

The lab was solved.

'Educations > WhiteHat School' 카테고리의 다른 글

[WhiteHat School] 화이트햇 스쿨  (0) 2024.01.23
[과제] 컴퓨터구조 기초  (1) 2023.09.12
  • Problem path
  • Problem information
  • Problem solving

 

 

 

[Problem path]

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

 

what-is-my-ip

Description How are they aware of us even behind the wall? FYI Flag Location: /flag Flag Format: DH{...}

dreamhack.io


 

 

 

[Problem information]


 

 

 

[Problem solving]

1. When I connected to the problem server, my public IP address was displayed.

 

 

2. In the problem file, I checked the code in which the flag function was written in the root path part. Analyzing the code, you can see that the IP address is forwarded to the server to execute the desired shell command(for example: using '; ls' command to check the directory list) and capture and show the results fo the commands executed by the server.

 

 

3. I sent the request to the web server via curl as follows. The '-H' option is to add a request header, and "X-Forwarded-For" is one of the headers that carries the client's IP address to the server. And execute the "; cat /flag" shell command. That is, it functions to execute a shell command "; cat /flag" using the user's IP address and show the result to the user. It can be seen that the flag is derived as a result of the shell command as follows.

 

 

 

 

 

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

[Webhacking] php7cmp4re  (0) 2024.01.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

+ Recent posts