"Permission Denied" as root when moving files
Using sudo
on the RPISEC-MBE virtual machine, I have mounted and copied my files that were on a USB flash drive to an admin folder (that I have access to). Unfortunately, even with sudo
I can't seem to copy them to the /levels/lecture
directory. Why is it not letting me copy those files in, even as root?
gameadmin@warzone:~$ mkdir /media/usb ; sudo mount /dev/sdb1 /media/usb
gameadmin@warzone:~$ ls -l /media/usb/rpisec
total 32
drwxr-xr-x 2 root root 16384 Jun 7 15:41 bombs
drwxr-xr-x 2 root root 16384 Jun 7 15:41 crackme
gameadmin@warzone:~$ sudo cp -R /media/usb/rpisec/* /home/gameadmin/
gameadmin@warzone:~$ ls -l /home/gameadmin
total 8
drwxr-xr-x 2 root root 4096 Jun 7 15:42 bombs
drwxr-xr-x 2 root root 4096 Jun 7 15:42 crackme
gameadmin@warzone:~$ ls -l /levels/lecture
total 28
drwxr-xr-x 2 root root 4096 Jun 21 2015 aslr
drwxr-xr-x 2 root root 4096 Jun 21 2015 cpp
drwxr-xr-x 2 root root 4096 Jun 21 2015 format_strings
drwxr-xr-x 2 root root 4096 Jun 21 2015 heap
drwxr-xr-x 2 root root 4096 Jun 21 2015 misc
drwxr-xr-x 2 root root 4096 Jun 21 2015 rop
drwxr-xr-x 2 root root 4096 Jun 21 2015 shellcode
gameadmin@warzone:~$ sudo mv /home/gameadmin/* /levels/lecture/
mv: cannot move '/home/gameadmin/bombs' to '/levels/lecture/bombs': Permission denied
mv: cannot move '/home/gameadmin/crackme' to '/levels/lecture/crackme': Permission denied
Solution 1:
From the documentation:
The warzone marks many files as immutable to prevent users from changing them and ruining the game for other players. For example, we don't want the lab2B user to delete its .pass file or /levels files. A few system files, such as /etc/passwd, are also marked immutable.
If you would like to modify or delete these files simply remove the immutable flag:
chattr -i filename
We recommend that you add the flag back when you are done making your changes:
chattr +i filename
File immutability is a wonderful thing in many circumstances. If you have the opportunity, learning how to use these can save you a lot of headache later 👍🏻