> For the complete documentation index, see [llms.txt](https://docs.cooku222.kr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cooku222.kr/security/web-hacking/webhacking.kr/webhacking.kr-old-24.md).

# \[webhacking.kr] old-24

<figure><img src="https://blog.kakaocdn.net/dna/TRXEW/btsOt8XdS6w/AAAAAAAAAAAAAAAAAAAAAPx_LxQch1Y_2_mpouYpy84aNlcuJyiAFErLyxV5XSkr/img.png?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=XTHEqfPlxT52rd6DjO6RpaUVhQo%3D" alt="" height="281" width="1505"><figcaption></figcaption></figure>

extract($\_SERVER);\
extract($\_COOKIE);\
$ip = $REMOTE\_ADDR;\
$\_SERVER, $\_COOKIE를 extract()로 변수화하고 있음.\
\
REMOTE\_ADDR는 기본적으로 사용자의 실제 IP를 나타내지만, $\_COOKIE에도 같은 키(REMOTE\_ADDR)가 있으면 덮어씀.

$ip = htmlspecialchars($REMOTE\_ADDR);\
$ip = str\_replace("..",".",$ip);\
$ip = str\_replace("12","",$ip);\
$ip = str\_replace("7.","",$ip);\
$ip = str\_replace("0.","",$ip);\
".." → ".", "12" → "", "7." → "", "0." → "" 순서로 문자열을 조작함.

```
<?php
  include "../../config.php";
  if($_GET['view_source']) view_source();
?><html>
<head>
<title>Challenge 24</title>
</head>
<body>
<p>
<?php
  extract($_SERVER);
  extract($_COOKIE);
  $ip = $REMOTE_ADDR;
  $agent = $HTTP_USER_AGENT;
  if($REMOTE_ADDR){
    $ip = htmlspecialchars($REMOTE_ADDR);
    $ip = str_replace("..",".",$ip);
    $ip = str_replace("12","",$ip);
    $ip = str_replace("7.","",$ip);
    $ip = str_replace("0.","",$ip);
  }
  if($HTTP_USER_AGENT){
    $agent=htmlspecialchars($HTTP_USER_AGENT);
  }
  echo "<table border=1><tr><td>client ip</td><td>{$ip}</td></tr><tr><td>agent</td><td>{$agent}</td></tr></table>";
  if($ip=="127.0.0.1"){
    solve(24);
    exit();
  }
  else{
    echo "<hr><center>Wrong IP!</center>";
  }
?><hr>
<a href=?view_source=1>view-source</a>
</body>
```

editthiscookie로 쿠키값을 변경한 후 필터링을 우회한다. -> 127.0.0.1이 되는 값을 구한다.

<figure><img src="https://blog.kakaocdn.net/dna/by83Yg/btsOwhdXnlq/AAAAAAAAAAAAAAAAAAAAAJSDdGIRjb7qx-WDgzuew-SugfC5v_6dpRnItoJ5iDOW/img.png?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=srPjJvicOjQGr7Qs8SCUO98Rzx4%3D" alt="" height="343" width="997"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cooku222.kr/security/web-hacking/webhacking.kr/webhacking.kr-old-24.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
