> 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/dreamhack/dreamhack-amocafe.md).

# \[Dreamhack] amocafe

#### 문제 링크

<https://dreamhack.io/wargame/challenges/899>

#### 문제

<figure><img src="https://blog.kakaocdn.net/dna/mGbqH/btsEdJFYSJB/AAAAAAAAAAAAAAAAAAAAAMAFNXW8x4AH6ZZ1f0D8VucCZ6Dm3NiI9fhUPlOtudoq/img.jpg?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=bXj8vZ%2FMoHHJRjGbdaKinTKvymM%3D" alt="" height="422" width="1022"><figcaption></figcaption></figure>

&#x20;

#### 풀이

<figure><img src="https://blog.kakaocdn.net/dna/brM9tc/btsEbBaMFNA/AAAAAAAAAAAAAAAAAAAAAOEPCr7Uo1lHD21QbtJ62fono7zk-M6-rX0dxroLlMbQ/img.jpg?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=nW94Dvdb1UPfroDIesCOM26NBPU%3D" alt="" height="402" width="557"><figcaption></figcaption></figure>

웹에 접속하면 이런 화면이 펼쳐진다. 막막하므로 코드를 살펴본다.&#x20;

<figure><img src="https://blog.kakaocdn.net/dna/bc2x9T/btsEbA3ZIZs/AAAAAAAAAAAAAAAAAAAAAAg22pmJo55PdwiXV9kJPcPyJ1EkazBOthDesKWdsPMW/img.jpg?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=Po1yiBpikvdvZ%2By%2BlUFlKJr4ZUs%3D" alt="" height="247" width="422"><figcaption></figcaption></figure>

일단 이 부분 코드부터 보면, 비트연산자가 쓰여서 16진수를 2진수로 바꿔서 생각을 할 수 있어야 하는 문제라는 것을 알 수 있다.\
코드를 파이썬으로 직접 짜는 방법도 있으나, 나는 여기서 직접 역연산을 하는 방법을 택했다.\
1\. 우선 사이트의 \_를 알려면 여기서 \~res & 0xf == 0x4 라는 것을 풀어야 하는데, 0xf, 0x4는 16진수로 쓰여있으므로 2진수로 바꾸면 \~res & 1111 == 0100\
res == 1011\
2\. 모두 16진수에서 2진수로 변환\
1 => 0001\
c => 1100\
3 => 0011\
0 => 0000\
f =>1111\
e =>1110\
이제 이걸 연달아서 입력해주면\
0001/1011/1100/1011/0011/1011/1100/1011/0000/1011/1011/1111/1111/1011/0011/1100\
\=> 0001101111001011001110111100101100001011101111111111101100111100\
여기서 끝나는게 아닌데, 윗부분 코드에

<figure><img src="https://blog.kakaocdn.net/dna/ewncKH/btsEf5VRF37/AAAAAAAAAAAAAAAAAAAAAObVObkxKrkdeJNQttVg2fga2hj61ZzTDk7LbGiqH6Sv/img.jpg?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=cID51bRSjayF5cbjrQ75tX%2F9518%3D" alt="" height="128" width="331"><figcaption></figcaption></figure>

이런 부분이 있다. int형으로 변환을 시켜주라는 것이다. \
따라서 위에 입력된 2진수 값을 int형을 변환을 시켜주면(int형은 기본이 10진수이므로 쉽게 말하면 10진수로 변환을 시켜주는 것이다.)\
2002760202557848382 \
가 나온다.\
이를 프롬프트에 입력해주면

<figure><img src="https://blog.kakaocdn.net/dna/bnVQQu/btsEfuBrG0u/AAAAAAAAAAAAAAAAAAAAAAGFzMF8gCH1w22tb1b2vsubirQi7Cgio8E5y1gCtHrf/img.jpg?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=p4oaB8JIQ8fogxLdH5RXeI3mZCw%3D" alt="" height="447" width="507"><figcaption></figcaption></figure>

<figure><img src="https://blog.kakaocdn.net/dna/bNaI2r/btsEdNIupeN/AAAAAAAAAAAAAAAAAAAAADN718s3GtrjzQj3R5LY-rePYFJfkrHp1EBHgHDOGTyp/img.png?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=eu%2FZB1NsVBnHMkx0RR17v%2F7VgoU%3D" alt="" height="148" width="681"><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/dreamhack/dreamhack-amocafe.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.
