расскажи как поломали, интересно уж очень.
по теме, попробуй это:
PHP код:
/*
* Kopete ICQ password recoverer
*
* Copyright © 2007 by R
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <wchar.h>
#define STR_VER "1.0"
#define MAX_PW_LEN 64
int decode_utf8(wchar_t* uc, unsigned char* utf8, size_t nchars ) {
/*
* Simple UTF-8 to UCS-2 decoder
*
*/
int i,n,nconv;
for(i=0,nconv=0; (i<strlen(utf8)) && (nconv<nchars);nconv++) {
if (utf8[i] < 128) {
*uc++=utf8[i];
i++;
}
else if ( (utf8[i] & 0xe0) == 0xc0) {
if( (utf8[i+1] & 0xc0) == 0x80 ) {
*uc++=(utf8[i]&0x1f)<<6 | (utf8[i+1] & 0x3f);
i+=2;
}
else {
return -1;
}
}
else if ( (utf8[i] & 0xf0) == 0xe0 ) {
if( (utf8[i+1] & 0xc0) == 0x80 && (utf8[i+2] & 0xc0) == 0x80) {
*uc++=(utf8[i]&0xf)<<12 | (utf8[i+1] & 0x3f)<<6 | (utf8[i+2] & 0x3f);
i+=3;
}
else {
return -1;
}
}
#ifdef _DEBUG
printf("uc=0x%x,nconv=%d\n",*(uc-1),nconv);
#endif
}
return nconv;
}
int main(int argc, char**argv)
{
char kopets[PATH_MAX+1];
char encoded_passwd[MAX_PW_LEN*3+1],buf[1024];
int saved_passwd_found;
wchar_t password[MAX_PW_LEN+1], c;
int i,n;
FILE *f;
printf("\n"
" -= Kopets v."STR_VER" - Kopete password recoverer by R =-\n"
"\n");
if(argc<2) {
snprintf(kopets,PATH_MAX,"%s/.kde/share/config/kopeterc",get*env("HOME"));
} else {
strncpy(kopets,argv[1],PATH_MAX);
kopets[PATH_MAX]=0;
}
f=fopen(kopets,"r");
if(!f) {
printf(" Unable to open file %s\r",kopets);
return EXIT_FAILURE;
}
printf(" Reading the config file: %s ...\n", kopets);
saved_passwd_found=0;
// Scan for "Password=" parameter
while(!feof(f)) {
fgets(buf,sizeof(buf),f);
if( !strncmp(buf,"Password=",9) ) {
if(strchr(buf,'\n')) *strchr(buf,'\n')=0;
strncpy(encoded_passwd,buf+9,sizeof(encoded_passwd)-1);
saved_passwd_found = 1;
break;
}
}
fclose(f);
if(!saved_passwd_found) {
printf(" Saved password not found!\n");
return EXIT_FAILURE;
}
printf(" Recovering Kopete password...\n");
// convert encoded password from UTF-8 to UCS-2
n=decode_utf8(password,encoded_passwd,MAX_PW_LEN);
if(n==-1)
{
printf(" ERROR: Invalid UTF-8 character in the encoded password string\n");
return EXIT_FAILURE;
}
for (i=0;i<n;i++)
{
c=password[i];
c= (c<0x20)? c : (wchar_t)(0x1001F-c);
password[i]=c;
}
printf("\n Decoded password is: %ls\n\n",password);
return 0;
}
|