I use code to crack rar passwords. I read the password from the file and pass it to the sprintf function. This is the code.
FILE* fp = fopen("password.txt","r"); while ( fgets ( pword, sizeof(pword), fp ) != NULL ) { sprintf(command, "rar e -p%s realp.rar", pword); printf(command);
This code looks great, but it does not work. Therefore, I commented on the functioning of the system and printed out the variable "command". The output is as follows:
rar e -pfirstpassword realp.rarrar e -psecondpassword realp.rarrar e -pthirdpassword realp.rarrar e -pfourthpassword realp.rar
I see how it breaks. The result should look like this.
rar e -pfirstpassword realp.rar rar e -psecondpassword realp.rar rar e -pthirdpassword realp.rar rar e -pfourthpassword realp.rar
Can someone help me solve this? Thanks in advance.
- operating system
- : windows 7
- compiler: dev C ++
source share