Advertisement
Guest User

Untitled

a guest
Jun 6th, 2010
877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5.  
  6. //operazioni sui bits
  7. #define bit_get(p,m) ((p) & (m))
  8. #define bit_set(p,m) ((p) |= (m))
  9. #define bit_clear(p,m) ((p) &= ~(m))
  10. #define bit_flip(p,m) ((p) ^= (m))
  11. #define bit_write(c,p,m) (c ? bit_set(p,m) : bit_clear(p,m))
  12. #define BIT(x) (0x01 << (x))
  13. #define LONGBIT(x) ((unsigned long)0x00000001 << (x))
  14.  
  15. int main( int argc, char **argv )
  16. {
  17. unsigned int v1,v0,a0,a1,a3,t0;
  18. unsigned int bitmask = 0xF;
  19. unsigned int mac[6];
  20.  
  21.  
  22. if( argc != 3 )
  23. {
  24. fprintf( stderr, "\nUsage: %s <SSID> <MAC>\n\n" , argv[0] );
  25. exit( -1 );
  26. }
  27.  
  28. printf( ":: SSID: %s \n" , argv[1] );
  29. printf( ":: MAC: %s \n" , argv[2] );
  30.  
  31. printf( "Computing WPA key...\n" );
  32.  
  33. sscanf( argv[2], "%x:%x:%x:%x:%x:%x", mac, mac+1, mac+2, mac+3, mac+4, mac+5 );
  34.  
  35. printf( ":: Splitting MAC: 0x%x : 0x%x : 0x%x : 0x%x : 0x%x : 0x%x \n" , mac[0], mac[1],mac[2],mac[3],mac[4],mac[5] );
  36.  
  37.  
  38. v1 = mac[2];
  39. v0 = mac[3];
  40. a0 = mac[4];
  41. v1 = (mac[2] & bitmask);
  42. a1 = mac[5];
  43. v0 = v0 << 16;
  44. v1 = v1 << 24;
  45. bit_set(v1,v0);
  46. a0 = a0 << 8;
  47. bit_set(v1,a0);
  48. bit_set(v1,a1);
  49.  
  50. printf("Valore di v1: \t %x\n", v1);
  51.  
  52.  
  53. v0 = 0x55E63B89;
  54. v0 = (v1*v0);
  55. v0 = v0 >> 57;
  56.  
  57. t0 = v0 * 0x5f5e100;
  58. a3 = v1 - t0;
  59.  
  60. printf("valore di a3: \t %x\n", a3);
  61.  
  62. return 0;
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement