PDA

View Full Version : help with newcamd card server client?



jansenjw
31st July, 2008, 09:31 PM
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 =====

Devilfish
31st July, 2008, 11:50 PM
I'm no good with this sort of thing but maybe this will help you...

newcamd cardsharing (http://www.digital-kaos.co.uk/forums/showthread.php?t=3805)

ocorvos
31st October, 2009, 05:42 PM
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.


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 =====

asdf11
28th July, 2010, 08:47 PM
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.

asdf11
28th July, 2010, 08:50 PM
Oh i'm late.

hanspoland
27th May, 2011, 12:36 PM
Hi, I'm interested in your program. Is ready?