Programming

    • Programming

      So how many of you are programmers and what languages do you know?

      I know XHTML and CSS which are not exactly programming languages but I also know basic PHP which I plan to improve once I can afford to buy this great book on Amazon that I found which covers OO PHP and teaches you how to build things like a forum and eCommerce system! I also plan to learn JavaScript and Ajax.
    • Re: Programming

      I've taken just a few classes, I know enough html to get around if I need to from scrap, any web design programs are a piece of cake.

      I'm in a Java class right now, I can do quite a bit in it, but there is still LOADS for me to learn.
      I'm Proud to be an American.
      Pro-Choice Before Conception, Pro-Life After.
      A person cannot help what they Feel, only what they Do.
      You will never find proof of a god... because it's Faith
    • Re: Programming

      01101000 01101111 01110111 00100000 01101101 01110101 01100011 01101000 00100000 01110111 01101111 01101111 01100100 00101100 00100000 01110111 01101111 01110101 01101100 01100100 00100000 01100001 00100000 01110111 01101111 01101111 01100100 01100011 01101000 01110101 01100011 01101011 00100000 01100011 01101000 01110101 01100011 01101011 00101100 00100000 01101001 01100110 00100000 01100001 00100000 01110111 01101111 01101111 01100100 01100011 01101000 01110101 01100011 01101011 00100000 01100011 01101111 01110101 01101100 01100100 00100000 01100011 01101000 01110101 01100011 01101011 00100000 01110111 01101111 01101111 01100100 00111111
      [CENTER][SIZE=4][/SIZE][SIZE=2]Can you imagine what I would do if I could do all I can?[/SIZE] [/CENTER]
    • Re: Programming

      DamnImGood wrote:

      Do you really want people posting long lists of code snippets?


      why not?

      C Source Code

      1. #include <stdio.h>
      2. #include <stdlib.h>
      3. #include <string.h>
      4. #include <unistd.h>
      5. #include <sys/types.h>
      6. #include <sys/stat.h>
      7. #include <openssl/sha.h>
      8. #include <openssl/evp.h>
      9. #define BUF_SIZE 0x100000
      10. #define SHA256_DIGEST_LENGTH 32
      11. typedef unsigned char uint8;
      12. typedef unsigned int uint32;
      13. typedef unsigned long long uint64;
      14. uint64 u32_to_u64(uint32 msq, uint32 lsq) {
      15. uint64 ms = (uint64)msq;
      16. uint64 ls = (uint64)lsq;
      17. return ls | (ms << 32);
      18. }
      19. uint64 hash_platform(const char* platform) {
      20. uint8* md = malloc(SHA_DIGEST_LENGTH);
      21. SHA1(platform, strlen(platform), md);
      22. uint64 hash = u32_to_u64(
      23. ((md[0] << 24) | (md[1] << 16) | (md[2] << 8) | md[3]),
      24. ((md[4] << 24) | (md[5] << 16) | (md[6] << 8) | md[7])
      25. );
      26. free(md);
      27. return hash;
      28. }
      29. uint64 ramdisk_size(const char* ramdisk) {
      30. struct stat filestat;
      31. if(stat(ramdisk, &filestat) < 0) {
      32. return 0;
      33. }
      34. return (uint64)filestat.st_size;
      35. }
      36. void keydump(uint8* passphrase,int l) {
      37. int i=0;
      38. for(i=0; i<l; i++) {
      39. printf("%02x", passphrase[i]);
      40. } printf("n");
      41. }
      42. int compare(const uint32* a, const uint32* b) {
      43. if(*a < *b) return -1;
      44. if(*a > *b) return 1;
      45. return 0;
      46. }
      47. const char platform[]="s5l8900x";
      48. const char ramdisk[]="ramdisk.dmg";
      49. int main(int argc, char* argv[]) {
      50. if(argc<3) {printf("%s: <platform> <ramdisk> <main>n", argv[0]); return -1;}
      51. uint32 saltedHash[4];
      52. uint64 salt[4];
      53. salt[0] = 0xad79d29de5e2ac9e;
      54. salt[1] = 0xe6af2eb19e23925b;
      55. salt[2] = 0x3f1375b4bd88815c;
      56. salt[3] = 0x3bdff4e5564a9f87;
      57. FILE* fd = fopen(argv[2], "rb");
      58. int i = 0;
      59. int x = 0;
      60. SHA256_CTX ctx;
      61. uint8* buffer = NULL;
      62. uint8* passphrase = NULL;
      63. uint64 totalSize = ramdisk_size(argv[2]);
      64. uint64 platformHash = hash_platform(argv[1]);
      65. /*printf("size: %I64x plat: %s plathash %I64xn", totalSize,
      66. platform,platformHash);*/
      67. for(i=0;i<4;i++)
      68. {
      69. salt[i]+=platformHash;
      70. //printf("%d: %I64xn", i, salt[i]);
      71. }
      72. for(i = 0; i < 4; i++) {
      73. saltedHash[i] = ((uint32)(salt[i] % totalSize)) & 0xFFFFFE00;
      74. }
      75. qsort(&saltedHash, 4, 4, &compare);
      76. SHA256_Init(&ctx);
      77. SHA256_Update(&ctx, salt, 32);
      78. int r=0;
      79. i=0; //hash count
      80. buffer = malloc(BUF_SIZE);
      81. passphrase = malloc(SHA256_DIGEST_LENGTH);
      82. while(r<totalSize) {
      83. x = fread(buffer, 1, BUF_SIZE, fd);
      84. SHA256_Update(&ctx, buffer, x);
      85. if(i<4) //some salts remain
      86. {
      87. if(r >= (saltedHash[i]+0x4000)) i++;
      88. else if( r < saltedHash[i] && saltedHash[i] < (r+x) )
      89. {
      90. if( (saltedHash[i]+0x4000) < r )
      91. SHA256_Update(&ctx, buffer, saltedHash[i]-r);
      92. else SHA256_Update(&ctx, buffer+(saltedHash[i]-r),
      93. ( (x-(saltedHash[i]-r))<0x4000) ? (x-(saltedHash[i]-r)) : 0x4000 );
      94. }
      95. }
      96. r+=x;
      97. }
      98. fclose(fd);
      99. SHA256_Final(passphrase, &ctx);
      100. printf("passphrase: ");
      101. keydump(passphrase, SHA256_DIGEST_LENGTH);
      102. if(buffer) free(buffer);
      103. if(argc==4) //do main as well
      104. {
      105. fd=fopen(argv[3],"rb");
      106. EVP_CIPHER_CTX ctx;
      107. int offset=0x1D4;
      108. uint8 data[0x30];
      109. uint8 out[0x30]; int outlen,tmplen;
      110. int a;
      111. for(a=0;a<7;a++)
      112. {
      113. fseek(fd, offset, SEEK_SET); offset+=0x268;
      114. fread(data, 1, 0x30, fd);
      115. EVP_CIPHER_CTX_init(&ctx);
      116. EVP_DecryptInit_ex(&ctx, EVP_des_ede3_cbc(),
      117. NULL, passphrase, &passphrase[24]);
      118. EVP_DecryptUpdate(&ctx, out, &outlen, data, 0x30);
      119. if(!EVP_DecryptFinal_ex(&ctx, out + outlen, &tmplen))
      120. printf("not block %dn", a);
      121. else
      122. break;
      123. }
      124. printf("vfdecryptk: ");
      125. keydump(out, 0x24);
      126. }
      127. if(passphrase) free(passphrase);
      128. return 0;
      129. }
      Display All
      [CENTER][/CENTER]

      [CENTER][COLOR="Red"]The blog of DaveTaylor![/COLOR][/CENTER]