Official Compromised Discussion

@sparkla said:

I managed to get a real shell afterwards but user.txt wasn’t in the location shown by the locate command. Not sure if that was intended or another “user manipulation”, it was very late so I didn’t reset the box to check again.

The user flag is where it should be. I suspect that if you aren’t in the right account you can’t see it.

@sparkla said:

Try

locate user.txt

Maybe that helps to understand my question.

I will tomorrow.

Keep in mind, locate does a search in the updatedb database - it will only find files that are stored in the db. It is often not as effective as a find command.

For example find / -name "user.txt" 2>/dev/null would, in most situations be a better choice. (I have no idea if it would work on this box, I never tried it). File permissions can affect both.

I have never been so stuck in my entire life :joy:

@sparkla said:

Try

locate user.txt

Maybe that helps to understand my question.

Ok - so having tried this I might have a better idea what you mean.

Somethings to consider:

  • locate is (at least in my experience) really hit and miss. It frequently misses file on my local system because I dont keep the database up to date.
  • each user account has set privs, if the account you are in doesn’t have privs to see the file, you might not be able to find it with other tools. Keep in mind what account is being used by which “exploit.”
  • If you use the second account via the first bit, the output is muddy so it isn’t great for broad searching (targeted enumeration still works).

On this box, there is no need to hunt the flags. They are exactly where they should be.

@sparkla said:

@TazWake that is exactly the reason why I was asking myself if someone manipulated the box. Locate shows the past, I don’t know which past.

Ah, interesting. When I ran locate just now it returned nothing! :smile:

In my case locate showed user.txt should be in home of my***. But it wasn’t.

It should be. If it isn’t someone messed with your box.

EDITED TO ADD:

I am sorry, I’ve realised I might have added to the confusion here because I wasn’t paying enough attention to detail in my replies.

Hopefully, this is cleared up now.

Type your comment> @sparkla said:

@TazWake Edit: Posts were timed badly. Now you answered my questions, thanks.

Awesome - I think I understand at last!

Hopefully, we are communicating on the same frequency now :smile:

It is a crying shame that so many people think it is funny/clever to break the boxes for other people. I wish more Linux boxes set the immutable flag on the flags.

Got user, wasn’t so much hard as it was I had never used this method before and couldn’t find anything online about it. Thanks to @TazWake for walking me through the second half with the S** service trickery.

Onto root, from what I see on this thread this will certainly go over my head. I have 0 knowledge of reversing… should be interesting.

Been increasing the difficulty over the past 2 weeks, Unbalanced was a cakewalk but this is definitely my max.

Edit: Starting the 6 hr ghidra crash course lol wish me luck

Really interesting box! I have learned a few news things!!
Thanks for the hints and Congrats @D4nch3n !

Pm if you need a small nudge :wink:

How did you guys transfer the interesting file back over to your local macine? scp hangs when I try to connect back to my personal ssh server

Netcat worked for me, but YMMV.

Type your comment> @LMAY75 said:

How did you guys transfer the interesting file back over to your local macine? scp hangs when I try to connect back to my personal ssh server

A lot of ways are there! Scp, Nc, Pyserver, need more? Google it.

Type your comment> @gunroot said:

Type your comment> @LMAY75 said:

How did you guys transfer the interesting file back over to your local macine? scp hangs when I try to connect back to my personal ssh server

A lot of ways are there! Scp, Nc, Pyserver, need more? Google it.

scp wasnt working at first, so I thought there might be another way. Ended up getting it working though thanks!

@LMAY75 for scp you need a valid SSH creds to work. Otherwise it won’t as it comes with a part of SSH. Try NC or Pyserver for easy file distribution.

Type your comment> @gunroot said:

@LMAY75 for scp you need a valid SSH creds to work. Otherwise it won’t as it comes with a part of SSH. Try NC or Pyserver for easy file distribution.

No I ended up getting scp to work. It was just hanging at first.

root@compromised:~# id
uid=0(root) gid=0(root) groups=0(root)

■■■■ yea!

DM me if you need any hints. Most satisfying root possibly ever, very proud of myself there :joy:

Good suggestion from @sparkla - people often overlook how effective Base64 can be in transferring files between systems.

However if ssh from you to the box works, so should scp as it is basically the same protocol. If ssh works but scp fails, there is a good chance something on the box is broken.

@sparkla said:

SSH from box to me doesn’t work as well. I suspect either broken or on purpose to prevent usage of nc (and enforce the intended route) in the early stage of foothold.

Rumour has it (and I certainly haven’t even tried to confirm this yet) but SSH from HTB boxes to user machines is prevented.

You should be able to use SSH/SCP from your machine to this box though.

Couldn’t spot the privesc, nudge welcome.

Its difficult to avoid spoilers. I’d start with thinking about this as a compromised device, and looking for things the attacker might have done to allow themselves back in.

Type your comment> @sparkla said:

SSH from box to me doesn’t work as well. I suspect either broken or on purpose to prevent usage of nc (and enforce the intended route) in the early stage of foothold.

Couldn’t spot the privesc, nudge welcome.

DM me if you still need the nudge for privesc

@sparkla said:

My english must be really bad.

But apart from that (and the fact that I have no idea who “Rumour” is and why he 'has it")

This is the rumour: Official Buff Discussion - #746 by he77kat - Machines - Hack The Box :: Forums

This may be why your SSH isn’t working from the box to your machine. It may not be. YMMV.

I take away the PrivEsc must be super easy and I just looked the wrong way.

PrivEsc on this box is not easy.

@TazWake said:
This is the rumour: Official Buff Discussion - #746 by he77kat - Machines - Hack The Box :: Forums

This may be why your SSH isn’t working from the box to your machine. It may not be. YMMV.

FYI if anyone is stuck on this. Edit /etc/ssh/sshd_config and change “Port” to anything you want. SSH is only blocked on the standard port. I still wouldn’t recommend leaving it enabled though, just start it when you need and stop it afterwards:
systemctl start/stop ssh