#include #include #include #include using namespace std; //this is an example line from the shadow file: //$6$Iy/hHRfM$gC.Fw7CbqG.Qc9p9X59Tmo5uEHCf0ZAKCsPZuiYUKcejrsGuZtES1VQiusSTen0NRUPYN0v1z76PwX2G2.v1l1:15001:0:99999:7::: // the salt and password values are extracted as string target_salt = "$6$Iy/hHRfM$"; string target_pw_hash = "$6$Iy/hHRfM$gC.Fw7CbqG.Qc9p9X59Tmo5uEHCf0ZAKCsPZuiYUKcejrsGuZtES1VQiusSTen0NRUPYN0v1z76PwX2G2.v1l1"; // define a null string which is returned in case of failure to find the password char null[] = {'\0'}; // define the maximum length for the password to be searched #define MAX_LEN 6 list pwlist; // check if the pw and salt are matching the hash int check_password(char* pw, char* salt, char* hash) { char* res = crypt(pw, salt); cout << "password " << pw << "\n"; cout << "hashes to " << res << "\n"; for (int i = 0; i