> For the complete documentation index, see [llms.txt](https://gitbook-88.gitbook.io/ctf-writeup/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook-88.gitbook.io/ctf-writeup/ba-chang/gong-fang-shi-jie/simple_js.md).

# simple\_js

```javascript
function dechiffre(pass_enc) {
        var pass = "70,65,85,88,32,80,65,83,83,87,79,82,68,32,72,65,72,65";
        var tab = pass_enc.split(',');
        var tab2 = pass.split(',');
        var i, j, k, l = 0, m, n, o, p = "";
        i = 0;
        j = tab.length;
        k = j + (l) + (n = 0);
        n = tab2.length;
        for (i = (o = 0); i < (k = j = n); i++) {
            o = tab[i - l];
            p += String.fromCharCode((o = tab2[i]));
            if (i == 5) break;
        }
        for (i = (o = 0); i < (k = j = n); i++) {
            o = tab[i - l];
            if (i > 5 && i < k - 1)
                p += String.fromCharCode((o = tab2[i]));
        }
        p += String.fromCharCode(tab2[17]);
        pass = p;
        return pass;
}
String["fromCharCode"](dechiffre("\x35\x35\x2c\x35\x36\x2c\x35\x34\x2c\x37\x39\x2c\x31\x31\x35\x2c\x36\x39\x2c\x31\x31\x34\x2c\x31\x31\x36\x2c\x31\x30\x37\x2c\x34\x39\x2c\x35\x30"));
h = window.prompt('Enter password');
alert(dechiffre(h));
```

修改

```javascript
function dechiffre() {
    var pass = "70,65,85,88,32,80,65,83,83,87,79,82,68,32,72,65,72,65";
    var tab2 = pass.split(',');
    var i, n, p = "";
    n = tab2.length;
    for (i = 0; i < n; i++) {
        p += String.fromCharCode(tab2[i]);
        if (i == 5) break;
    }
    for (i = 0; i < n; i++) {
        if (i > 5 && i < n - 1) p += String.fromCharCode(tab2[i]);
    }
    p += String.fromCharCode(tab2[17]);
    return p;
}
```

发现传入的值实际上是用不到的，无论输入什么样的密码都会报错。该段代码**实质**为输出报错信息。

删除这段函数后，真正的密码在**fromCharCode**中，截取下来转译为数字，在通过Ascii码得到flag。y

```python
array = [55, 56, 54, 79, 115, 69, 114, 116, 107, 49, 50]
string = ""
for i in array:
    char = chr(i)
    string += char
print(string)
```


---

# 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://gitbook-88.gitbook.io/ctf-writeup/ba-chang/gong-fang-shi-jie/simple_js.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.
