# Ancient History

## Problem

> I must have been sleep hacking or something, I don't remember visiting all of these sites... <http://mercury.picoctf.net:45211/> (try a couple different browsers if it's not working right)

## Solution

1. Visiting the website just shows "Hello World!", but viewing the source shows a lot of obfuscated JavaScript.
2. The browser history shows that the JavaScript performs some redirects where the URL parameter is a single character of the flag.
3. The issue is that visits to a page with the same character as the parameter are collapsed on the history page of modern browsers. So, let's try deobfuscating the code using [JSNice](http://jsnice.org/).
4. Interestingly, the actual changes to the history (`window.history.pushState`) are made in the clear. Therefore, the obscuration is a meaningless distraction.
5. Let's search the page HTML using a regular expression `urlpath:.\/index\.html\?.` and then combine the last character of all matches using a Python [script](https://github.com/HHousen/PicoCTF-2021/blob/master/Web%20Exploitation/Ancient%20History/script.py).

### Flag

`picoCTF{th4ts_k1nd4_n34t_0b0a1adf}`


---

# Agent Instructions: 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://picoctf2021.haydenhousen.com/web-exploitation/ancient-history.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.
