Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added README.md file instead of the TXT file #185

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Linux/SUID/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## SUIDs, SGIDs, and Sticky Bits

In Linux, file permissions are given in 3 categories: owner, group, and other users. And on top of that, special permissions like SUID, SGID, and Sticky Bits are given to those categories respectively.

**SUID** -> `Set User ID` -> Helps running a program as another user than the one executing it
**SGID** -> `Set Group ID` -> Helps running a program as another group permission than the one the user executing it is a part of.
**Sticky Bits** -> Used to set delete permissions over a directory. Only file owner, directory owner or root can delete it.

For setting SUID, SGID, and Sticky bits, there are numeric notations:

SUID -> 4 -> u+s
SGID -> 2 -> g+s
Sticky bit -> 1 -> o+t

- SUID is set on owner. It can't be set on other 2 categories.
- SGID is set on group. It can't be set on other 2 categories.
- Sticky is set on others. It can't be set on other 2 categories.

chmod 4222 filename
4 -> SUID
222 -> Respective file permissions for the 3 categories.

## Using with chmod
chmod u+s filename -> Used to set SUID over a binary file
chmod g+s filename -> Used to set SGID over a binary file
chmod o+t filename -> Used to set sticky bits over a directory

-rwsr--r-- : s bit is for SUID set bit + having executable file permission (x).
-rwSr--r-- : S bit is for SUID set bit and no executable file permission.
-rw-r-sr-- : s bit is for SGID set bit + having executable file permission (x).
-rw-r-Sr-- : S bit is for SGID set bit and no executable file permission.
-rw-r--r-T : T bit is for Sticky bit
30 changes: 30 additions & 0 deletions Linux/etc-passwd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# /etc/passwd file
```bash
sabyasachi@h0tPlug1n:~$ cat /etc/passwd

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
...
sabyasachi:x:1000:1000:Sabyasachi Paul,,,:/home/sabyasachi:/bin/bash
sssd:x:127:137:SSSD system user,,,:/var/lib/sss:/usr/sbin/nologin

This file has user account information. It is divided into 7 sections
In order, these fields are:

```
- The username (root)
- The user's password hash. In most cases the hash will not actually be given here and instead will be replaced with an `x`. This means that the hash can instead be found in `/etc/shadow`.
- The user's UID (User ID) — as the root user, this is 0.
- The user's GID (Group ID). For the root user this will also be 0.
- A description of the account. This is simply "root" in the example, however, it can be left blank.
- The user's home directory (/root)
- The user's login shell (/bin/bash)

e.g.: `user1`:`$1$123$LZ9RzzZZaryI4vY3ZLGhN0`:`0`:`0`:`iamroot`:`/root`:`/bin/bash`

*If we can manually form our own entry (including a full password hash) and insert it into the passwd file then we can create a new user account. Interestingly, Linux doesn't check to confirm that the UID and GID of an account are unique — only that usernames are unique. In other words, we can create an account with our own unique username that has a UID and GID of 0, effectively giving our new account the same permissions as the root account!*