So found 3 open ports , 22(SSH), 80(HTTP) , 3000(HTTP) with Node.js , Opening port 80 it had a landing page which was titled Dump Docs , and both were also there on port 3000 with a file named files.zip attached which contains the source code of how the api works
Downloaded the files.zip and extracted it getting a folder named local-web
, where inside it we have validation.js
and I also noticed the .git
folder then I realized it's a git repo , so now I decide to type in git show
And I got this line of code which does validation with if the username is 'theadmin' then I have admin privs , meaning I can access /logs
and /privs
, So I now decide to write a script which will register a user to the api on port 3000 :
So now then since it's already registered I decided to add another function on my script which will allow me to login with the registered creds:
So the login()
function will log us in , using our creds , and then it will check what privileges we have and it will dump us a jwt token, YES! a JWT Token , now that I realized we have JWT Tokens related with this whole thing , I now decide to dump the .git
folder using Dumper from GitTools , and after dumping whole those dumps, I decided to take a look at each .env file inside those dumps and at last I was able to get the jwt secret key used:
Now since I have the key , I try checking the contents of the jwt token like what's inside it? and all that like the parameter and all that..
So now it rings on my mind , that the name with the highest privilege is theadmin
so since i have the key all I can do now is to just change the name with this command:
and that should give us our generated signed new token for the admin:
I now decided to get back to the source codes and found a file named private.js
which is really interesting:
const getLogs = git log --oneline ${file}
this can allow us to perform command injection , by adding ;<command to execute>
at the ?file=
, so I rewrote my exploit which will now have a function named forge()
which will allow me to perform execute my revshell that I hosted from my localhost using http.server
module and then will allow me to get reverse shell:
Ran the exploit and boom!!!
So first thing I do now is to check for files with SUID perms for root:
Luckily I found one binary named count
inside /opt/count
which also had a source code in the same folder, the source code was written in C :abc:
I mean I understand what was in it , it's like we could write something or read something but not in higher privileged files or contents , so I now decided what if I try read a file root.txt
and in between the process of the binary running I crush it purposely , now see when a program is crushed in between it's execution time, the crash log is saved to /var/crash
, So theoretically and technically the flag should be inside the crash logs, and it'll produce the crashdump because it is set to produce the core dumps!
So I made two shell instances , one shell instance will be used to run the count
binary before we crash it with the other shell instance.
I also noticed it's taking time to output the result of the binary running:
So I guess as I run it I have to type y
before I crush it so as the results are saved lol
ON SECOND TERMINAL :
I now crash that PID
and there it is crashed
and now reading from the file CoreDump
we see the flag using the command strings CoreDump
: