[ Source ] Gamespy Arcade password decoder

Post new topic   Reply to topic

View previous topic View next topic Go down

[ Source ] Gamespy Arcade password decoder

Post  ~Fleck on Tue Jun 30, 2009 6:40 am

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>



#define VER            "0.1"
#define BUFFSZ          4096
#define NICK            "usr_nick="
#define PASS            "usr_pass="



#ifndef WIN32
    #define strnicmp strncasecmp
#endif

#ifndef u_char
    #define u_char  unsigned char
#endif



void gsa_pwd(u_char *pwd);
void std_err(void);



int main(int argc, char *argv[]) {
    FILE    *fd;
    u_char  *buff,
            *ptr,
            *limit;


    setbuf(stdout, NULL);

    fputs("\n"
        "Gamespy Arcade password decoder "VER"\n"
        "by Luigi Auriemma\n"
        "e-mail: aluigi@autistici.org\n"
        "web:    aluigi.org\n"
        "\n", stdout);

    if(argc < 2) {
        printf("\nUsage: %s <settings.cfg>\n"
            "\n"
            "settings.cfg is located in the directory Profiles\\ID where ID is the profile number\n"
            "\n", argv[0]);
        fputs("\n    Press RETURN to exit\n", stdout);
        fgetc(stdin);
        exit(1);
    }

    printf("\nOpening file %s\n\n", argv[1]);
    fd = fopen(argv[1], "rb");
    if(!fd) std_err();

    buff = malloc(BUFFSZ + 1);
    if(!buff) std_err();

    while(1) {
        if(!fgets(buff, BUFFSZ, fd)) break;

        if(!strnicmp(buff, NICK, sizeof(NICK) - 1)) {
            printf("Nickname:  %s", buff + sizeof(NICK) - 1);

        } else if(!strnicmp(buff, PASS, sizeof(PASS) - 1)) {
            ptr = buff + sizeof(PASS) - 1;
            if(*ptr == 0xab) {  // new method, encoded
                ptr++;
                limit = strchr(ptr, 0xbb);
                if(limit) *limit = 0;
                gsa_pwd(ptr);
            } else {            // old method
                for(limit = ptr; *limit > 0xd; limit++);
                *limit = 0;
            }
            printf("Password:  %s\n", ptr);
        }
    }

    fclose(fd);
    fputs("\n\n    Press RETURN to exit\n", stdout);
    fgetc(stdin);
    return(0);
}



void gsa_pwd(u_char *pwd) {
    u_char  *out;
    int    len,
            tmp;

    out = pwd;
    len = strlen(pwd) >> 1;
    while(len--) {
        tmp = *pwd++;
        tmp = *pwd++ - tmp;
        if(tmp < 0) tmp += 0x5f;
        *out++ = tmp + 0x20;
    }
    *out = 0;
}



void std_err(void) {
    perror("\nError");
    fputs("\n    Press RETURN to exit\n", stdout);
    fgetc(stdin);
    exit(1);

_________________

Thanks to FusioN for this awesome sig :]

~Fleck
Moderator
Moderator

Posts: 274
Activity: -258
Reputation: 8
Join date: 2009-06-28
Age: 16
Location: 127.0.0.1

Back to top Go down

View previous topic View next topic Back to top


Post new topic   Reply to topic
Permissions of this forum:
You cannot reply to topics in this forum