[Solved] change any linux user password using c++


All is possible in this way -> to make c++ code which change password I done this:

  • Password must be encrypted, so I used code to make it in $6$:SHA-512 hash.
  • Must open /etc/shadow file, read it, find user by username and change password. There you can read about shadow file structure.

To open file used fstream, to find and change line I used std::getline and std::vector.

To run .cpp file, need to be root in terminal, run g++ fileName.cpp -o excqFileName -lcrypt and ./excqFileName commands. Thats it’s for me.

That all folks, I did my task and it’s possible. Will not share code, but I explained enough to understand how it works.

solved change any linux user password using c++