Web Fundamentals
For complete tryhackme path, refer the link
Task 5 - CTF
References
Intro
The course is well designed and we would need less help. However, if some things are not clear or need some hints, proceed further.
There are four tasks,
- To use curl GET reqest
- To use curl POST request
- To use curl and get cookie
- To use curl and set cookie
GET request
Deploy the machine and use curl to get the result.
curl http://<ip>:8081
Check if the web page response is obtained. This would be similar to ,
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="main.css">
<script src="main.js"></script>
</head>
<body>
<h1>Flags:</h1>
<ul>
<li>GET request. /ctf/get</li>
<li>POST request. /ctf/post</li>
<li>Get a cookie. /ctf/getcookie</li>
<li>Set a cookie. /ctf/sendcookie</li>
</ul>
</body>
</html>
Use the following curl command to get the flag.
curl http://<ip>:8081/ctf/get
POST request
Use the following curl command to send a POST request.
curl --data "flag_please" http://<ip>:8081/ctf/post
Get cookie
Use the following curl command to get cookie.
curl -c cookie.txt http://<ip>:8081/ctf/getcookie
The downloaded cookie in cookie.txt contains the flag, similar to,
# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
<ip> FALSE / FALSE 0 flag <flag>
Send cookie
Use the following curl command to send custom cookie.
curl -b "flagpls=flagpls" http://<ip>:8081/ctf/sendcookie
The response contains the flag.