Building password list
#20
(09-05-2019, 05:00 PM)Ar76 Wrote:
Code:
#include <stdio.h>
#include <string.h>

int main(){

FILE *FP;
int i=0;
char buffer[20];
sprintf(buffer, "combos.text", i);
fp=fopen(buffer, "w");

for(i=0; i<100000000;i++){
strcat(buffer, "WIFI-");
fprintf(fp, buffer);

}
return 0;
}

Any errors let me know.

Does that code actually work? Wink

I have never used Codeblocks, I would be surprised if it does not mind the difference in case between "FP" when declared and "fp" when used, or the lack of format like %09u in the second argument to sprintf() in order to process the 'i' variable, which I think you meant to do within the loop so that it changes at each turn, not only once at the beginning Smile

More importantly: you should never use strcat(), use strncat() instead, or in fact in this case I do not understand the use of either when sprintf() - or even better, snprintf() if available - is what is already meant to be used to format the variable into the name...

You should never use strcat() because it has no idea when to stop, as exemplified in this case: the common mistake would have been to concatenate two strings together (once) and hope that they fit in the buffer, which works as long as neither is under the control of someone else otherwise they can attack you with a buffer overflow, but since your loop never resets the buffer your code attacks itself: buffer becomes... well it's undefined at the beginning, hopefully your compiler would have filled it with null bytes if it was to be used by strcat() directly, but let's say that the sprintf() line compiles somehow... buffer becomes "combos.txtWIFI-" in the first loop turn, "combos.txtWIFI-WIFI-" in the second loop turn which is already overflowing the 20 bytes you allocated for buffer on the stack (20 for the text + 1 for the null byte at the end), and from the third turn of the loop your program is already overwriting its own memory; hopefully the OS kills it long before it reaches the 100000000 turns target Smile
Reply


Messages In This Thread
Building password list - by Ar76 - 09-01-2019, 09:01 AM
RE: Building password list - by undeath - 09-01-2019, 11:22 AM
RE: Building password list - by os2873 - 09-02-2019, 07:39 AM
RE: Building password list - by Ar76 - 09-02-2019, 02:50 PM
RE: Building password list - by os2873 - 09-03-2019, 10:24 AM
RE: Building password list - by Ar76 - 09-03-2019, 11:25 AM
RE: Building password list - by os2873 - 09-03-2019, 09:38 PM
RE: Building password list - by differentequal - 09-04-2019, 08:58 AM
RE: Building password list - by undeath - 09-02-2019, 12:22 PM
RE: Building password list - by os2873 - 09-03-2019, 10:23 AM
RE: Building password list - by philsmd - 09-04-2019, 01:20 PM
RE: Building password list - by Ar76 - 09-04-2019, 02:44 PM
RE: Building password list - by philsmd - 09-04-2019, 03:39 PM
RE: Building password list - by Ar76 - 09-05-2019, 12:33 PM
RE: Building password list - by philsmd - 09-05-2019, 12:38 PM
RE: Building password list - by Ar76 - 09-05-2019, 01:50 PM
RE: Building password list - by philsmd - 09-05-2019, 04:01 PM
RE: Building password list - by Ar76 - 09-05-2019, 05:00 PM
RE: Building password list - by Ar76 - 09-05-2019, 05:18 PM
RE: Building password list - by Kryczek - 09-06-2019, 01:23 PM
RE: Building password list - by Ar76 - 09-06-2019, 08:53 PM
RE: Building password list - by Ar76 - 09-07-2019, 09:47 AM