• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[C] a few of my small sources

Status
Not open for further replies.
Level 6
Joined
Nov 1, 2007
Messages
42
just thought i was post up some of my small sources i've coded from a while ago in C.

Random Password Generator:

Code:
/*Random password generator By GoSu.SpeeD*/

#include <stdio.h>
#include <windows.h>

int main(int argc, char **argv)
{    
   SetConsoleTitle("Your Title Here");  
   SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), FOREGROUND_BLUE | FOREGROUND_INTENSITY ); 
   unsigned char c;
   int a;
   int d;
   int e = 40;
   int f = 1;
   int length; 
     
   srand(GetTickCount());
   
   printf("\t\tPassword Generator\n\n");
   printf("Options:\n\n"
          "1 - Generate a password\n"
          "2 - Exit\n\n"
          ">");
          
   a = getchar();       
   if (a == '1')
   {
      FILE *fp;
      fp = fopen("Passwords.txt", "a");
      for (d = 0; d < e; d = d + f)
      {
       c = (rand() % 255);
       if(isgraph(c))
        {              
          printf("%c", c);
          fprintf(fp, "%c", c);
        }
      }
      fprintf(fp, "\n");
      printf("\n\n");
      fclose(fp);
      sleep(2000);
      printf("Your generated password is now saved in Passwords.txt\n\n");
      sleep(1000);
   }
   if (a == '2')
   {
      exit(1);
   }   
   system("pause");
   return 0;
}

Simple Argument Driven program:

Code:
/* 
   Simple Argument Driven Program 
   By GoSu.SpeeD
*/

#include <stdio.h>

int main(int argc, char **argv)
{
  if (argc != 2) // if arguments are not equal to 2
  {
     printf("Incorrect Usage - \n");
     printf("Usage: %s <Name>", argv[0]); /*  printing argv[0] as a 
                                              string will show the executable name */	
     return -1;
  }
  printf("So your name is %s?", argv[1]); /* printing argv[1] as a string will print
                                             the second Argument in the console */
}

CD Tray Open/Close:

Code:
/* Cd-tray Open/Close
          GoSu.SpeeD
*/

/*
   compile: gcc.exe t.c -o t.exe -lwinmm
*/

#include <stdio.h>
#include <windows.h>

int menu(void);
int cdtray(char);

int main(int argc, char **argv)
{
    if(argc < 2 || strlen(*(argv + 1)) != 2 || **(argv + 1) != '-')
    {
        return menu();
    }
    switch(*(*(argv + 1) + 1))
    {
       case 'o':
       case 'O':
          cdtray(*(*(argv + 1) + 1));
          break;
       case 'c':
       case 'C':
          cdtray(*(*(argv + 1) + 1));
          break;
       default:
          return menu();
    }
    return 0;
}

int menu(void)
{
    printf("Usage:\ntray.exe [-o] [-c]\n");
    exit(1);
}

int cdtray(char c)
{
    switch(c)
    {
       case 'o':
       case 'O':
          mciSendString("set cdaudio door open", NULL, 0, NULL);
          break;
       case 'c':
       case 'C':
          mciSendString("set cdaudio door closed", NULL, 0, NULL);
          break;
    }
    return 0;
}

Simple Decimal TO Hex Conversion:

Code:
#include <stdio.h>

int main()
{
    int hex;
    printf("Please input the decimal value you wish to convert to hex\n\n");
    printf("> ");
    
    scanf("%d", &hex);
    printf("\n-> %x\n\n", hex);
    
    system("pause");
    return 0;
}

hope these help someone :)
 
Level 6
Joined
Nov 1, 2007
Messages
42
that password generator tool is so much fail...

good luck with passwords containing <32 ASCII characters

not really considering most public brute-forcers only brute at about 10 brutes a second (if even) so it will take too long to crack a random password containing more than 10 ascii characters.

also i didn't state that it generated "uber leet passwords".
 
Status
Not open for further replies.
Top