Luigi Auriemma

aluigi.org (ARCHIVE-ONLY FORUM!)
It is currently 19 Jul 2012 13:47

All times are UTC [ DST ]





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: FlashFXP PW Decoder (with no C-LIBS) don't work
PostPosted: 24 May 2008 15:46 

Joined: 24 May 2008 15:41
Posts: 5
HI Everyone

I have a problem with the pw decryptin Code for FlashFXP PW's

I want write this Code with NO C-LIBS.

But now the PW Decrypt Function don't work anymore, look at my Code:

Code:
void flashfxp_pwddec(char *pwd) {
    char  *enc,
            *ptr;
    int     len,
            old,
            i;

    enc = FXPDATA;
    len = strlen(pwd) >> 1;
    if(!len) return;
    len--;
   wsprintfA(pwd,"%02X", &old);
    ptr = pwd;
    pwd += 2;
    while(len--) {
        wsprintfA(pwd,"%02X", &i);
        i ^= *enc++;
        if(old >= i) i--;
        *ptr++ = i - old;
        wsprintfA(pwd, ("%02X", &old);
        pwd += 2;
        if(!*enc) enc = FXPDATA;
    }
    *ptr = 0;
}


I replace the function sscanf with wsprintfA.
But now the decryptet pw is wrong.

Can someone tell me whats wrong with this funktion?

Thx for your help

greeZ
mashroom100


Top
 Profile  
 
 
 Post subject:
PostPosted: 24 May 2008 16:38 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
it's normal that doesn't work, sscanf and sprintf are just the opposite functions 8-)

If you can't or don't want to use sscanf use the following function which is a fast hex2byte decoder:

Code:
unsigned char hex2byte(unsigned char *hex) {
    static const unsigned char hextable[256] =
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x00\x00\x00\x00\x00\x00"
        "\x00\x0a\x0b\x0c\x0d\x0e\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x0a\x0b\x0c\x0d\x0e\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";

    return((hextable[hex[0]] << 4) | hextable[hex[1]]);
}


and instead of "wsprintfA(pwd,"%02X", &old);" use "old = hex2byte(pwd)" and so on


Top
 Profile  
 
 Post subject:
PostPosted: 25 May 2008 15:46 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
isnt ''print'' commands for .. well printing something out. like show it on screen. and scan is for reading info from screen ?!
i kind a tought about it before, but im not that good in programming so i tought ill see what Luigi says first :)


Top
 Profile  
 
 Post subject:
PostPosted: 25 May 2008 17:15 

Joined: 24 May 2008 15:41
Posts: 5
Big THX @ aluigi. With your code it works great!

greeZ
mashroom100


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: