Created
November 18, 2014 09:43
-
-
Save CreateRemoteThread/fa6e9532a23001d0f43c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
sectalks 0x01 | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <windows.h> | |
#include <time.h> | |
char *globalPassword = "PIGEONS"; | |
char *createPassword(); | |
int challenge(); | |
void chomp(char *s); | |
char *generateAuthToken(); | |
int main(int argc, char **argv) | |
{ | |
srand(time(NULL)); | |
int bCont = 1; | |
if(challenge() == 1) | |
{ | |
char *newPassword = createPassword(); | |
printf(" the password is %s",newPassword); | |
return 0; | |
} | |
} | |
char *convertAuth(char *in) | |
{ | |
int i = 0; | |
char *convertedAuthKey = (char *)malloc(128); | |
memset(convertedAuthKey,0,128); | |
int authIntegers[6]; | |
for(i = 0; i < 6; i++) | |
{ | |
authIntegers[i] = (in[i] * (i + 1)) % 256; | |
} | |
sprintf(convertedAuthKey,"%d %d %d %d %d %d",authIntegers[0],authIntegers[1],authIntegers[2],authIntegers[3],authIntegers[4],authIntegers[5]); | |
return convertedAuthKey; | |
} | |
char *createPassword() | |
{ | |
char *newGlobalPassword = (char *)malloc(8); | |
newGlobalPassword[7] = '\0'; | |
newGlobalPassword[0] = globalPassword[0] ^ '\x11'; | |
newGlobalPassword[1] = globalPassword[1] ^ '\x0F'; | |
newGlobalPassword[2] = globalPassword[2] ^ '\x0B'; | |
newGlobalPassword[3] = globalPassword[3] ^ '\x04'; | |
newGlobalPassword[4] = globalPassword[4] ^ '\x08'; | |
newGlobalPassword[5] = globalPassword[5] ^ 'z'; | |
newGlobalPassword[6] = globalPassword[6] ^ 'a'; | |
return newGlobalPassword; | |
} | |
int challenge() | |
{ | |
char *authResponse = generateAuthToken(); | |
// printf(" DEBUG: authResponse = %s\n",authResponse); | |
char *inputBuffer = (char *)malloc(256); | |
int i = 0; | |
for(i = 0; i < 3; i++) | |
{ | |
printf(" > "); | |
memset(inputBuffer,0,256); | |
fgets(inputBuffer,256,stdin); | |
chomp(inputBuffer); | |
if(strlen(inputBuffer) != 6) | |
{ | |
printf(" the password is the wrong length\n"); | |
} | |
else | |
{ | |
char *convertedActualPassword = convertAuth(authResponse); | |
char *convertedEnterdPassword = convertAuth(inputBuffer); | |
if(strcmp(authResponse,inputBuffer) == 0) | |
{ | |
return 1; | |
} | |
else | |
{ | |
printf(" expected : %s\n",convertedActualPassword); | |
printf(" got : %s\n",convertedEnterdPassword); | |
} | |
free(convertedActualPassword); | |
free(convertedEnterdPassword); | |
} | |
} | |
free(inputBuffer); | |
free(authResponse); | |
return 0; | |
} | |
void chomp(char *s) | |
{ | |
int i = 0; | |
int stop = strlen (s); | |
for (i = 0; i < stop; i++) | |
{ | |
if (!(isprint (s[i])) || s[i] == '\r' || s[i] == '\n') | |
{ | |
s[i] = 0; | |
return; | |
} | |
} | |
} | |
char *globalGenerator = "abcdefghijkmnopqrstwxyz123456790"; | |
char *generateAuthToken() | |
{ | |
char *authToken = (char *)malloc(7); | |
memset(authToken,0,7); | |
int i = 0; | |
for(i = 0;i < 6; i++) | |
{ | |
authToken[i] = globalGenerator[rand() % strlen(globalGenerator)]; | |
} | |
return authToken; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment