Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
stallwoodj
Collaborator
Collaborator

Extracting PSK from Spark

Hi,

I had a situation where I needed to get PSK's from a Spark to install on a big boy Quantum we're migrating to.

The encoded strings are in CLISH "show configuration" and can be reversed using the attached (clunky) C code.

./reverse 26272b2428252e4c
aaaabbbb

Might be useful for someone else.

Thanks

Jamie

0 Kudos
2 Replies
stallwoodj
Collaborator
Collaborator

Updated with corrections

 

 

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

int main(int argc, char *argv[]) {
char HASH[]="-ODIFIED&W0ROPERTY3HEET7ITH/+4HE3HEET)$3?,$!0?!5?02/0%24)%3.5,,";
int max=strlen(HASH),dlen,hp=0;
int i;
unsigned char c,v,*data;

if (argc<2) {
printf("Error: argument missing\n");
return 1;
}

data=argv[1]; dlen=strlen(data);

if ((dlen%2)!=0) {
printf("Hash data has odd number of characters\n");
return 1;
}
for (i=dlen; (hp<max)&&(i>0); i-=2) {
c=data[i-2];
switch(c) {
case 'a' ... 'f':
c=10+(c-'a');
break;
case 'A' ... 'F':
c=10+(c-'A');
break;
case '0' ... '9':
c=c-'0';
break;
default:
printf("Invalid char '%c' in string\n",c);
return 2;
}
v=(16*c);
c=data[i-1];
switch(c) {
case 'a' ... 'f':
c=10+(c-'a');
break;
case 'A' ... 'F':
c=10+(c-'A');
break;
case '0' ... '9':
c=c-'0';
break;
default:
printf("Invalid char '%c' in string\n",c);
return 2;
}
v+=c;
printf("%c",(v==255?0:v)^HASH[hp]);
hp++;
}
printf("\n\n");
return 0;
}

0 Kudos
the_rock
MVP Platinum
MVP Platinum

If I get a hold of actual smb appliance, would be interesting to test this out.

Best,
Andy
0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events