Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
892 connectés 

  FORUM HardWare.fr
  Programmation

  Algorithme...

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Algorithme...

n°109649
stef_dober​mann
Personne n'est parfait ...
Posté le 08-03-2002 à 19:45:45  profilanswer
 

Je cherche l'algorithme qui permet de décoder les fichier pwl,
le but (uniquement perso) le coder en Perl :D
 
J'ai chercher sur Google mais je n'ai trouvé que des prog déjà tou fait !!
 
Voili voila M'sieur,Dames et les autres......
 
je vous avez des truc ca m'intersse  
je sais que pas bien mon bon on ne peut pas programmer tou les jours la même chose :lol:


---------------
Tout à commencé par un rêve...
mood
Publicité
Posté le 08-03-2002 à 19:45:45  profilanswer
 

n°109659
deathsharp
Posté le 08-03-2002 à 20:54:50  profilanswer
 

g trouver ca sur google si ca peut t'aider (condition que tu connaissent c++ )
 

Code :
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <process.h>
  4. #include <stdlib.h>
  5. #include <ctype.h>
  6. #include <conio.h>
  7. unsigned char huge Data[100001];
  8. unsigned char keystream[1001];
  9. int Rpoint[300];
  10. void main (int argc,char *argv[]) {
  11. FILE *fd;
  12. int  i,j,k;
  13. int size;
  14. char ch;
  15. char *name;
  16. int cracked;
  17. int sizemask;
  18. int maxr;
  19. int rsz;
  20. int pos;
  21. int Rall[300]; /* recource allocation table */
  22. if (argc<2) {
  23.  printf("usage: glide filename (username)" );
  24.  exit(1);
  25. }
  26. /* read PWL file */
  27. fd=fopen(argv[1],"rb" );
  28. if(fd==NULL) {
  29.  printf("can't open file %s",argv[1]);
  30.  exit(1);
  31. }
  32. size=0;
  33. while(!feof(fd)) {
  34.  Data[size++]=fgetc(fd);
  35. }
  36. size--;
  37. fclose(fd);
  38. /* find username */
  39. name=argv[1];
  40. if(argc>2) name=argv[2];
  41. printf("Username: %s\n",name);
  42. /* copy encrypted text into keystream */
  43. cracked=size-0x0208;
  44. if(cracked<0) cracked=0;
  45. if(cracked>1000) cracked=1000;
  46. memcpy(keystream,Data+0x208,cracked );
  47. /* generate 20 bytes of keystream */
  48. for(i=0;i<20;i++) {
  49.  ch=toupper(name[i]);
  50.  if(ch==0) break;
  51.  if(ch=='.') break;
  52.  keystream[i]^=ch;
  53. };
  54. cracked=20;
  55. /* find allocated recources */
  56. sizemask=keystream[0]+(keystream[1]<<8);
  57. printf("Sizemask: %04X\n",sizemask);
  58. for(i=0;i<256;i++) Rall[i]=0;
  59. maxr=0;
  60. for(i=0x108;i<0x208;i++) {
  61.  if(Data[i]!=0xff) {
  62.   Rall[Data[i]]++;
  63.   if (Data[i]>maxr) maxr=Data[i];
  64.  }
  65. }
  66. maxr=(((maxr/16)+1)*16); /* recource pointer table size appears to be divisable by 16 */
  67. /* search after recources */
  68. Rpoint[0]=0x0208+2*maxr+20+2; /* first recource */
  69. for(i=0;i<maxr;i++) {
  70.  /* find size of current recource */
  71.  pos=Rpoint[i];
  72.  rsz=Data[pos]+(Data[pos+1]<<8);
  73.  rsz^=sizemask;
  74.  printf("Analyzing block with size: %04x\t(%d:%d)\n",rsz,i,Rall[i]);
  75.  if( (Rall[i]==0) && (rsz!=0) ) {
  76.   printf("unused resource has nonzero size !!!\n" );
  77.   printf("If last line produced any : You may try to recover\n" );
  78.   printf("press y to attempt recovery\n" );
  79.   ch=getch();
  80.   if(ch!='y') exit(0);
  81.   rsz=2;
  82.   i-=1;
  83.  }
  84.  pos+=rsz;
  85.  /* Resources have a tendency to have the wrong size for some reason */
  86.  /* check for correct size */
  87.  if(i<maxr-1) {
  88.   while(Data[pos+3]!=keystream[1]) {
  89.    printf(":",Data[pos+3]);
  90.    pos+=2; /* very rude may fail */
  91.   }
  92.  }
  93.  pos+=2; /* include pointer in size */
  94.  Rpoint[i+1]=pos;
  95. }
  96. Rpoint[maxr]=size;
  97. /* insert Table data into keystream */
  98. for(i=0;i <= maxr;i++) {
  99.  keystream[20+2*i]^=Rpoint[i] & 0x00ff;
  100.  keystream[21+2*i]^=(Rpoint[i] >> 8) & 0x00ff;
  101. }
  102. cracked+=maxr*2+2;
  103. printf("%d bytes of keystream recovered\n",cracked);
  104. /* decrypt resources */
  105. for(i=0;i < maxr;i++) {
  106.  rsz=Rpoint[i+1]-Rpoint[i];
  107.  if (rsz>cracked) rsz=cracked;
  108.  printf("Recource[%d] (%d)\n",i,rsz);
  109.  for(j=0;j<rsz;j++) printf("%c",Data[Rpoint[i]+j]^keystream[j]);
  110.  printf("\n" );
  111. }
  112. exit(0);
  113. }


 
g pas tester, g pas lu, g rien fait


---------------
What butter and whiskey won't cure, there is no cure for.
n°109677
stef_dober​mann
Personne n'est parfait ...
Posté le 08-03-2002 à 21:51:50  profilanswer
 

Je te remercie  :jap: , je ne connais pas trop le C mais c pas grave je vais m'i m'être  :sweat:


---------------
Tout à commencé par un rêve...
n°109678
stef_dober​mann
Personne n'est parfait ...
Posté le 08-03-2002 à 21:52:20  profilanswer
 

si y'an n'a d'autre qui ont autre chose ca serait cool :D


---------------
Tout à commencé par un rêve...

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation

  Algorithme...

 

Sujets relatifs
(VB6) algorithme de rechercheAlgorithme / Algorigramme
[Algorithme][PERL] Trie, recherche sur des fichiersalgorithme de johnson
Algorithme et AnalyseAlgorithme programmation
[javascript] c'est un problème d'algorithme?algorithme de bellman
algorithme pour retouche d'imageAlgorithme de compression MP3
Plus de sujets relatifs à : Algorithme...


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR