How do I send a C program string to the su password prompt?

I changed the default ubuntu root password:

sudo passwd

      

Now I am developing a C program to force a password. I use system()

to call su

But su

asks for the password directly in the terminal ... I want to automate this procedure and automatically enter the password ... My current code is:

#include <stdlib.h>
main()
{
    system("su");
}

      

but this asks for a password ... I want to automatically provide a password in the program so that it su

does not ask for a password. Any ideas ??????

+3


source to share


2 answers


First, you are probably wrong. The correct way to hack the superuser account on a Linux / Unix system is to iterate over the hashes in / etc / passwd.

However, if you want to do it with system commands, you can use sudo -S and pass the STDIN password.



The reason this doesn't work with su

is because it is prohibited because it is inherently insecure and dangerous, so su

it doesn't even use STDIN.

+2


source


Use sucrack.

Su is trying to enforce TTY use. Simplified TTY means "actually a user in a teletype terminal", not a script. But then again, all of its software and all of it can be emulated. The surackck kernel is "PTY", (again simplified) "pseudo televic terminal", which looks identical to the software (su).



In short, he can magically enter passwords and tell you if he finds the password.

Sucrack is available as an ubuntu package which will require you to install root (which you don't have). So the alternative is to compile a static version of sucrack on another system and upload it to the server. It is doable. Hackers do this all the time;)

0


source







All Articles