Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I saw this problem in an online hacking competition. The question asked us to print the contents of the file "secret"

bruce@ip-10-144-4-86:/home/hacker-weekly$ ll
total 20
drwxr-xr-x   2 hacker-weekly hacker-weekly  4096 Nov 12 19:19 ./
drwxr-xr-x 222 root          root          12288 Dec 27 06:27 ../
-r--r-----   1 root          secret          373 Nov 12 19:19 secret

bruce@ip-10-144-4-86:/home/hacker-weekly$ stat secret
  File: `secret'
  Size: 373             Blocks: 8          IO Block: 4096   regular file
Device: ca01h/51713d    Inode: 141569      Links: 1
Access: (0440/-r--r-----)  Uid: (    0/    root)   Gid: ( 1004/  secret)
Access: 2012-11-24 13:14:40.942961879 +0000
Modify: 2012-11-12 19:19:51.079654457 +0000
Change: 2012-11-12 19:19:51.079654344 +0000
 Birth: -

bruce@ip-10-144-4-86:/home/hacker-weekly$ getent group secret
secret:x:1004:guest

bruce@ip-10-144-4-86:/home/hacker-weekly$ cat /etc/issue
Ubuntu 12.04.1 LTS \n \l

bruce@ip-10-144-4-86:/home/hacker-weekly$ groups
bruce

bruce@ip-10-144-4-86:/home$ netstat -tulen
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          7287
tcp6       0      0 :::22                   :::*                    LISTEN      0          7289
udp        0      0 0.0.0.0:68              0.0.0.0:*                           0          6522

PS - I can gather other information also if you tell me what command to run on shell

share|improve this question

1 Answer 1

There is no official way to access a file if its permissions do not allow you to do so. Any such possibility would be a (severe) bug in the OS. So there's no magic command which reads such files or, say, a magic switch for some command:

cat --ignore-permissions /home/hacker-weekly/secret

That's why it is called a competition - you need to work around the OS security machinery or find a mis-configuration of the machine which would allow you to access the file.

In this case, I think, the give-away is the guest user which is in the secret group - I think you need somehow to become guest.

If you had physical access to the machine, you could also reboot into a single-user mode or unplug the hard drive and put it into another machine.

share|improve this answer
    
I have been racking my brains on this problem for days. I can't take it anymore. I don't have physical access to the machine. If I do su -c "cat secret" guest it asks for a password which I don't have. –  Bruce Dec 28 '12 at 0:12
1  
@Bruce: That's the whole point of such competitions - you won't find a solution in a manual. It's like a brainteaser :) One (rather naive) option to try is to search for SUID/SGID scripts in the system which might give you access to the file... –  Sergey Dec 28 '12 at 0:25
    
Tried find / -xdev -type f -perm +g=s -print and find / -xdev -type f -perm +u=s -print. Got no files/scripts. –  Bruce Dec 28 '12 at 0:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.