October 16, 2016

The relation between SetUID and setresuid when a shell is executed


[Configuration 1] Asw3's source code is same as the image above. Asw7's source code is same as the image above but it doesn't have setresuid and setresgid. 
[Configuration 2] SetUID(→UID 996 = flag03) is set in Asw3 and Asw7.




[Case of using setresuid] If the Asw3 is executed, the effective UID(flag03=UID 996) is printed according to SetUID special privilege. /bin/bash becomes a child of the Asw3.




[Case of not using setresuid] If the Asw7 is executed, the effective UID(flag03=UID 996) is printed according to SetUID special privilege, but /bin/bash is executed with the authority of the level03 according to SetUID special privilege. The Asw7 process is terminated.