From C to PHP Script

Discussion in 'PHP' started by Fratyr, Feb 12, 2008.

  1. #1
    Hello guys.
    Im on a big dilemma, i need some professional help.

    I got this script, below script's description and example.

    
    #include <stdio.h>
    
    char key[] = {
    0x56, 0xf4, 0xef, 0x50,
    0x34, 0xa9, 0xef, 0x6b,
    0x55, 0x4b, 0x03, 0x3c,
    0x9a, 0x01, 0x78, 0xb3,
    0xfd, 0xb1, 0x3d, 0xd4,
    0x9b, 0xd3, 0xcb, 0x9f,
    0x06, 0xd2, 0xd2, 0x65,
    0xe8, 0xbd
    };
    
    int main (int argc, char** argv)
    {
    int i, last_i;
    char word[30];
    char *cur_char;
    
    if (argc!=2)
    {
    printf("Usage: 炼㤜䀂 coded_string_up_to_30_symbols\n",argv[0]);
    return 0;
    }
    
    cur_char=argv[1];
    
    while(*cur_char)
    {
    if(*cur_char!='&')
    {
    word[i++]=*cur_char;
    cur_char++;
    }
    else
    {
    sscanf(cur_char,"&7c35056a;",word+i);
    i++;
    cur_char+=4;
    }
    }
    
    word[i];
    last_i=i;
    
    for (i;i<last_i;i++)
    word[i]word[i]-key[i])&0xff;
    
    printf("text/x-plain-icqmbcs\n",word);
    
    return 0;
    }
    
    
    Code (markup):
    This little script DECODE encoded passwords from HASH.
    Let's say you got this password: &8b;$&1f;&83;j&da;&22;&a3;&85;&aa;p
    IF you decode it, you get something like this: 500......_m (... dots means some chars, i just dont remember them, but the last ones was _m).

    Now, i want someone to help me rewrite this script to PHP, i want it to be web application so i could run it from any place at my hosting.

    Please, any advice, or maybe a fully rewrited code will be great, i just dont work with HEX and bytes YET.. so i dont know how to realise it. :)
     
    Fratyr, Feb 12, 2008 IP
  2. Fratyr

    Fratyr Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sorry this code is a bit wrong ... here is the original one:
    www[.]fratyr[.]com/original.c
     
    Fratyr, Feb 12, 2008 IP
  3. Fratyr

    Fratyr Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Without [ ] in a link of course.. :]
     
    Fratyr, Feb 12, 2008 IP
  4. 00johnny

    00johnny Peon

    Messages:
    149
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i'm not sure I fully understand what this program does. Basically do some math with the password and the key?
    What is this used for and why do you need it in php?
    Is this a paid gig?
     
    00johnny, Feb 17, 2008 IP
  5. Fratyr

    Fratyr Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    This is not an active thread anymore, took too much time to people to answer such a basic question. :-|

    Anyway this script dehex passwords for MP-202 AudioCodes VoIP Adapter.
    Anyone who has it and want to decrypt it's password can use it. It's free.
    Built on basic C functions.
     
    Fratyr, Feb 18, 2008 IP