This forum is in archive mode. You will not be able to post new content.

Author Topic: Password Permutation in C  (Read 3010 times)

0 Members and 2 Guests are viewing this topic.

Offline Killeramor

  • Peasant
  • *
  • Posts: 115
  • Cookies: 5
  • Programming tutor for Qbasic, and beginner C++.
    • View Profile
Password Permutation in C
« on: January 28, 2015, 06:25:57 PM »
Okay you dogs, this is a raw meat that I don't feel like seasoning. So eat it up bitches.

Edited:

Code: (cpp) [Select]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


void FileWriting(char *nme, FILE *list);
void FileOutPut();
void Trim(char *pass);


int main()
{
char nme[100], answer[4], answer2[4];
int repeat=1;


printf("Hello Welcome to Killeramor's Password Permutation!\n");
printf("---------------------------------------------------\n");
printf("What is your Name? ");
    fgets(nme,100,stdin);
   
    do
    {             
        printf("Lets get started.\n");


        FILE *list;
        list=fopen("Passwords.txt", "w");   
            FileWriting(nme,list);
        fclose(list);
                 
        printf("Would you like to see what was posted to file?(Y/N) ");
            fgets(answer,4,stdin);
        if(tolower(answer[0]) == 'y')
            {
                FileOutPut();
                printf("Would you like to redo the file?(Y/N)");
                    fgets(answer2,4,stdin);
                if (tolower(answer2[0]) == 'y')
                    {
                        repeat = 1;
                    }
                else if (tolower(answer2[0]) == 'n')
                    {
                        printf("Have a good day!\n");
                  return 0;
                    }
            }   
        else if (tolower(answer[0]) == 'n')
            {
                printf("Thanks for using the program.\n");
                return 0;
            }
        else
            {
                printf("Did not enter the way it was asked for.\n So We will end the program.");
                return 0;
            }           
    }while(repeat == 1);
   
    system("pause");
    return 0;
}


/* Function used to write to the File. */
void FileWriting(char *nme, FILE *list)
{
int loop=0,num=0,rNum,lCheck=0, howMany=1,basic,itteration;
char pass[100]; 
 


char a[5]="aA@4",b[5]="bB86",c[6]="cC(<[",d[3]="dD";
char e[4]="eE3",f[3]="fF",g[4]="gG5",h[4]="hH#",i[4]="iI!";
char j[5]="jJ]}", k[4]="kK{", l[6]="lL|17", m[3]="mM", n[4]="nN^";
char o[4]="oO0", p[4]="pP9",q[3]="qQ", r[3]="rR",s[4]="sS$", t[4]="tT+";
char u[3]="uU", v[3]="vV", w[3]="wW", x[4]="xX*", y[3]="yY", z[3]="zZ";


printf("\nEnter the password: ");
    fgets(pass,100,stdin);
Trim(pass);


    fprintf(list, "Generated by Killeramor's Password Permutation Generator.\n");
    fprintf(list,"---------------------------------------------------------\n");
    fprintf(list, "Permutation Password list for: %s\n", nme);   
    fprintf(list, "Password Listing's:\n" );   
    fprintf(list, "Password your using is:%s\n",pass); 
     
srand(time(NULL));   
for(loop=0; loop < 10; loop++){   
    for  (basic=0; basic< 10; basic++)
        {
           num= num + 1;
         fprintf(list,"Number:%d ", howMany);
           fprintf(list," %s%d\n",pass,num);
           howMany = howMany + 1;
       }
    num=0;
    for(lCheck=0; lCheck < strlen(pass); lCheck++){   
        if (tolower(pass[lCheck]) == 'a' ||
               pass[lCheck] == '@' ||
               pass[lCheck] == '4')
      {
            rNum = rand() % 4 ;
            pass[lCheck]= a[rNum];
        }
                                               
        else if (tolower(pass[lCheck]) == 'b' ||
                  pass[lCheck] == '8' ||
                  pass[lCheck] == '6')
      {   
            rNum = rand() % 4 ;
            pass[lCheck]= b[rNum];
        }
                                                                           
        else if (tolower(pass[lCheck]) == 'c' ||
                 pass[lCheck] == '(' ||
                 pass[lCheck] == '<' ||
                 pass[lCheck] == '[' )
      {
            rNum = rand() % 5;
            pass[lCheck]= c[rNum];
        }
                                     
        else if (tolower(pass[lCheck]) == 'd')                                   
        {
            rNum = rand() % 2;
            pass[lCheck]= d[rNum];
        }
       
        else if (tolower(pass[lCheck]) == 'e'||
                    pass[lCheck] == '3')
        {
            rNum = rand() % 3;
            pass[lCheck]= e[rNum];
        }
       
        else if (tolower(pass[lCheck]) == 'f')
        {
            rNum = rand() % 2;
            pass[lCheck]= f[rNum];
        }
       
        else if (tolower(pass[lCheck]) == 'g'
                  || pass[lCheck] == '5')
        {
            rNum = rand() % 3;
            pass[lCheck]= g[rNum];
        }                                   
                                     
        else if (tolower(pass[lCheck]) == 'h'
                  || pass[lCheck] == '#')
        {
            rNum = rand() % 3;
            pass[lCheck]= h[rNum];
        }
       
        else if (tolower(pass[lCheck]) == 'i'
               || pass[lCheck] =='!')
        {
             rNum = rand() % 3;
             pass[lCheck]= i[rNum];
        }
        else if (tolower(pass[lCheck]) == 'j'||
                 pass[lCheck] ==']' ||
                 pass[lCheck] =='}' )
        {
             rNum = rand() % 4;
             pass[lCheck]= j[rNum];
        }
        else if (tolower(pass[lCheck]) == 'k'||
                 pass[lCheck] =='{')
        {
            rNum = rand() % 3;
            pass[lCheck]= k[rNum];
        }
        else if (tolower(pass[lCheck]) == 'l' ||
                 pass[lCheck] =='|'|
                 pass[lCheck] =='7' ||
                 pass[lCheck] =='1' )
        {
            rNum = rand() % 5;
            pass[lCheck]= l[rNum];
        }
        else if (tolower(pass[lCheck]) == 'm')
        {
            rNum = rand() % 2;
            pass[lCheck]= m[rNum];
        }
        else if (tolower(pass[lCheck]) == 'n' ||
                  pass[lCheck] =='^' )
        {
            rNum = rand() % 3;
            pass[lCheck]= n[rNum];
        }
        else if (tolower(pass[lCheck]) == 'o' ||
                  pass[lCheck] == '0' )
        {
            rNum = rand() % 3;
            pass[lCheck]= o[rNum] ;
        }
        else if (tolower(pass[lCheck]) == 'p' ||
                  pass[lCheck] =='9' )
        {
            rNum = rand() % 3;
            pass[lCheck]= p[rNum] ;
        }
        else if (tolower(pass[lCheck]) == 'q')
        {
            rNum = rand() % 2;
            pass[lCheck]= q[rNum];
        }
        else if (tolower(pass[lCheck]) == 'r')
        {
            rNum = rand() % 2;
            pass[lCheck]= r[rNum];
        }
        else if (tolower(pass[lCheck]) == 's' ||
                  pass[lCheck] == '$' )
        {
            rNum = rand() % 3;
            pass[lCheck]= s[rNum];
        }
        else if (tolower(pass[lCheck]) == 't' ||
                  pass[lCheck] =='+' )
        {
            rNum = rand() % 3;
            pass[lCheck]= t[rNum];
        }
        else if (tolower(pass[lCheck]) == 'u')
        {
            rNum = rand() % 2;
            pass[lCheck]= u[rNum];
        }                 
        else if (tolower(pass[lCheck]) == 'v')
        {
            rNum = rand() % 2;
            pass[lCheck]= v[rNum];
        }                                                                                           
        else if (tolower(pass[lCheck]) == 'w')
        {
            rNum = rand() % 2;
            pass[lCheck]= w[rNum];
        }
        else if (tolower(pass[lCheck]) == 'x' ||
                  pass[lCheck] =='*')
        {
            rNum = rand() % 3;
            pass[lCheck]= x[rNum];
        }
        else if (tolower(pass[lCheck]) == 'y')
        {
            rNum = rand() % 2;
            pass[lCheck]= y[rNum];
        }                                                                       
        else if (tolower(pass[lCheck]) == 'z')
        {
            rNum = rand() % 2;
            pass[lCheck]= z[rNum];
        }
            for (itteration=0;itteration< 10; itteration++){   
                howMany = howMany + 1;
                num = num+ 1;
                fprintf(list,"Number:%d ", howMany);
                fprintf(list," %s%d\n",pass,num);
            }
        num=0;
        }
}
   
/*    num=0;
    for (basic=0;basic< 10; basic++){   
        num=0;
        num = num + 1; 
       howMany = howMany +1;
        fprintf(list,"Number:%d ", howMany);
        fprintf(list," %s%d\n",pass,num);
    }*/
}




/*Function used to open up the text Document.*/
void FileOutPut()
{
    int done= done+ 1;
   
    if ( done == 1){
        //System command to set the file path for the file.
            system("setx path E:\\Password Permutations");
        }
    // System command to run the file.
    system("start Passwords.txt");
    printf("\n");
}




void Trim(char *pass)
{
    char * p = pass;
    int l = strlen(p);


    while(isspace(p[l - 1])) p[--l] = 0;
    while(*pass && isspace(* p)) ++p, --l;


    memmove(pass, p, l + 1);
}

« Last Edit: February 22, 2015, 11:16:32 AM by Kulverstukas »
Knowledge is free. Share what you know, help others grow. We all start somewhere.

Offline ArkPhaze

  • Peasant
  • *
  • Posts: 136
  • Cookies: 20
  • null terminated
    • View Profile
Re: Password Permutation in C
« Reply #1 on: February 22, 2015, 09:43:57 AM »
There's tons of things wrong with this.
Code: [Select]
int done= done+ 1;
You're using an undefined variable to add to 1 and set to itself...

Code: [Select]
while(isspace(p[l - 1])) p[--l] = 0;
while(*pass && isspace(* p)) ++p, --l;

No bounds checking. while(*pass ...) is also not really useful.

The rest is just bloat.
sig=: ArkPhaze

[ J/ASM/.NET/C/C++ - Software Engineer ]

Offline Killeramor

  • Peasant
  • *
  • Posts: 115
  • Cookies: 5
  • Programming tutor for Qbasic, and beginner C++.
    • View Profile
Re: Password Permutation in C
« Reply #2 on: February 25, 2015, 01:43:35 AM »
There's tons of things wrong with this.
Code: [Select]
int done= done+ 1;
You're using an undefined variable to add to 1 and set to itself...

Code: [Select]
while(isspace(p[l - 1])) p[--l] = 0;
while(*pass && isspace(* p)) ++p, --l;

No bounds checking. while(*pass ...) is also not really useful.

The rest is just bloat.


I am aware of the bloat. The value was fixed in a later update of this code. I did not have time to learn more indepth ways when completing this code. Wrote it in a 1-2 day span, with little to no knowledge of C. Hint to why I called it Raw Meat.
« Last Edit: February 25, 2015, 01:43:57 AM by Killeramor »
Knowledge is free. Share what you know, help others grow. We all start somewhere.

Offline ForceBru

  • NULL
  • Posts: 3
  • Cookies: 0
    • View Profile
Password Permutation in C
« Reply #3 on: April 06, 2015, 05:09:38 PM »
Nobody noticed that you have to use
Code: [Select]
FILE *list=fopen(...); You need to use file pointers instead of just
Code: [Select]
FILE.

Your code seems to be wrecked somehow. What does this mean?

Code: [Select]
char *p=
« Last Edit: April 06, 2015, 05:13:25 PM by ForceBru »

Offline ArkPhaze

  • Peasant
  • *
  • Posts: 136
  • Cookies: 20
  • null terminated
    • View Profile
Re: Password Permutation in C
« Reply #4 on: April 06, 2015, 06:16:10 PM »
Nobody noticed that you have to use
Code: [Select]
FILE *list=fopen(...); You need to use file pointers instead of just
Code: [Select]
FILE.

Your code seems to be wrecked somehow. What does this mean?

Code: [Select]
char *p=

Might be because he is in fact using FILE pointers? Look at the code more closely. I see this:
Code: [Select]
FILE *list;
list=fopen("Passwords.txt", "w"); 
« Last Edit: April 06, 2015, 06:17:07 PM by ArkPhaze »
sig=: ArkPhaze

[ J/ASM/.NET/C/C++ - Software Engineer ]

Offline HTH

  • Official EZ Slut
  • Administrator
  • Knight
  • *
  • Posts: 395
  • Cookies: 158
  • EZ Titan
    • View Profile
Re: Password Permutation in C
« Reply #5 on: April 06, 2015, 10:31:35 PM »
In addition I scanned through the code briefly and couldn't find this messed up assignment statement he claimed was there.
<ande> HTH is love, HTH is life
<TurboBorland> hth is the only person on this server I can say would successfully spitefuck peoples women

Offline Killeramor

  • Peasant
  • *
  • Posts: 115
  • Cookies: 5
  • Programming tutor for Qbasic, and beginner C++.
    • View Profile
Re: Password Permutation in C
« Reply #6 on: April 07, 2015, 11:49:08 AM »
lOL I LOVE how i did not have to defend myself. Love ya HTH and Ark lol
Knowledge is free. Share what you know, help others grow. We all start somewhere.

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.