PIE (地址无关程序编译)
gcc -fPIE -pie -o x random.c
每次执行,变量的的地址均会变
readelf -h x | grep Type
Type: DYN (Shared object file)
(1)
echo $SHLVL
查看当前shell的层次,Incremented by one each time an instance of bash is started
(2) usermod
-c, --comment COMMENT new value of the GECOS field
-d, --home HOME_DIR new home directory for the user account
-e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-f, --inactive INACTIVE set password inactive after expiration
to INACTIVE
-g, --gid GROUP force use GROUP as new primary group
-G, --groups GROUPS new list of supplementary GROUPS
-a, --append append the user to the supplemental GROUPS
mentioned by the -G option without removing
him/her from other groups
-h, --help display this help message and exit
-l, --login NEW_LOGIN new value of the login name
-L, --lock lock the user account
-m, --move-home move contents of the home directory to the
new location (use only with -d)
-o, --non-unique allow using duplicate (non-unique) UID
-p, --password PASSWORD use encrypted password for the new password
-R, --root CHROOT_DIR directory to chroot into
-s, --shell SHELL new login shell for the user account
-u, --uid UID new UID for the user account
-U, --unlock unlock the user account
-Z, --selinux-user SEUSER new SELinux user mapping for the user account
(3) real uid 和 effective uid
real uid 是指用户登陆系统时所具有的身份信息,可以通过setuid, 或者setresuid在程序中设置。
effective uid是指程序执行的过程中所带有的身份信息, 系统检查权限时根据此信息来判断权限是否达到要求, 然后进一步执行程序。
(4)set uid (u+s), 和 set gid (g+s)
setuid程序执行时具有程序所有着的权限。也就是说,root的一个可执行程序(比如:passwd),如果setuid以后,test用户运行时,具有root的权限。
setgid作用与文件时,跟setuid类似,临时拥有的组权限与拥有着的组一样。
segid作用于目录时,在该目录下所建的文件组与目录的组保持一致。如果没有设置该标志位, 所建的文件、目录组信息就是创建着的组信息。
(5)修改软件源
http://www.annhe.net/article-614.html
(6)查看gcc预定义的变量
touch foo.h
gcc -E -dM -c foo.h
ANSI C标准中有几个标准预定义宏(也是常用的):
__LINE__:在源代码中插入当前源代码行号;__FILE__:在源文件中插入当前源文件名;
__DATE__:在源文件中插入当前的编译日期
__TIME__:在源文件中插入当前编译时间;
__STDC__:当要求程序严格遵循ANSI C标准时该标识被赋值为1;
__cplusplus:当编写C++程序时该标识符被定义。
(7)常用命令集合
根据文件名,查找文件
find ./ -name "*"
根据关键词,查找文件
grep -rn "*" ./
sizeof
http://blog.csdn.net/wanfustudio/article/details/705674
修改Linux命令提示符
编辑/etc/profile,文件末尾添加ps1的值
export PS1='[\u@\h \w]\$'
u:user
h:host
w:当前用户路径用~代替
W:只显示最后一个路径名