Advertisement
Guest User

Untitled

a guest
Aug 30th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.93 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <time.h>
  4.  
  5. #define mystr "Minha própria utilidade. Copyright (C) 2007-2010 hpgl, Russia"
  6.  
  7. #define allow595B
  8. #define allowA95B
  9. #define allow2A7B
  10.  
  11. #define fSVCTAG 0
  12. #define fHDDSN 1
  13. #define fHDDold 2
  14. #define t595B 0
  15. #define tD35B 1
  16. #define tA95B 2
  17. #define t2A7B 3
  18.  
  19. #ifdef allow595B
  20. #define f595B
  21. #fim se
  22. #ifdef allowA95B
  23. #define f595B
  24. #fim se
  25. #ifdef allow2A7B
  26. #define f595B
  27. #fim se
  28.  
  29. char bSuffix [] = "595BD35BA95B2A7B";
  30.  
  31. char scancods [] = "\ 00 \ 0331234567890 - = \ 010 \ 011qwertyuiop [] \ 015 \ 377asdfghjkl; '` \ 377 \\ zxcvbnm, ./ ";
  32. char encscans [] = {0x05,0x10,0x13,0x09,0x32,0x03,0x25,0x11,0x1F, 0x17,0x06,0x15, \
  33. 0x30,0x19,0x26,0x22,0x0A, 0x02,0x2C, 0x2F, 0x16,0x14,0x07,0x18, \
  34. 0x24,0x23,0x31,0x20,0x1E, 0x08,0x2D, ​​0x21,0x04,0x0B, 0x12,0x2E};
  35.  
  36. #ifdef allow2A7B
  37. char chartabl2A7B [72] = "012345679abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0";
  38. #fim se
  39.  
  40. não assinado int MD5magic [64] = {
  41. 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
  42. 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
  43. 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
  44. 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
  45. 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
  46. 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
  47. 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
  48. 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
  49. 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
  50. 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
  51. 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05,
  52. 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
  53. 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
  54. 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
  55. 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
  56. 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391};
  57.  
  58. char não assinado inData [23], outData [16];
  59. char buf1output [32], buf1input [20];
  60. char bug4;
  61.  
  62. void calcsuffix (char bfunc, char btype, char * outbuf);
  63.  
  64. void initData (void) {
  65. * (int *) (& outData [0]) = 0x67452301;
  66. * (int *) (& outData [4]) = 0xEFCDAB89;
  67. * (int *) (& outData [8]) = 0x98BADCFE;
  68. * (int *) (& outData [12]) = 0x10325476;
  69. }
  70.  
  71. typedef int (encfuncT1) (int num1, int num2, int num3);
  72.  
  73. #ifdef f595B
  74. int enc0F2 (int num1, int num2, num3 int) {return (((num3 num2 numérico) num1) num3);}
  75. int enc0F4 (int num1, int num2, int num3) {return ((num2 num1 numérico) num3); }
  76. int enc0F5 (int num1, int num2, int num3) {return ((num1 | ~ num3) ^ num2); }
  77. #fim se
  78. int enc1F2 (int num1, int num2, int num3) {return (((num3 ^ num2) & num1) ^ num3);}
  79. int enc1F4 (num1 int, int num2, int num3) {return ((num2 ^ num1) ^ num3); }
  80. int enc1F5 (int num1, int num2, int num3) {return ((num1 | ~ num3) ^ num2); }
  81. int encF3 (int num1, int num2, int num3) {return (((num1 ^ num2) & num3) ^ num2);}
  82.  
  83. typedef int (encfuncT2) (função encfuncT1, int num1, int num2, int num3, tecla int);
  84.  
  85. int enc1F1 (função encfuncT1, int num1, int num2, int num3, tecla int)
  86. {
  87. return func (num1, num2, num3) + tecla;
  88. }
  89.  
  90. #ifdef f595B
  91. int enc0F1 (função encfuncT1, int num1, int num2, int num3, tecla int)
  92. {
  93. função return func (num1, num2, num3);
  94. }
  95. #fim se
  96.  
  97. int rol unsigned (não assinado int t, int bitsrot)
  98. {
  99. return (t >> (32-bitsrot)) | (t << bitsrot);
  100. }
  101.  
  102. void blockEncodeF (int * outdata, int * encblock, encfuncT2 func1,
  103. encfuncT1 func2, encfuncT1 func3, encfuncT1 func4, encfuncT1 func5)
  104. {
  105. char S [4] [4] = {{7, 12, 17, 22}, {5, 9, 14, 20}, {4, 11, 16, 23}, {6, 10, 15, 21}} ;
  106. int A, B, C, D, t, i;
  107.  
  108. A = outdata [0];
  109. B = outdata [1];
  110. C = outdata [2];
  111. D = outdata [3];
  112.  
  113. para (i = 0; i <64; i ++) {t = MD5magic [i]; interruptor (i >> 4) {
  114. caso 0: t = A + func1 (func2, B, C, D, t + encapsulado [(i) & 15]); pausa;
  115. caso 1: t = A + func1 (func3, B, C, D, t + encapsulamento [(i * 5 + 1) & 15]); pausa;
  116. caso 2: t = A + func1 (func4, B, C, D, t + encapsulamento [(i * 3 + 5) & 15]); pausa;
  117. caso 3: t = A + func1 (func5, B, C, D, t + encapsulamento [(i * 7) & 15]); pausa;
  118. }
  119. A = D; D = C; C = B; B + = rol (t, S [i >> 4] [i e 3]);
  120. };
  121.  
  122. outdata [0] + = A;
  123. outdata [1] + = B;
  124. outdata [2] + = C;
  125. outdata [3] + = D;
  126. }
  127.  
  128. void blockEncode (char * outdata, int * encblock, char btype) {
  129. if (btype == tD35B)
  130. blockEncodeF ((int *) outdata, encblock, enc1F1, enc1F2, encF3, enc1F4, enc1F5);
  131. #ifdef f595B
  132. outro
  133. blockEncodeF ((int *) outdata, encblock, enc0F1, enc0F2, encF3, enc0F4, enc0F5);
  134. #fim se
  135. }
  136.  
  137. void codificar (char * inbuf, int cnt, char btype) {
  138. int encBlock [16];
  139. char * ptr;
  140. initData ();
  141. memcpy (encBlock, inbuf, cnt);
  142. ptr = & ((char *) encBlock) [cnt];
  143. * ptr ++ = 0x80;
  144. memset (ptr, 0,64-1-cnt);
  145. encBlock [16-2] = ((int unsigned) cnt << 3);
  146. blockEncode (outData, encBlock, btype);
  147. }
  148.  
  149. void psw (char bfunc, char btype, char * outbuf) {
  150. int cnt, i, lenpsw, r;
  151. if (bfunc == fHDDold) {
  152. memcpy (inData, buf1input, 11);
  153. // calcsuffix (bfunc, btype, outbuf);
  154. para (cnt = 0; cnt <8; cnt ++) outbuf [cnt] = scancods [outbuf [cnt]]; } else {memset (inData, 0, sizeof (inData)); if (bfunc == fSVCTAG) cnt = 7; else cnt = 11; if ((bfunc == fHDDSN) && (btype == tA95B)) memcpy (inData, & buf1input [3], cnt-3); mais memcpy (inData, buf1input, cnt); if (btype == t595B) memcpy (& emData [cnt], & bSuffix [0], 4); else if (btype == tD35B) memcpy (& inData [cnt], & bSuffix [4], 4); else if (btype == tA95B) memcpy (& inData [cnt], & bSuffix [0], 4); else if (btype == t2A7B) memcpy (& inData [cnt], & bSuffix [12], 4); cnt + = 4; inData [cnt] = inData [4] e 0x1F; inData [cnt + 1] = ((inData [4] >> 5) | (((inData [3] >> 5) | (inData [3] << 3)) & 0xF1) & 0x1F); inData [cnt + 2] = ((inData [3] >> 2) & 0x1F);
  155. inData [cnt + 3] = (inData [3] >> 7) | ((inData [2] << 1) & 0x1F); inData [cnt + 4] = (inData [2] >> 4) | ((inData [1] << 4) & 0x1F); inData [cnt + 5] = (inData [1] >> 1) & 0x1F;
  156. inData [cnt + 6] = (inData [1] >> 6) | ((inData [0] << 2) & 0x1F); inData [cnt + 7] = (inData [0] >> 3) & 0x1F;
  157. para (i = cnt; i <8 + cnt; i ++) {
  158. r = 0xAA;
  159. if (inData [i] e 1)
  160. r ^ = inData [4];
  161. if (inData [i] e 2)
  162. r ^ = inData [3];
  163. if (inData [i] e 4)
  164. r ^ = inData [2];
  165. if (inData [i] e 8)
  166. r ^ = inData [1];
  167. if (inData [i] e 16)
  168. r ^ = inData [0];
  169. inData [i] = encscans [r% sizeof (encscans)];
  170. }
  171. cnt = 23;
  172. codificar (inData, cnt, btype);
  173. r = outData [0]% 9;
  174. lenpsw = 0;
  175. para (cnt = 0; cnt <16; cnt ++) {
  176. if ((r <= cnt) && (lenpsw <8)) {buf1 saída [lenpsw ++] = scancods [encscans [outData [cnt]% tamanhoof (encscans)]]; }}}} int main (int arg, char * argv []) {unsigned char len, len1, bfunc, eol = 1, echo = 0, * menos, s2 [20]; btype de caractere assinado; int argn = 0; if (argc> 1)
  177. echo = 1;
  178.  
  179. if (! echo)
  180. fputs ("" mystr "\ n" \
  181. "A tag de serviço curta deve ser preenchida com '*' até o tamanho 7 chars \ n" \
  182. "O número de série do HDD está certo 11 caracteres do HDDSerNum real deixado acolchoado com '*' \ n" \
  183. "Algumas BIOS deixaram o número de série do pad HDD com espaços em vez de '*' \ n", stdout);
  184.  
  185. while (! feof (stdin)) {
  186. if ((argc <= 1) && argn) quebra; fputs ("Entrada: #", stdout); if (argc> 1) {
  187. strncpy (buf1input, argv [++ argn], sizeof (buf1input)); argc--;
  188. }
  189. outro {
  190. if (! eol) while (! feof (stdin) && (fgetc (stdin)! = '\ n')); eol = 0;
  191. if (fgets (buf1input, 16 + 1 + 1, stdin) == NULL) {
  192. if (echo) fputs ("\ n", stdout);
  193. pausa;
  194. }
  195. }
  196. len = strlen (buf1input);
  197. if (len && (buf1input [len-1] == '\ n')) {len -; eol = 1; buf1input [len] = 0;}
  198. if (eco) {fputs (buf1input, stdout); fputs ("\ n", stdout);}
  199. menos = strchr (buf1input, '-');
  200. if (len == 11) {
  201. if (menos! = NULL) {
  202. fputs ("- entrada incorreta \ n", stdout);
  203. continuar;
  204. }
  205. bfunc = fHDDold;
  206. fputs ("Por número de série do HDD para BIOS mais antigo:", stdout);
  207. } outro {
  208. if (len == 0) quebra;
  209. if (menos == NULL) {
  210. fputs ("- Nenhum tipo de BIOS encontrado na string de entrada, deve ser seguido por -595B e outro registrado \ n", stdout);
  211. continuar;
  212. }
  213. len1 = minus (unsigned char *) buf1input;
  214.  
  215. btype = -1;
  216. #ifdef allow595B
  217. if (strncmp (& buf1input [len1 + 1], & bSuffix [0], 4) == 0) btype = t595B;
  218. outro
  219. #fim se
  220. if (strncmp (& buf1input [len1 + 1], & bSuffix [4], 4) == 0) btype = tD35B;
  221. outro
  222. #ifdef allowA95B
  223. if (strncmp (& buf1input [len1 + 1], & bSuffix [8], 4) == 0) btype = tA95B;
  224. outro
  225. #fim se
  226. #ifdef allow2A7B
  227. if (strncmp (& buf1input [len1 + 1], & bSuffix [12], 4) == 0) btype = t2A7B;
  228. #fim se
  229. if (btype <0) {
  230. fputs ("- Tag de serviço inválida na string de entrada, permitida somente -D35B e outra registrada \ n", stdout);
  231. continuar;
  232. }
  233. struct tm * time1; time_t timer1 = time (NULL);
  234. time1 = gmtime (& timer1);
  235. strftime (s2, tamanho de (s2), "% d.% m.% Y% H:% M", tempo1);
  236. fputs (s2, stdout);
  237. fputs ("DELL", stdout);
  238.  
  239. if (len1 == 7) {
  240. bfunc = fSVCTAG;
  241. fputs ("tag de serviço:", stdout);
  242. fputs (buf1input, stdout);
  243. } outro
  244. if (len1 == 11) {
  245. bfunc = fHDDSN;
  246. fputs ("número de série do HDD:", stdout);
  247. fputs (buf1input, stdout);
  248. }
  249. outro {
  250. fputs ("- Entrada incorreta, deve ser 7 chars service tag ou 11 chars HDD serial number \ n", stdout);
  251. continuar;
  252. }
  253. }
  254. psw (bfunc, btype, buf1output);
  255. fputs ("senha:", stdout);
  256. fputs (buf1output, stdout);
  257. if (bug4) fputs ("! aviso bug4 - senha pode não funcionar!", stdout);
  258.  
  259. if (btype == t595B) if (bfunc == fSVCTAG) {// para verificar se o bug A95B
  260. char mpw1 [20];
  261. strcpy (mpw1, buf1output);
  262. psw (bfunc, tA95B, buf1output);
  263. if (strcmp (mpw1, buf1output)! = 0) {
  264. fputs ("passwordA95B:", stdout);
  265. fputs (buf1output, stdout);
  266. }
  267. }
  268. fputs ("\ n", stdout);
  269. }
  270. return 0;
  271. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement