Post

Cookie Arena Writeup: NSLookup_1

Short summary of the post.

Cookie Arena Writeup: NSLookup_1

Overview

Ta có mã của nó:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
  include_once('./ignore/design/design.php');
  $design = Design(__FILE__, 'NSLookup Tool');

  if (isset($_GET['domain'])) {
    $domain = $_GET['domain'];
    $result = shell_exec("nslookup $domain");
  }
?>
<html>
  <head>
    <title>NSLookup Tool</title>
    <style>
      .output {
        width: 40%;
        border: 1px solid #ccc;
        padding: 10px;
        margin-top: 10px;
      }
    </style>
  </head>
  <body>
    <?php if(strlen($result) > 0) { ?>
    <div class="output">
      <h2>NSLookup Result</h2>
      <pre><?php echo $result; ?></pre>
      <a href="/index.php">Back</a>
    </div>
    <?php } else { ?>
    <div>
        <h2>NSLookup Tool</h2>
        <form action="/index.php" method="GET">        
            <div class="form-group">
                <label for="domain">Domain</label>
                <input type="text" class="form-control" id="domain" name="domain">
                <button type="submit" class="btn btn-primary">LOOKUP!</button>
            </div>
            
        </form>
    </div>
    <?php } ?>

    <div>
      <?php echo $design; ?>  
    </div>    
  </body>
</html>

Tại dòng thứ 6, ta có hàm shell_exec được dùng để thực hiện nslookup, điều ta có thể khai thác được server nhờ đoạn code này là: nó không validate input cho domain:

1
2
3
4
if (isset($_GET['domain'])) {
    $domain = $_GET['domain'];
    $result = shell_exec("nslookup $domain");
  }

Exploitation

Payload chỉ đơn giản vậy thôi là ăn rồi 💀

Discover server để tìm flag thôi

Conclusion

Bài này khá đơn giản nên chắc không có conclusion nào đâu, hehe 😀

Happy hacking

This post is licensed under CC BY 4.0 by the author.