This is a theoretical question. What if I run those commands with correct privileges? How could I restore su and sudo?
Neither of these binaries are required to reinstall the packages - so you simply need to gain root access and reinstall the packages containing those binaries with
yum or what ever package manager your system uses - there should be no need to do anything more dramatic then that.
The trick is gaining root access. This is trivial if the root account is unlocked and you know the password (which if you were using
su then you do). At which point just log into the system as root and reinstall the packages.
If you do not have root access then you can try to reboot into recovery mode if your distro has that enabled - if so it will give you a root prompt which you can reinstall the required packages.
If you cannot get recovery mode to work or it is not enabled then you need to boot a live cd. Once booted with a live cd you can mount the root filesystem of your system somewhere, chroot into it and reinstall the packages that way. Such as:
cd /location/of/new/root mount -t proc proc proc/ mount --rbind /sys sys/ mount --rbind /dev dev/ cp /etc/resolv.conf etc/resolv.conf chroot /location/of/new/root /bin/bash # <install packages here>
Log onto console as root,
/usr/bin/sudo from a "known, good" neighboring server.
If root access is available via SSH, then restore the binaries from another server (or upload the two files from the latest backup - you did backup your system, didn't you? - on any suitable server and download them from there):
ssh root@woundedserver "cd /usr/bin; wget http://myamazonserver/files/su; chmod 4755 su" or scp /usr/bin/su root@woundedserver:/usr/bin # I never remember whether scp preserves permissions, so just to be sure: ssh root@woundedserver "chmod 4755 /usr/bin/su" or even (I just tried, the md5sums match after the copy) cat /a/good/su/binary | ssh root@woundedserver "cat >/usr/bin/su; chmod 4755 /usr/bin/su"
If root isn't allowed to SSH in, or you disabled that possibility or closed the SSH port too, I suspect the only way is booting with the init "hack", or boot from a rescue CD. That ought to work.
If you also secured GRUB and maybe encrypted the filesystem, either wait for an exploitable vulnerability to be discovered, or reinstall everything from the latest backup. You did backup your system, didn't you? :-)