Wednesday, May 9, 2012

fake root

Well guys, you must know that root is supreme master of the unix operating systems like Linux, Hurd, Solaris, HP-UX, BSDs, AIX and there still many of them. root account is lord of the system where any other accounts are under its orders, rules, legacy and/or policy.

root is identical to UID 0 and any other accounts with different various UID number from 1 to 65535 in Linux. Maximum number of UIDs depends on the flavor of the operating systems. Let's take a look at our sample /etc/passwd


root:x:0:0::/root:/bin/bash
bin:x:1:1:bin:/bin:/bin/false
daemon:x:2:2:daemon:/sbin:/bin/false
adm:x:3:4:adm:/var/log:/bin/false
lp:x:4:7:lp:/var/spool/lpd:/bin/false
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/:/bin/false
news:x:9:13:news:/usr/lib/news:/bin/false
uucp:x:10:14:uucp:/var/spool/uucppublic:/bin/false
operator:x:11:0:operator:/root:/bin/bash
games:x:12:100:games:/usr/games:/bin/false
ftp:x:14:50::/home/ftp:/bin/false
smmsp:x:25:25:smmsp:/var/spool/clientmqueue:/bin/false
mysql:x:27:27:MySQL:/var/lib/mysql:/bin/false
rpc:x:32:32:RPC portmap user:/:/bin/false
sshd:x:33:33:sshd:/:/bin/false
gdm:x:42:42:GDM:/var/state/gdm:/bin/bash
apache:x:80:80:User for Apache:/srv/httpd:/bin/false
messagebus:x:81:81:User for D-BUS:/var/run/dbus:/bin/false
haldaemon:x:82:82:User for HAL:/var/run/hald:/bin/false
pop:x:90:90:POP:/:/bin/false
nobody:x:99:99:nobody:/:/bin/false

each value is delimited by a colon. Well let's focus on the first line because this is what we are gonna learn.

root:x:0:0::/root:/bin/bash

the first value is root that means this is the name of account.
the second value is x which means that the password is encrypted and the encrypted password is encrypted password is located on /etc/shadow. the third one is User Identity (UID). the fourth is group Identity (GID). the fifth is description of the account and in this case we have no description. the sixth is the home directory and the seventh is the default shell for the account.

then let's make a user account and assign a password to it. let's call it "fruit".

useradd fruit
passwd fruit

let's change the fruit UID and GID to 0 and (zero) and root UID to 100 and GID to 1000. fruit has taken all the privileges that root once had

No comments:

Post a Comment