Register
Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    May 2008
    Location
    Netherlands
    Posts
    21
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    1
    Thanked in
    1 Post

    Default help with newcamd card server client?

    Hi

    I am trying to write a newcamd card server client, but have trouble logging in. Somehow there is an issue with the DES encryption. The protocol in protocol.txt is very vague around the encryption of the packet and the sample source code does not really help either. ANyone has some knowledge about the newcamd client?

    Thanks!

    Here is the code snippet:
    //LOGIN
    char salt[]="$1$abcdefgh$"; //$1$ indicates that DES encryption should be used by glibc
    char buf[1024]; //unencrypted command buffer for I/O
    int len; //buffer length
    int usnlen, cpwdlen;

    char DESkey[14];
    char username[]="local";
    char pwd[]="local";
    char *cpwd, loginkey[16];

    cpwd =crypt(pwd,salt); //crypt the password as described in the newcamd protocol
    usnlen =sizeof(username);
    cpwdlen =34; //glibc crypt generates 34 byte result code
    len =usnlen+cpwdlen;

    //now build the packet
    buf[0]=MSG_CLIENT_2_SERVER_LOGIN;
    buf[1]=(len>>8)&0x0f; //length: first 4 bits
    buf[2]=len&0xff; //length: last 8 bits
    memcpy(&buf[3],username,usnlen);
    memcpy(&buf[3+usnlen],cpwd,cpwdlen);
    buf[3+len]=0;

    len+=4; //1 additional 0
    printf("\tBuf:"); for (i=0;i<len;i++) printf("%02x ",buf[i]); printf("\n");

    for (i=0;i<14;i++) DESkey[i]=i+1; //as defined in /var/keys/newcamd.list
    printf("\tDESkey:"); for (i=0;i<14;i++) printf("%02d ",DESkey[i]); printf("\n");
    printf("\tDESkey generated, ");

    for (i=0;i<14;i++) loginkey[i]=buf1[i]^DESkey[i];

    send(handle,buf,len,0);

    //now hope the server answers
    i=recv(handle, buf1,1024,0);
    printf("%d bytes received from server\n",i);

    ======== server does not answer, so i returns -1 =====
    Last edited by jansenjw; 31st July, 2008 at 09:35 PM.

  2. #2
    Administrator
    Devilfish's Avatar
    Join Date
    Feb 2008
    Posts
    7,851
    Thanks Thanks Given 
    74
    Thanks Thanks Received 
    3,152
    Thanked in
    207 Posts

    Default

    I'm no good with this sort of thing but maybe this will help you...

    newcamd cardsharing

  3. #3
    Newbie
    Join Date
    Mar 2009
    Posts
    1
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts

    Default

    Jansenjw,

    Could you fix your issues?

    I am writing a newcamd client card server and having similar questions.

    If you could do it, I can share my current code so you can help me.

    thanks in advance.

    Quote Originally Posted by jansenjw View Post
    Hi

    I am trying to write a newcamd card server client, but have trouble logging in. Somehow there is an issue with the DES encryption. The protocol in protocol.txt is very vague around the encryption of the packet and the sample source code does not really help either. ANyone has some knowledge about the newcamd client?

    Thanks!

    Here is the code snippet:
    //LOGIN
    char salt[]="$1$abcdefgh$"; //$1$ indicates that DES encryption should be used by glibc
    char buf[1024]; //unencrypted command buffer for I/O
    int len; //buffer length
    int usnlen, cpwdlen;

    char DESkey[14];
    char username[]="local";
    char pwd[]="local";
    char *cpwd, loginkey[16];

    cpwd =crypt(pwd,salt); //crypt the password as described in the newcamd protocol
    usnlen =sizeof(username);
    cpwdlen =34; //glibc crypt generates 34 byte result code
    len =usnlen+cpwdlen;

    //now build the packet
    buf[0]=MSG_CLIENT_2_SERVER_LOGIN;
    buf[1]=(len>>8)&0x0f; //length: first 4 bits
    buf[2]=len&0xff; //length: last 8 bits
    memcpy(&buf[3],username,usnlen);
    memcpy(&buf[3+usnlen],cpwd,cpwdlen);
    buf[3+len]=0;

    len+=4; //1 additional 0
    printf("\tBuf:"); for (i=0;i<len;i++) printf("%02x ",buf[i]); printf("\n");

    for (i=0;i<14;i++) DESkey[i]=i+1; //as defined in /var/keys/newcamd.list
    printf("\tDESkey:"); for (i=0;i<14;i++) printf("%02d ",DESkey[i]); printf("\n");
    printf("\tDESkey generated, ");

    for (i=0;i<14;i++) loginkey[i]=buf1[i]^DESkey[i];

    send(handle,buf,len,0);

    //now hope the server answers
    i=recv(handle, buf1,1024,0);
    printf("%d bytes received from server\n",i);

    ======== server does not answer, so i returns -1 =====

  4. #4
    Newbie
    Join Date
    Jul 2010
    Posts
    2
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts

    Default

    Hi!
    usnlen =sizeof(username);
    Is it really what you want?
    Or does it work with
    usnlen=strlen(username)*sizeof(char);
    or
    usnlen=(strlen(username)+1)*sizeof(char)
    ?
    I like to help, if it helps.

  5. #5
    Newbie
    Join Date
    Jul 2010
    Posts
    2
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts

    Default

    Oh i'm late.

  6. #6
    Newbie
    Join Date
    May 2011
    Posts
    1
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts

    Default

    Hi, I'm interested in your program. Is ready?

 

 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.