├── HashDiff.sln ├── HashDiff.suo ├── HashDiff ├── HashCalc.cpp ├── HashCalc.h ├── HashCompare.cpp ├── HashCompare.h ├── HashDiff.aps ├── HashDiff.cpp ├── HashDiff.h ├── HashDiff.rc ├── HashDiff.vcxproj ├── HashDiff.vcxproj.filters ├── HashDiff.vcxproj.user ├── HashDiffDlg.cpp ├── HashDiffDlg.h ├── ReadMe.cpp ├── ReadMe.h ├── ReadMe.txt ├── Search.cpp ├── Search.h ├── Volume.h ├── common.cpp ├── common.h ├── crc32.cpp ├── crc32.h ├── md5.cpp ├── md5.h ├── res │ ├── HashDiff.ico │ └── HashDiff.rc2 ├── resource.h ├── sha1.cpp ├── sha1.h ├── sha256.cpp ├── sha256.h ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── LICENSE └── README.md /HashDiff.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HashDiff", "HashDiff\HashDiff.vcxproj", "{9A1BCBC0-4B00-4DA5-BD6F-994E1FEE635F}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {9A1BCBC0-4B00-4DA5-BD6F-994E1FEE635F}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {9A1BCBC0-4B00-4DA5-BD6F-994E1FEE635F}.Debug|Win32.Build.0 = Debug|Win32 14 | {9A1BCBC0-4B00-4DA5-BD6F-994E1FEE635F}.Release|Win32.ActiveCfg = Release|Win32 15 | {9A1BCBC0-4B00-4DA5-BD6F-994E1FEE635F}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /HashDiff.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff.suo -------------------------------------------------------------------------------- /HashDiff/HashCalc.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/HashCalc.cpp -------------------------------------------------------------------------------- /HashDiff/HashCalc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/HashCalc.h -------------------------------------------------------------------------------- /HashDiff/HashCompare.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/HashCompare.cpp -------------------------------------------------------------------------------- /HashDiff/HashCompare.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/HashCompare.h -------------------------------------------------------------------------------- /HashDiff/HashDiff.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/HashDiff.aps -------------------------------------------------------------------------------- /HashDiff/HashDiff.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/HashDiff.cpp -------------------------------------------------------------------------------- /HashDiff/HashDiff.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/HashDiff.h -------------------------------------------------------------------------------- /HashDiff/HashDiff.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/HashDiff.rc -------------------------------------------------------------------------------- /HashDiff/HashDiff.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {9A1BCBC0-4B00-4DA5-BD6F-994E1FEE635F} 15 | HashDiff 16 | MFCProj 17 | 18 | 19 | 20 | Application 21 | true 22 | Unicode 23 | Static 24 | 25 | 26 | Application 27 | false 28 | true 29 | Unicode 30 | Static 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | Use 51 | Level3 52 | Disabled 53 | WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) 54 | 55 | 56 | Windows 57 | true 58 | 59 | 60 | false 61 | true 62 | _DEBUG;%(PreprocessorDefinitions) 63 | 64 | 65 | 0x0804 66 | _DEBUG;%(PreprocessorDefinitions) 67 | $(IntDir);%(AdditionalIncludeDirectories) 68 | 69 | 70 | 71 | 72 | Level3 73 | Use 74 | MaxSpeed 75 | true 76 | true 77 | WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) 78 | ProgramDatabase 79 | 80 | 81 | Windows 82 | false 83 | true 84 | true 85 | AsInvoker 86 | 87 | 88 | false 89 | true 90 | NDEBUG;%(PreprocessorDefinitions) 91 | 92 | 93 | 0x0804 94 | NDEBUG;%(PreprocessorDefinitions) 95 | $(IntDir);%(AdditionalIncludeDirectories) 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | Use 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | Create 135 | Create 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /HashDiff/HashDiff.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 资源文件 21 | 22 | 23 | 资源文件 24 | 25 | 26 | 27 | 28 | 头文件 29 | 30 | 31 | 头文件 32 | 33 | 34 | 头文件 35 | 36 | 37 | 头文件 38 | 39 | 40 | 头文件 41 | 42 | 43 | 头文件 44 | 45 | 46 | 头文件 47 | 48 | 49 | 头文件 50 | 51 | 52 | 头文件 53 | 54 | 55 | 头文件 56 | 57 | 58 | 头文件 59 | 60 | 61 | 头文件 62 | 63 | 64 | 头文件 65 | 66 | 67 | 头文件 68 | 69 | 70 | 71 | 72 | 源文件 73 | 74 | 75 | 源文件 76 | 77 | 78 | 源文件 79 | 80 | 81 | 源文件 82 | 83 | 84 | 源文件 85 | 86 | 87 | 源文件 88 | 89 | 90 | 源文件 91 | 92 | 93 | 源文件 94 | 95 | 96 | 源文件 97 | 98 | 99 | 源文件 100 | 101 | 102 | 源文件 103 | 104 | 105 | 源文件 106 | 107 | 108 | 109 | 110 | 资源文件 111 | 112 | 113 | -------------------------------------------------------------------------------- /HashDiff/HashDiff.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /HashDiff/HashDiffDlg.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/HashDiffDlg.cpp -------------------------------------------------------------------------------- /HashDiff/HashDiffDlg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/HashDiffDlg.h -------------------------------------------------------------------------------- /HashDiff/ReadMe.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/ReadMe.cpp -------------------------------------------------------------------------------- /HashDiff/ReadMe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/ReadMe.h -------------------------------------------------------------------------------- /HashDiff/ReadMe.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/ReadMe.txt -------------------------------------------------------------------------------- /HashDiff/Search.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/Search.cpp -------------------------------------------------------------------------------- /HashDiff/Search.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/Search.h -------------------------------------------------------------------------------- /HashDiff/Volume.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/Volume.h -------------------------------------------------------------------------------- /HashDiff/common.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "stdafx.h" 3 | #include "common.h" 4 | void test() 5 | { 6 | 7 | } -------------------------------------------------------------------------------- /HashDiff/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H 2 | #define _COMMON_H 3 | void test(); 4 | 5 | #endif -------------------------------------------------------------------------------- /HashDiff/crc32.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "crc32.h" 3 | 4 | DWORD crc32::ploy = 0xEDB88320; 5 | DWORD crc32::initValue = 0xFFFFFFFF; 6 | DWORD crc32::endValue = 0xFFFFFFFF; 7 | 8 | 9 | crc32::crc32(void){} 10 | 11 | void crc32::init(){ 12 | for(int i = 0;i<256;i++){ 13 | DWORD temp = i; 14 | for(int j=0;j<8;j++){ 15 | if(temp&1){ 16 | temp = (temp>>1)^ploy; 17 | } 18 | else{ 19 | temp>>=1; 20 | } 21 | } 22 | this->crc32_table[i] = temp; 23 | } 24 | } 25 | 26 | void crc32::calc(){ 27 | 28 | 29 | } 30 | 31 | crc32::crc32(HANDLE file,DWORD size) 32 | { 33 | crc32Value = 0; 34 | DWORD k = SetFilePointer(file,0,0,0); 35 | this->crc32_table = new DWORD[256]; 36 | crc32::init(); 37 | this->realSize = new DWORD; 38 | this->buffer = new BYTE[size+10]; 39 | ReadFile(file,buffer,size,realSize,NULL); 40 | DWORD remain = initValue; 41 | for(int pos = 0;posbuffer[pos]; 43 | remain = (remain>>8)^crc32_table[j%256]; 44 | } 45 | remain = remain^endValue; 46 | //printf("%X\n",remain); 47 | crc32Value = remain; 48 | } 49 | 50 | 51 | 52 | crc32::~crc32(void) 53 | { 54 | /* 55 | delete this->crc32_table; 56 | delete this->buffer; 57 | delete this->realSize; 58 | */ 59 | } 60 | -------------------------------------------------------------------------------- /HashDiff/crc32.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class crc32 3 | { 4 | public: 5 | crc32(void); 6 | crc32(HANDLE,DWORD); 7 | ~crc32(void); 8 | DWORD crc32Value; 9 | 10 | private: 11 | void init(); 12 | void calc(); 13 | 14 | static DWORD ploy; 15 | static DWORD initValue; 16 | static DWORD endValue; 17 | 18 | BYTE *buffer; 19 | DWORD *realSize; 20 | DWORD *crc32_table; 21 | 22 | 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /HashDiff/md5.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/md5.cpp -------------------------------------------------------------------------------- /HashDiff/md5.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/md5.h -------------------------------------------------------------------------------- /HashDiff/res/HashDiff.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/res/HashDiff.ico -------------------------------------------------------------------------------- /HashDiff/res/HashDiff.rc2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/res/HashDiff.rc2 -------------------------------------------------------------------------------- /HashDiff/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/resource.h -------------------------------------------------------------------------------- /HashDiff/sha1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/sha1.cpp -------------------------------------------------------------------------------- /HashDiff/sha1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/sha1.h -------------------------------------------------------------------------------- /HashDiff/sha256.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | #include 4 | #include "sha256.h" 5 | #include "stdio.h" 6 | 7 | const unsigned int SHA256::sha256_k[64] = //UL = uint32 8 | { 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 9 | 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 10 | 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 11 | 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 12 | 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 13 | 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 14 | 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 15 | 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 16 | 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 17 | 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 18 | 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 19 | 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 20 | 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 21 | 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 22 | 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 23 | 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 }; 24 | 25 | void SHA256::transform(const unsigned char *message, unsigned int block_nb) 26 | { 27 | uint32 w[64]; 28 | uint32 wv[8]; 29 | uint32 t1, t2; 30 | const unsigned char *sub_block; 31 | int i; 32 | int j; 33 | for (i = 0; i < (int)block_nb; i++) { 34 | sub_block = message + (i << 6); 35 | for (j = 0; j < 16; j++) { 36 | SHA2_PACK32(&sub_block[j << 2], &w[j]); 37 | } 38 | for (j = 16; j < 64; j++) { 39 | w[j] = SHA256_F4(w[j - 2]) + w[j - 7] + SHA256_F3(w[j - 15]) + w[j - 16]; 40 | } 41 | for (j = 0; j < 8; j++) { 42 | wv[j] = m_h[j]; 43 | 44 | } 45 | 46 | for (j = 0; j < 64; j++) { 47 | t1 = wv[7] + SHA256_F2(wv[4]) + SHA2_CH(wv[4], wv[5], wv[6]) 48 | + sha256_k[j] + w[j]; 49 | t2 = SHA256_F1(wv[0]) + SHA2_MAJ(wv[0], wv[1], wv[2]); 50 | wv[7] = wv[6]; 51 | wv[6] = wv[5]; 52 | wv[5] = wv[4]; 53 | wv[4] = wv[3] + t1; 54 | wv[3] = wv[2]; 55 | wv[2] = wv[1]; 56 | wv[1] = wv[0]; 57 | wv[0] = t1 + t2; 58 | } 59 | for (j = 0; j < 8; j++) { 60 | m_h[j] += wv[j]; 61 | } 62 | } 63 | } 64 | 65 | void SHA256::init() 66 | { 67 | m_h[0] = 0x6a09e667; 68 | m_h[1] = 0xbb67ae85; 69 | m_h[2] = 0x3c6ef372; 70 | m_h[3] = 0xa54ff53a; 71 | m_h[4] = 0x510e527f; 72 | m_h[5] = 0x9b05688c; 73 | m_h[6] = 0x1f83d9ab; 74 | m_h[7] = 0x5be0cd19; 75 | m_len = 0; 76 | m_tot_len = 0; 77 | } 78 | 79 | void SHA256::update(const unsigned char *message, unsigned int len) 80 | { 81 | unsigned int block_nb; 82 | unsigned int new_len, rem_len, tmp_len; 83 | const unsigned char *shifted_message; 84 | tmp_len = SHA224_256_BLOCK_SIZE - m_len; 85 | rem_len = len < tmp_len ? len : tmp_len; 86 | memcpy(&m_block[m_len], message, rem_len); 87 | if (m_len + len < SHA224_256_BLOCK_SIZE) { 88 | m_len += len; 89 | return; 90 | } 91 | new_len = len - rem_len; 92 | block_nb = new_len / SHA224_256_BLOCK_SIZE; 93 | shifted_message = message + rem_len; 94 | transform(m_block, 1); 95 | transform(shifted_message, block_nb); 96 | rem_len = new_len % SHA224_256_BLOCK_SIZE; 97 | memcpy(m_block, &shifted_message[block_nb << 6], rem_len); 98 | m_len = rem_len; 99 | m_tot_len += (block_nb + 1) << 6; 100 | } 101 | 102 | void SHA256::final(unsigned char *digest) 103 | { 104 | unsigned int block_nb; 105 | unsigned int pm_len; 106 | unsigned int len_b; 107 | int i; 108 | block_nb = (1 + ((SHA224_256_BLOCK_SIZE - 9) 109 | < (m_len % SHA224_256_BLOCK_SIZE))); 110 | len_b = (m_tot_len + m_len) << 3; 111 | pm_len = block_nb << 6; 112 | memset(m_block + m_len, 0, pm_len - m_len); 113 | m_block[m_len] = 0x80; 114 | SHA2_UNPACK32(len_b, m_block + pm_len - 4); 115 | transform(m_block, block_nb); 116 | for (i = 0; i < 8; i++) { 117 | SHA2_UNPACK32(m_h[i], &digest[i << 2]); 118 | } 119 | } 120 | 121 | std::string sha256(std::string input) 122 | { 123 | unsigned char digest[SHA256::DIGEST_SIZE]; 124 | memset(digest, 0, SHA256::DIGEST_SIZE); 125 | 126 | SHA256 ctx = SHA256(); 127 | ctx.init(); 128 | ctx.update((unsigned char*)input.c_str(), input.length()); 129 | ctx.final(digest); 130 | 131 | char buf[2 * SHA256::DIGEST_SIZE + 1]; 132 | buf[2 * SHA256::DIGEST_SIZE] = 0; 133 | for (int i = 0; i < SHA256::DIGEST_SIZE; i++) 134 | sprintf_s(buf + i * 2, 3,"%02x", digest[i]); 135 | return std::string(buf); 136 | } 137 | 138 | -------------------------------------------------------------------------------- /HashDiff/sha256.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef SHA256_H 3 | #define SHA256_H 4 | #include 5 | 6 | class SHA256 7 | { 8 | protected: 9 | typedef unsigned char uint8; 10 | typedef unsigned int uint32; 11 | typedef unsigned long long uint64; 12 | 13 | const static uint32 sha256_k[]; 14 | static const unsigned int SHA224_256_BLOCK_SIZE = (512 / 8); 15 | public: 16 | void init(); 17 | void update(const unsigned char *message, unsigned int len); 18 | void final(unsigned char *digest); 19 | static const unsigned int DIGEST_SIZE = (256 / 8); 20 | 21 | protected: 22 | void transform(const unsigned char *message, unsigned int block_nb); 23 | unsigned int m_tot_len; 24 | unsigned int m_len; 25 | unsigned char m_block[2 * SHA224_256_BLOCK_SIZE]; 26 | uint32 m_h[8]; 27 | }; 28 | 29 | std::string sha256(std::string input); 30 | 31 | #define SHA2_SHFR(x, n) (x >> n) 32 | #define SHA2_ROTR(x, n) ((x >> n) | (x << ((sizeof(x) << 3) - n))) 33 | #define SHA2_ROTL(x, n) ((x << n) | (x >> ((sizeof(x) << 3) - n))) 34 | #define SHA2_CH(x, y, z) ((x & y) ^ (~x & z)) 35 | #define SHA2_MAJ(x, y, z) ((x & y) ^ (x & z) ^ (y & z)) 36 | #define SHA256_F1(x) (SHA2_ROTR(x, 2) ^ SHA2_ROTR(x, 13) ^ SHA2_ROTR(x, 22)) 37 | #define SHA256_F2(x) (SHA2_ROTR(x, 6) ^ SHA2_ROTR(x, 11) ^ SHA2_ROTR(x, 25)) 38 | #define SHA256_F3(x) (SHA2_ROTR(x, 7) ^ SHA2_ROTR(x, 18) ^ SHA2_SHFR(x, 3)) 39 | #define SHA256_F4(x) (SHA2_ROTR(x, 17) ^ SHA2_ROTR(x, 19) ^ SHA2_SHFR(x, 10)) 40 | 41 | //#define SHA256_F1(x) ((x >> 2 | x << 30) ^ (x >> 13 | x << 19) ^ (x >> 22 | x << 10)) 42 | //#define SHA256_F2(x) ((x >> 6 | x << 26) ^ (x >> 11 | x << 21) ^ (x >> 25 | x << 7)) 43 | //#define SHA256_F3(x) ((x >> 7 | x << 25) ^ (x >> 18 | x << 14) ^ (x >> 3)) 44 | //#define SHA256_F4(x) ((x >> 17 | x << 15) ^ (x >> 19 | x << 13) ^ (x >> 10)) 45 | 46 | #define SHA2_UNPACK32(x, str) \ 47 | { \ 48 | *((str) + 3) = (uint8) ((x) ); \ 49 | *((str) + 2) = (uint8) ((x) >> 8); \ 50 | *((str) + 1) = (uint8) ((x) >> 16); \ 51 | *((str) + 0) = (uint8) ((x) >> 24); \ 52 | } 53 | #define SHA2_PACK32(str, x) \ 54 | { \ 55 | *(x) = ((uint32) *((str) + 3) ) \ 56 | | ((uint32) *((str) + 2) << 8) \ 57 | | ((uint32) *((str) + 1) << 16) \ 58 | | ((uint32) *((str) + 0) << 24); \ 59 | } 60 | #endif -------------------------------------------------------------------------------- /HashDiff/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/stdafx.cpp -------------------------------------------------------------------------------- /HashDiff/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/stdafx.h -------------------------------------------------------------------------------- /HashDiff/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggg4566/HashDiff/1e7c31e6c6ceb7dfe1db4d43e70f49574c1d923a/HashDiff/targetver.h -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HashDiff 2 | 应急响应辅助工具,根据样本hash 全盘检索 3 | 4 | win10 vs2010 vc++ mfc 5 | 6 | 运行平台:OS >=win7 NTFS 格式硬盘 7 | 8 | # 功能 9 | 10 | ## 文件快速搜索 11 | 12 | 类似everything的搜索功能,第一次搜索需要花费时间建立索引,代码和原理: 13 | 14 | https://github.com/LeiHao0/Fake-Everything 15 | 16 | ![](https://user-images.githubusercontent.com/7532477/132863751-fed089a4-f361-45b2-a006-698ec3cc4c18.png) 17 | 18 | 19 | ## 根据hash检索文件 20 | 21 | a)支持全盘以及特定文件检索 22 | 23 | b) 使用windows线程池加快检索速度,不要设置太高,默认线程数量 10~30 24 | 25 | c) 在已知样本的情况下可以设置样本的大小来加快搜索速度 26 | 27 | ![](https://user-images.githubusercontent.com/7532477/132863853-545337a9-73a5-458d-9823-07d5b5afaba1.png) 28 | 29 | 30 | ## hash 计算 31 | 32 | ![](https://user-images.githubusercontent.com/7532477/132863936-b804bac3-9002-4409-80fc-2b45ed91cd5a.png) 33 | 34 | 35 | 36 | # 致谢: 37 | 38 | https://github.com/LeiHao0/Fake-Everything 39 | 40 | https://github.com/cpp518/HashCalculator 41 | 42 | 43 | --------------------------------------------------------------------------------