├── README.md
└── Version 1
├── NoREpls.sln
├── NoREpls
├── NoREpls.vcxproj
├── NoREpls.vcxproj.filters
├── NoREpls.vcxproj.user
├── Resource.rc
├── aboutdlg.cpp
├── aboutdlg.h
├── anti.cpp
├── anti.h
├── helper.cpp
├── helper.h
├── main.cpp
├── md5.cpp
├── md5.h
├── nagdlg.cpp
├── nagdlg.h
├── package_installed_locked.ico
├── registration.cpp
├── registration.h
├── resource.h
└── str_obfuscator.hpp
└── README.md
/README.md:
--------------------------------------------------------------------------------
1 | # NoREpls
2 | NoREpls - Application designed for the purposes of reverse engineering.
3 |
4 | A small series designed to teach one to identify and overcome anti-reverse engineering methods for the Windows operating system.
5 |
6 | ## Version 1
7 | Part 0 - https://0x00sec.org/t/crackme-norepls-part-0/2964
8 |
9 | Part 1 - https://0x00sec.org/t/crackme-norepls-part-1/2974
10 |
11 | Part 2 - https://0x00sec.org/t/crackme-norepls-part-2/2987
12 |
13 | Part 3 - https://0x00sec.org/t/crackme-norepls-part-3/2994
14 |
15 | Part 4 - https://0x00sec.org/t/crackme-norepls-part-4/3002
16 |
17 | Part 5 - https://0x00sec.org/t/crackme-norepls-part-5/3022
18 |
19 | Part 6 - https://0x00sec.org/t/crackme-norepls-part-6/3059
20 |
21 |
22 | ## Version 2
23 | This project is currently suspended while I try and find time to develop another application.
24 |
--------------------------------------------------------------------------------
/Version 1/NoREpls.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NoREpls", "NoREpls\NoREpls.vcxproj", "{38230B77-33B2-4A81-896F-046D757A9C82}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {38230B77-33B2-4A81-896F-046D757A9C82}.Debug|x64.ActiveCfg = Debug|x64
17 | {38230B77-33B2-4A81-896F-046D757A9C82}.Debug|x64.Build.0 = Debug|x64
18 | {38230B77-33B2-4A81-896F-046D757A9C82}.Debug|x86.ActiveCfg = Debug|Win32
19 | {38230B77-33B2-4A81-896F-046D757A9C82}.Debug|x86.Build.0 = Debug|Win32
20 | {38230B77-33B2-4A81-896F-046D757A9C82}.Release|x64.ActiveCfg = Release|x64
21 | {38230B77-33B2-4A81-896F-046D757A9C82}.Release|x64.Build.0 = Release|x64
22 | {38230B77-33B2-4A81-896F-046D757A9C82}.Release|x86.ActiveCfg = Release|Win32
23 | {38230B77-33B2-4A81-896F-046D757A9C82}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/Version 1/NoREpls/NoREpls.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {38230B77-33B2-4A81-896F-046D757A9C82}
23 | Win32Proj
24 | NoREpls
25 | 8.1
26 |
27 |
28 |
29 | Application
30 | true
31 | v140
32 | Unicode
33 |
34 |
35 | Application
36 | false
37 | v140_xp
38 | true
39 | Unicode
40 |
41 |
42 | Application
43 | true
44 | v140
45 | Unicode
46 |
47 |
48 | Application
49 | false
50 | v140
51 | true
52 | Unicode
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | true
74 |
75 |
76 | true
77 |
78 |
79 | false
80 |
81 |
82 | false
83 |
84 |
85 |
86 |
87 |
88 | Level3
89 | Disabled
90 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
91 | true
92 | EnableFastChecks
93 |
94 |
95 | Windows
96 | true
97 |
98 |
99 |
100 |
101 |
102 |
103 | Level3
104 | Disabled
105 | _DEBUG;_WINDOWS;%(PreprocessorDefinitions)
106 |
107 |
108 | Windows
109 | true
110 |
111 |
112 |
113 |
114 | Level3
115 |
116 |
117 | MaxSpeed
118 | true
119 | true
120 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
121 | MultiThreaded
122 | CompileAsCpp
123 | OnlyExplicitInline
124 |
125 |
126 | Windows
127 | true
128 | true
129 | false
130 | false
131 |
132 |
133 |
134 |
135 | Level3
136 |
137 |
138 | MaxSpeed
139 | true
140 | true
141 | NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
142 |
143 |
144 | Windows
145 | true
146 | true
147 | true
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
--------------------------------------------------------------------------------
/Version 1/NoREpls/NoREpls.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;hh;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 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 | Source Files
32 |
33 |
34 | Source Files
35 |
36 |
37 | Source Files
38 |
39 |
40 |
41 |
42 | Header Files
43 |
44 |
45 | Header Files
46 |
47 |
48 | Header Files
49 |
50 |
51 | Header Files
52 |
53 |
54 | Header Files
55 |
56 |
57 | Header Files
58 |
59 |
60 | Header Files
61 |
62 |
63 | Header Files
64 |
65 |
66 |
67 |
68 | Resource Files
69 |
70 |
71 |
72 |
73 | Resource Files
74 |
75 |
76 |
--------------------------------------------------------------------------------
/Version 1/NoREpls/NoREpls.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Version 1/NoREpls/Resource.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NtRaiseHardError/NoREpls/72b660fad95513afe8d544fb907f9e855bb223fd/Version 1/NoREpls/Resource.rc
--------------------------------------------------------------------------------
/Version 1/NoREpls/aboutdlg.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "aboutdlg.h"
4 | #include "helper.h"
5 | #include "registration.h"
6 | #include "resource.h"
7 |
8 | INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
9 | switch (uMsg) {
10 | case WM_INITDIALOG:
11 | MyLoadString(IDS_STRING_VERSIONW, lpVersionW);
12 | ::SetDlgItemText(hDlg, IDC_STATIC_VERSION, lpVersionW);
13 | if (g_bRegistered) {
14 | WCHAR szTitle[MAX_PATH];
15 | MyLoadString(IDS_STRING_LICENSEFMTW, lpLicenseFmtW);
16 | wsprintf(szTitle, lpLicenseFmtW, g_szLicenseName);
17 | MyUnloadString(lpLicenseFmtW);
18 | ::SetDlgItemText(hDlg, IDC_STATIC_DEMO, szTitle);
19 | }
20 | MyUnloadString(lpVersionW);
21 | return TRUE;
22 | case WM_COMMAND:
23 | switch (LOWORD(wParam)) {
24 | case IDOK:
25 | ::EndDialog(hDlg, TRUE);
26 | return TRUE;
27 | }
28 | break;
29 |
30 | case WM_CLOSE:
31 | ::EndDialog(hDlg, TRUE);
32 | return TRUE;
33 | }
34 |
35 | return FALSE;
36 | }
--------------------------------------------------------------------------------
/Version 1/NoREpls/aboutdlg.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef __ABOUTDLG_H__
3 | #define __ABOUTDLG_H__
4 |
5 | INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
6 |
7 | #endif // !__ABOUTDLG_H__
8 |
--------------------------------------------------------------------------------
/Version 1/NoREpls/anti.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "anti.h"
4 | #include "helper.h"
5 | #include "md5.h"
6 |
7 | #pragma comment(lib, "Shlwapi.lib")
8 |
9 | #define MD5_LEN 32
10 |
11 | LPWSTR lpDbgWindow = NULL;
12 |
13 | LPWSTR DebuggerNames[] = {
14 | L"odbg",
15 | L"ollydbg",
16 | L"ida",
17 | L"immunity",
18 | L"softice",
19 | L"radare",
20 | L"gdb",
21 | L"x32dbg"
22 | /* needs more names */
23 | };
24 |
25 | LPWSTR MonitoringToolNames[] = {
26 | L"procmon",
27 | L"processhacker",
28 | L"procexp",
29 | L"wireshark"
30 | /* needs more names */
31 | };
32 |
33 | BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCWSTR lpszType, LPCWSTR lpszName, LONG_PTR lParam) {
34 | DSTRYFUNCBOUND;
35 | HRSRC hRsrc = ::FindResource(hModule, lpszName, lpszType);
36 | if (hRsrc) {
37 | DWORD dwSize = ::SizeofResource(hModule, hRsrc);
38 | HGLOBAL hResData = ::LoadResource(hModule, hRsrc);
39 | if (hResData) {
40 | LPVOID lpResource = ::LockResource(hResData);
41 | if (lpResource) {
42 | std::string digest = md5(lpResource, dwSize);
43 | if (strncmp(digest.c_str(), "f9e5a571aedde949df612d885d7d2472", MD5_LEN) && strncmp(digest.c_str(), "d11a7dd370cb977ff0a9756b34dda9af", MD5_LEN))
44 | DIE;
45 | }
46 | }
47 | }
48 |
49 | return TRUE;
50 | }
51 |
52 | BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) {
53 | DSTRYFUNCBOUND;
54 | int nLength = ::GetWindowTextLength(hwnd);
55 | LPWSTR lpWindowText = new WCHAR[nLength + 1];
56 |
57 | ANTIDIS_LINEAR;
58 | if (nLength > 0 && IsWindowVisible(hwnd)) {
59 | ::GetWindowText(hwnd, lpWindowText, nLength + 1);
60 | for (int i = 0; i < 8; i++)
61 | if (::StrStrI(lpWindowText, DebuggerNames[i]) != NULL) {
62 | DIE;
63 | }
64 | for (int i = 0; i < 4; i++)
65 | if (::StrStrI(lpWindowText, MonitoringToolNames[i]) != NULL) {
66 | DIE;
67 | }
68 | }
69 |
70 | delete[] lpWindowText;
71 |
72 | return TRUE;
73 | }
74 |
75 | void CheckDebuggerWindows() {
76 | ANTIDIS_LINEAR;
77 | ::EnumWindows(EnumWindowsProc, 0);
78 | }
--------------------------------------------------------------------------------
/Version 1/NoREpls/anti.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef __ANTI_H__
3 | #define __ANTI_H__
4 |
5 | #include
6 |
7 | #define DIE ::ExitProcess(0)
8 | // anti v2.2
9 | #define DIE_ASM __asm push 0 __asm call ExitProcess
10 | //anti 2.3
11 | //#define DIE_HARD_ASM __asm _emit 0xE9
12 |
13 | // anti v2.2
14 | #define ANTIDIS_LINEAR __asm { \
15 | __asm xor eax, eax \
16 | __asm _emit 0x75 \
17 | __asm _emit 0x07 \
18 | __asm _emit 0x74 \
19 | __asm _emit 0x06 \
20 | __asm jmp $ + 10 \
21 | __asm _emit 0x6A \
22 | }
23 |
24 | #define CheckFuncInt3(x) __asm { \
25 | __asm pushad \
26 | __asm mov eax, x \
27 | __asm mov cl, 0xCC \
28 | __asm cmp BYTE PTR [eax], cl \
29 | __asm _emit 0x75 \
30 | __asm _emit 0x01 \
31 | DIE_ASM \
32 | __asm popad \
33 | }
34 |
35 | #ifndef _DEBUG
36 | #define ISDBGPRSNT __asm { \
37 | __asm pushad \
38 | __asm mov eax, fs:[0x30] \
39 | __asm movzx eax, [eax + 0x2] \
40 | __asm _emit 0x74 \
41 | __asm _emit 0x01 \
42 | DIE_ASM \
43 | __asm popad \
44 | }
45 | #else
46 | #define ISDBGPRSNT __asm nop
47 | #endif // !_DEBUG
48 |
49 | #define DSTRYFUNCBOUND __asm { \
50 | __asm call $ + 5 \
51 | __asm pop eax \
52 | __asm add eax, 6 \
53 | __asm _emit 0x50 \
54 | __asm ret \
55 | }
56 |
57 | extern LPWSTR lpDbgWindow;
58 |
59 | BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCWSTR lpszType, LPCWSTR lpszName, LONG_PTR lParam);
60 | BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);
61 | void CheckDebuggerWindows(void);
62 |
63 | __forceinline bool StringTableCheck() {
64 | ::EnumResourceNames(NULL, MAKEINTRESOURCE(RT_STRING), (ENUMRESNAMEPROC)EnumResNameProc, 0);
65 | return true;
66 | }
67 |
68 | // anti
69 | struct _anti {
70 | _anti() {
71 | #ifndef _DEBUG
72 | // IsDebuggerPresent v2.1
73 | ANTIDIS_LINEAR
74 | ISDBGPRSNT
75 | #endif // !_DEBUG
76 | }
77 | };
78 |
79 | #endif // !__ANTI_H__
80 |
--------------------------------------------------------------------------------
/Version 1/NoREpls/helper.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "helper.h"
4 |
5 | BOOL FileExists(LPCWSTR szPath) {
6 | DWORD dwAttrib = ::GetFileAttributes(szPath);
7 |
8 | return (dwAttrib != INVALID_FILE_ATTRIBUTES &&
9 | !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
10 | }
11 |
12 | void MyWideCharToMultiByte(LPSTR& lpOutput, LPWSTR lpwInput, SIZE_T nInLen) {
13 | int nSize = WideCharToMultiByte(CP_UTF8, 0, lpwInput, nInLen, NULL, 0, NULL, NULL);
14 | lpOutput = new CHAR[nSize];
15 | WideCharToMultiByte(CP_UTF8, 0, lpwInput, nInLen, lpOutput, nSize, NULL, NULL);
16 | }
17 |
18 | void MyMultiByteToWideChar(LPWSTR& lpwOutput, LPSTR lpInput, SIZE_T nInLen) {
19 | int nSize = MultiByteToWideChar(CP_UTF8, 0, lpInput, nInLen, NULL, 0);
20 | lpwOutput = new WCHAR[nSize];
21 | MultiByteToWideChar(CP_UTF8, 0, lpInput, nInLen, lpwOutput, nSize);
22 | }
23 |
24 | void MyLoadString(UINT uID, LPWSTR& lpBuffer) {
25 | ::LoadString(::GetModuleHandle(NULL), uID, (LPWSTR)&lpBuffer, 0);
26 | }
27 |
28 | void MyUnloadString(LPWSTR& lpBuffer) {
29 | lpBuffer = NULL;
30 | }
--------------------------------------------------------------------------------
/Version 1/NoREpls/helper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef __HELPER_H__
3 | #define __HELPER_H__
4 |
5 | #include
6 |
7 | #include "anti.h"
8 | #include "resource.h"
9 | #include "str_obfuscator.hpp"
10 |
11 | #define STROBF(x) ((cryptor::create(x).decrypt()))
12 |
13 | // global strings declaration
14 |
15 | BOOL FileExists(LPCWSTR szPath);
16 | void MyWideCharToMultiByte(LPSTR& lpOutput, LPWSTR lpwInput, SIZE_T nInLen);
17 | void MyMultiByteToWideChar(LPWSTR& lpwOutput, LPSTR lpInput, SIZE_T nInLen);
18 | void MyLoadString(UINT uID, LPWSTR& lpBuffer);
19 | void MyUnloadString(LPWSTR& lpBuffer);
20 |
21 | struct _init {
22 | _init() {
23 | // check integrity of string tables v2.1
24 | StringTableCheck();
25 | // check debugging windows v2.2
26 | CheckDebuggerWindows();
27 | }
28 | };
29 |
30 | #endif // !__HELPER_H__
31 |
--------------------------------------------------------------------------------
/Version 1/NoREpls/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Software cracking challenge
4 | *
5 | * Version Protection/Licensing
6 | * -------- ----------------------
7 | * 1.0 Static, plaintext serial string
8 | * Nags: Main dialog
9 | * 1.1 Static, (base64) encoded serial string
10 | * Registered persisence: Global registered check variable
11 | * Nags: Save function, about dialog, register menu item
12 | * 1.2 License file "License.lic", static obfuscated serial string; successful serial check routine writes license file
13 | * Registered persisence: Checks license file content to verify and allow features
14 | * Nags: Start and close dialog, save function, about dialog, register menu item
15 | * 1.3 License file "License.lic", combine user name and license
16 | * Registered persistence:
17 | * Nags: Unchanged
18 | * --------------------------------------
19 | * 2.0 License file, "License.lic", combine user name and license, successful serial check writes license file
20 | * Anti: IsDebuggerPresent and LoadString + String table resource
21 | * Registered persistence:
22 | * Nags: Unchanged
23 | * 2.1 Registry keys (String value serial key), set global registered check variable in check routine
24 | * Anti: Inlined IsDebuggerPresent (PEB IsDebugged), check integrity of string table with md5 and load strings as required
25 | * Registered persistence: Checks registry values and then sets global registered check variable
26 | * Nags: Unchanged
27 | * 2.2
28 | * Anti: Enumerate window names, antidisassembly
29 | * Registered persistence:
30 | * Nags: Unchanged
31 | * --------------------------------------
32 | */
33 |
34 | #include
35 | #include
36 | #include
37 |
38 | #include "aboutdlg.h"
39 | #include "anti.h"
40 | #include "helper.h"
41 | #include "nagdlg.h"
42 | #include "registration.h"
43 | #include "resource.h"
44 |
45 | #pragma comment(lib, "ComCtl32.lib")
46 | #pragma comment(lib, "Crypt32.lib")
47 |
48 | bool g_bRegistered = false;
49 | WCHAR g_szLicenseName[MAX_PATH];
50 | HINSTANCE g_hInstance = NULL;
51 |
52 | LPWSTR lpVersionW = NULL;
53 | LPWSTR lpTitleW = NULL;
54 | LPWSTR lpLicenseW = NULL;
55 | LPWSTR lpRegRequiredW = NULL;
56 | LPWSTR lpUnRegW = NULL;
57 | LPWSTR lpRegSuccessW = NULL;
58 | LPWSTR lpRegThankW = NULL;
59 | LPWSTR lpRegFailW = NULL;
60 | LPWSTR lpInvalidSerialW = NULL;
61 | LPWSTR lpNoSerialW = NULL;
62 | LPWSTR lpEnterSerialW = NULL;
63 | LPWSTR lpNoNameW = NULL;
64 | LPWSTR lpEnterNameW = NULL;
65 | LPWSTR lpSerialEqW = NULL;
66 | LPWSTR lpNameEqW = NULL;
67 | LPWSTR lpTitleFmtW = NULL;
68 | LPWSTR lpSerialFmtW = NULL;
69 | LPWSTR lpLicenseFmtW = NULL;
70 | LPWSTR lpContUnregW = NULL;
71 | LPWSTR lpWaitFmtW = NULL;
72 |
73 | _anti a;
74 |
75 | _init i;
76 |
77 | void SaveText(HWND hDlg) {
78 | LPOPENFILENAME lpOfn = new OPENFILENAME;
79 | WCHAR szFileName[MAX_PATH] = L"";
80 |
81 | ::ZeroMemory(lpOfn, sizeof(OPENFILENAME));
82 |
83 | lpOfn->lStructSize = sizeof(OPENFILENAME);
84 | lpOfn->hwndOwner = hDlg;
85 | lpOfn->lpstrFilter = L"Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
86 | lpOfn->lpstrFile = szFileName;
87 | lpOfn->nMaxFile = MAX_PATH;
88 | lpOfn->Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_CREATEPROMPT;
89 | lpOfn->lpstrDefExt = L"txt";
90 |
91 | if (::GetSaveFileName(lpOfn)) {
92 | HANDLE hFile = ::CreateFile(szFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
93 | if (hFile) {
94 | // get edit box text length
95 | DWORD dwTextLen = ::GetWindowTextLength(::GetDlgItem(hDlg, IDC_EDIT));
96 | // get text
97 | LPSTR lpText = new CHAR[dwTextLen + 1];
98 | ::GetDlgItemTextA(hDlg, IDC_EDIT, lpText, dwTextLen + 1);
99 |
100 | // write to file
101 | DWORD dwWrite = 0;
102 | ::WriteFile(hFile, lpText, dwTextLen + 1, &dwWrite, NULL);
103 |
104 | // delete text
105 | delete[] lpText;
106 | }
107 | ::CloseHandle(hFile);
108 | }
109 |
110 | delete lpOfn;
111 | }
112 |
113 | void OpenText(HWND hDlg) {
114 | LPOPENFILENAME lpOfn = new OPENFILENAME;
115 | WCHAR szFileName[MAX_PATH] = L"";
116 |
117 | ZeroMemory(lpOfn, sizeof(OPENFILENAME));
118 |
119 | lpOfn->lStructSize = sizeof(OPENFILENAME);
120 | lpOfn->hwndOwner = hDlg;
121 | lpOfn->lpstrFile = szFileName;
122 | lpOfn->lpstrFile[0] = '\0';
123 | lpOfn->nMaxFile = MAX_PATH;
124 | lpOfn->lpstrFilter = L"Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
125 | lpOfn->nFilterIndex = 1;
126 | lpOfn->lpstrFileTitle = NULL;
127 | lpOfn->nMaxFileTitle = 0;
128 | lpOfn->lpstrInitialDir = NULL;
129 | lpOfn->Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
130 |
131 | if (::GetOpenFileName(lpOfn)) {
132 | HANDLE hFile = ::CreateFile(szFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
133 | if (hFile) {
134 | // get file content length
135 | DWORD dwTextLen = ::GetFileSize(hFile, NULL);
136 | // get text
137 | LPSTR lpText = new CHAR[dwTextLen];
138 | ZeroMemory(lpText, dwTextLen);
139 | DWORD dwRead = 0;
140 | ::ReadFile(hFile, lpText, dwTextLen, &dwRead, NULL);
141 |
142 | // write to edit box
143 | ::SetDlgItemTextA(hDlg, IDC_EDIT, lpText);
144 |
145 | // clean up
146 | delete[] lpText;
147 | ::CloseHandle(hFile);
148 | }
149 | }
150 |
151 | delete lpOfn;
152 | }
153 |
154 | __declspec(noinline) void DragFile(HWND hDlg, HDROP hDrop) {
155 | WCHAR szFileName[MAX_PATH];
156 | if (::DragQueryFile(hDrop, 0, szFileName, MAX_PATH)) {
157 | HANDLE hFile = ::CreateFile(szFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
158 | if (hFile) {
159 | // get file content length
160 | DWORD dwTextLen = ::GetFileSize(hFile, NULL);
161 | // get text
162 | LPSTR lpText = new CHAR[dwTextLen];
163 | ZeroMemory(lpText, dwTextLen);
164 | DWORD dwRead = 0;
165 | ::ReadFile(hFile, lpText, dwTextLen, &dwRead, NULL);
166 |
167 | // write to edit box
168 | ::SetDlgItemTextA(hDlg, IDC_EDIT, lpText);
169 |
170 | // clean up
171 | delete[] lpText;
172 | ::CloseHandle(hFile);
173 | }
174 | ::DragFinish(hDrop);
175 | }
176 | }
177 |
178 | __declspec(noinline) void ChangeFont(HWND hDlg) {
179 | CHOOSEFONT cf; // common dialog box structure
180 | static LOGFONT lf; // logical font structure
181 | static DWORD rgbCurrent; // current text color
182 |
183 | // Initialize CHOOSEFONT
184 | ZeroMemory(&cf, sizeof(cf));
185 | cf.lStructSize = sizeof(cf);
186 | cf.hwndOwner = hDlg;
187 | cf.lpLogFont = &lf;
188 | cf.rgbColors = rgbCurrent;
189 | cf.Flags = CF_SCREENFONTS | CF_EFFECTS;
190 |
191 | if (ChooseFont(&cf)) {
192 | HFONT hFont = CreateFontIndirect(cf.lpLogFont);
193 | ::SendMessage(::GetDlgItem(hDlg, IDC_EDIT), WM_SETFONT, (WPARAM)hFont, TRUE);
194 | }
195 | }
196 |
197 | __declspec(noinline) void AlwaysOnTop(HWND hDlg) {
198 | MENUITEMINFO mii = { sizeof(MENUITEMINFO) };
199 |
200 | mii.fMask = MIIM_STATE;
201 | ::GetMenuItemInfo(::GetMenu(hDlg), ID_OPTIONS_ALWAYSONTOP, FALSE, &mii);
202 |
203 | mii.fState ^= MFS_CHECKED;
204 | if (mii.fState == MFS_CHECKED)
205 | SetWindowPos(hDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
206 | else
207 | SetWindowPos(hDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
208 |
209 | ::SetMenuItemInfo(::GetMenu(hDlg), ID_OPTIONS_ALWAYSONTOP, FALSE, &mii);
210 | }
211 |
212 | INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
213 | DSTRYFUNCBOUND
214 | switch (uMsg) {
215 | case WM_INITDIALOG:
216 | MyLoadString(IDS_STRING_TITLEDEMOW, lpTitleW);
217 | ::SetWindowText(hDlg, lpTitleW);
218 | MyUnloadString(lpTitleW);
219 | ANTIDIS_LINEAR
220 | if (!CheckLicenseRegistry()) {
221 | ::DialogBox(NULL, MAKEINTRESOURCE(IDD_DIALOG4), 0, NagDialogProc);
222 | } else {
223 | RegisterProgram(hDlg);
224 | ::EnableMenuItem(::GetMenu(hDlg), ID_ABOUT_REGISTER, MF_GRAYED);
225 | }
226 | if (g_bRegistered) {
227 | WCHAR szTitle[MAX_PATH];
228 | MyLoadString(IDS_STRING_TITLEW, lpTitleW);
229 | MyLoadString(IDS_STRING_TITLEFMTW, lpTitleFmtW);
230 | wsprintf(szTitle, lpTitleFmtW, lpTitleW, g_szLicenseName);
231 | MyUnloadString(lpTitleFmtW);
232 | MyUnloadString(lpTitleW);
233 | ::SetWindowText(hDlg, szTitle);
234 | }
235 | ::ShowWindow(hDlg, SW_SHOW);
236 | return TRUE;
237 | case WM_COMMAND:
238 | switch (LOWORD(wParam)) {
239 | case ID_FILE_NEW:
240 | if (::GetWindowTextLengthA(::GetDlgItem(hDlg, IDC_EDIT)) > 0)
241 | if (::MessageBox(hDlg, L"You will lose all progress. Are you sure you want to continue?", L"Progress Detected", MB_YESNO | MB_ICONWARNING) == IDYES)
242 | ::SetDlgItemTextA(hDlg, IDC_EDIT, "");
243 | return TRUE;
244 | case ID_FILE_SAVE:
245 | if (g_bRegistered)
246 | SaveText(hDlg);
247 | else {
248 | MyLoadString(IDS_STRING_REGREQW, lpRegRequiredW);
249 | MyLoadString(IDS_STRING_UNREGW, lpUnRegW);
250 | ::MessageBox(hDlg, lpRegRequiredW, lpUnRegW, MB_OK | MB_ICONINFORMATION);
251 | MyUnloadString(lpUnRegW);
252 | MyUnloadString(lpRegRequiredW);
253 | }
254 | return TRUE;
255 | case ID_FILE_OPEN:
256 | OpenText(hDlg);
257 | return TRUE;
258 | case ID_FILE_EXIT:
259 | ::SendMessage(hDlg, WM_CLOSE, 0, 0);
260 | return TRUE;
261 | case ID_OPTIONS_ALWAYSONTOP:
262 | AlwaysOnTop(hDlg);
263 | return TRUE;
264 | case ID_OPTIONS_FONT:
265 | if (g_bRegistered)
266 | ChangeFont(hDlg);
267 | else {
268 | MyLoadString(IDS_STRING_REGREQW, lpRegRequiredW);
269 | MyLoadString(IDS_STRING_UNREGW, lpUnRegW);
270 | ::MessageBox(hDlg, lpRegRequiredW, lpUnRegW, MB_OK | MB_ICONINFORMATION);
271 | MyUnloadString(lpUnRegW);
272 | MyUnloadString(lpRegRequiredW);
273 | }
274 | return TRUE;
275 | case ID_ABOUT_REGISTER:
276 | if (::DialogBox(NULL, MAKEINTRESOURCE(IDD_DIALOG2), hDlg, RegisterDialogProc)) {
277 | MyLoadString(IDS_STRING_REGSUCCESSW, lpRegSuccessW);
278 | MyLoadString(IDS_STRING_REGTHANKW, lpRegThankW);
279 | ::MessageBox(hDlg, lpRegThankW, lpRegSuccessW, MB_OK | MB_ICONINFORMATION);
280 | MyUnloadString(lpRegThankW);
281 | MyUnloadString(lpRegSuccessW);
282 | }
283 | return TRUE;
284 | case ID_ABOUT_ABOUT:
285 | ::DialogBox(NULL, MAKEINTRESOURCE(IDD_DIALOG3), hDlg, AboutDialogProc);
286 | return TRUE;
287 | }
288 | break;
289 | case WM_DROPFILES:
290 | DragFile(hDlg, (HDROP)wParam);
291 | return TRUE;
292 | case WM_SIZE: {
293 | RECT rc;
294 | ::GetClientRect(hDlg, &rc);
295 | ::MoveWindow(::GetDlgItem(hDlg, IDC_EDIT), rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE);
296 | return TRUE;
297 | }
298 | case WM_CLOSE:
299 | if (::GetWindowTextLengthA(::GetDlgItem(hDlg, IDC_EDIT)) > 0)
300 | if (::MessageBox(hDlg, L"You will lose all progress. Are you sure you want to continue?", L"Progress Detected", MB_YESNO | MB_ICONWARNING) == IDNO)
301 | return TRUE;
302 | ::DestroyWindow(hDlg);
303 | return TRUE;
304 | case WM_DESTROY:
305 | if (!g_bRegistered)
306 | ::DialogBox(NULL, MAKEINTRESOURCE(IDD_DIALOG4), 0, NagDialogProc);
307 | ::PostQuitMessage(0);
308 | return TRUE;
309 | }
310 |
311 | return FALSE;
312 | }
313 |
314 | int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) {
315 | HWND hDlg = ::CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), 0, DialogProc, 0);
316 |
317 | MSG msg;
318 | BOOL ret;
319 | while ((ret = ::GetMessage(&msg, 0, 0, 0)) != 0) {
320 | if (ret == -1)
321 | return -1;
322 |
323 | if (!IsDialogMessage(hDlg, &msg)) {
324 | ::TranslateMessage(&msg);
325 | ::DispatchMessage(&msg);
326 | }
327 | }
328 |
329 | return 0;
330 | }
331 |
--------------------------------------------------------------------------------
/Version 1/NoREpls/md5.cpp:
--------------------------------------------------------------------------------
1 | #include "md5.h"
2 |
3 | #ifndef HAVE_OPENSSL
4 |
5 | #define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
6 | #define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y))))
7 | #define H(x, y, z) ((x) ^ (y) ^ (z))
8 | #define I(x, y, z) ((y) ^ ((x) | ~(z)))
9 | #define STEP(f, a, b, c, d, x, t, s) \
10 | (a) += f((b), (c), (d)) + (x) + (t); \
11 | (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
12 | (a) += (b);
13 |
14 | #if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
15 | #define SET(n) \
16 | (*(MD5_u32 *)&ptr[(n) * 4])
17 | #define GET(n) \
18 | SET(n)
19 | #else
20 | #define SET(n) \
21 | (ctx->block[(n)] = \
22 | (MD5_u32)ptr[(n) * 4] | \
23 | ((MD5_u32)ptr[(n) * 4 + 1] << 8) | \
24 | ((MD5_u32)ptr[(n) * 4 + 2] << 16) | \
25 | ((MD5_u32)ptr[(n) * 4 + 3] << 24))
26 | #define GET(n) \
27 | (ctx->block[(n)])
28 | #endif
29 |
30 | typedef unsigned int MD5_u32;
31 |
32 | typedef struct {
33 | MD5_u32 lo, hi;
34 | MD5_u32 a, b, c, d;
35 | unsigned char buffer[64];
36 | MD5_u32 block[16];
37 | } MD5_CTX;
38 |
39 | static void MD5_Init(MD5_CTX *ctx);
40 | static void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size);
41 | static void MD5_Final(unsigned char *result, MD5_CTX *ctx);
42 |
43 | static const void *body(MD5_CTX *ctx, const void *data, unsigned long size) {
44 | const unsigned char *ptr;
45 | MD5_u32 a, b, c, d;
46 | MD5_u32 saved_a, saved_b, saved_c, saved_d;
47 |
48 | ptr = (const unsigned char*)data;
49 |
50 | a = ctx->a;
51 | b = ctx->b;
52 | c = ctx->c;
53 | d = ctx->d;
54 |
55 | do {
56 | saved_a = a;
57 | saved_b = b;
58 | saved_c = c;
59 | saved_d = d;
60 |
61 | STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7)
62 | STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12)
63 | STEP(F, c, d, a, b, SET(2), 0x242070db, 17)
64 | STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22)
65 | STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7)
66 | STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12)
67 | STEP(F, c, d, a, b, SET(6), 0xa8304613, 17)
68 | STEP(F, b, c, d, a, SET(7), 0xfd469501, 22)
69 | STEP(F, a, b, c, d, SET(8), 0x698098d8, 7)
70 | STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12)
71 | STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17)
72 | STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22)
73 | STEP(F, a, b, c, d, SET(12), 0x6b901122, 7)
74 | STEP(F, d, a, b, c, SET(13), 0xfd987193, 12)
75 | STEP(F, c, d, a, b, SET(14), 0xa679438e, 17)
76 | STEP(F, b, c, d, a, SET(15), 0x49b40821, 22)
77 | STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5)
78 | STEP(G, d, a, b, c, GET(6), 0xc040b340, 9)
79 | STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14)
80 | STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20)
81 | STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5)
82 | STEP(G, d, a, b, c, GET(10), 0x02441453, 9)
83 | STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14)
84 | STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20)
85 | STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5)
86 | STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9)
87 | STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14)
88 | STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20)
89 | STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5)
90 | STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9)
91 | STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14)
92 | STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20)
93 | STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4)
94 | STEP(H, d, a, b, c, GET(8), 0x8771f681, 11)
95 | STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16)
96 | STEP(H, b, c, d, a, GET(14), 0xfde5380c, 23)
97 | STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4)
98 | STEP(H, d, a, b, c, GET(4), 0x4bdecfa9, 11)
99 | STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16)
100 | STEP(H, b, c, d, a, GET(10), 0xbebfbc70, 23)
101 | STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4)
102 | STEP(H, d, a, b, c, GET(0), 0xeaa127fa, 11)
103 | STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16)
104 | STEP(H, b, c, d, a, GET(6), 0x04881d05, 23)
105 | STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4)
106 | STEP(H, d, a, b, c, GET(12), 0xe6db99e5, 11)
107 | STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16)
108 | STEP(H, b, c, d, a, GET(2), 0xc4ac5665, 23)
109 | STEP(I, a, b, c, d, GET(0), 0xf4292244, 6)
110 | STEP(I, d, a, b, c, GET(7), 0x432aff97, 10)
111 | STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15)
112 | STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21)
113 | STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6)
114 | STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10)
115 | STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15)
116 | STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21)
117 | STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6)
118 | STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10)
119 | STEP(I, c, d, a, b, GET(6), 0xa3014314, 15)
120 | STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21)
121 | STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6)
122 | STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10)
123 | STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15)
124 | STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21)
125 |
126 | a += saved_a;
127 | b += saved_b;
128 | c += saved_c;
129 | d += saved_d;
130 |
131 | ptr += 64;
132 | } while (size -= 64);
133 |
134 | ctx->a = a;
135 | ctx->b = b;
136 | ctx->c = c;
137 | ctx->d = d;
138 |
139 | return ptr;
140 | }
141 |
142 | void MD5_Init(MD5_CTX *ctx) {
143 | ctx->a = 0x67452301;
144 | ctx->b = 0xefcdab89;
145 | ctx->c = 0x98badcfe;
146 | ctx->d = 0x10325476;
147 |
148 | ctx->lo = 0;
149 | ctx->hi = 0;
150 | }
151 |
152 | void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) {
153 | MD5_u32 saved_lo;
154 | unsigned long used, free;
155 |
156 | saved_lo = ctx->lo;
157 | if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
158 | ctx->hi++;
159 | ctx->hi += size >> 29;
160 | used = saved_lo & 0x3f;
161 |
162 | if (used) {
163 | free = 64 - used;
164 | if (size < free) {
165 | memcpy(&ctx->buffer[used], data, size);
166 | return;
167 | }
168 |
169 | memcpy(&ctx->buffer[used], data, free);
170 | data = (unsigned char *)data + free;
171 | size -= free;
172 | body(ctx, ctx->buffer, 64);
173 | }
174 |
175 | if (size >= 64) {
176 | data = body(ctx, data, size & ~(unsigned long)0x3f);
177 | size &= 0x3f;
178 | }
179 |
180 | memcpy(ctx->buffer, data, size);
181 | }
182 |
183 | void MD5_Final(unsigned char *result, MD5_CTX *ctx) {
184 | unsigned long used, free;
185 | used = ctx->lo & 0x3f;
186 | ctx->buffer[used++] = 0x80;
187 | free = 64 - used;
188 |
189 | if (free < 8) {
190 | memset(&ctx->buffer[used], 0, free);
191 | body(ctx, ctx->buffer, 64);
192 | used = 0;
193 | free = 64;
194 | }
195 |
196 | memset(&ctx->buffer[used], 0, free - 8);
197 |
198 | ctx->lo <<= 3;
199 | ctx->buffer[56] = ctx->lo;
200 | ctx->buffer[57] = ctx->lo >> 8;
201 | ctx->buffer[58] = ctx->lo >> 16;
202 | ctx->buffer[59] = ctx->lo >> 24;
203 | ctx->buffer[60] = ctx->hi;
204 | ctx->buffer[61] = ctx->hi >> 8;
205 | ctx->buffer[62] = ctx->hi >> 16;
206 | ctx->buffer[63] = ctx->hi >> 24;
207 | body(ctx, ctx->buffer, 64);
208 | result[0] = ctx->a;
209 | result[1] = ctx->a >> 8;
210 | result[2] = ctx->a >> 16;
211 | result[3] = ctx->a >> 24;
212 | result[4] = ctx->b;
213 | result[5] = ctx->b >> 8;
214 | result[6] = ctx->b >> 16;
215 | result[7] = ctx->b >> 24;
216 | result[8] = ctx->c;
217 | result[9] = ctx->c >> 8;
218 | result[10] = ctx->c >> 16;
219 | result[11] = ctx->c >> 24;
220 | result[12] = ctx->d;
221 | result[13] = ctx->d >> 8;
222 | result[14] = ctx->d >> 16;
223 | result[15] = ctx->d >> 24;
224 | memset(ctx, 0, sizeof(*ctx));
225 | }
226 | #else
227 | #include
228 | #endif
229 |
230 |
231 | using namespace std;
232 |
233 | /* Return Calculated raw result(always little-endian), the size is always 16 */
234 | void md5bin(const void* dat, size_t len, unsigned char out[16]) {
235 | MD5_CTX c;
236 | MD5_Init(&c);
237 | MD5_Update(&c, dat, len);
238 | MD5_Final(out, &c);
239 | }
240 |
241 | static char hb2hex(unsigned char hb) {
242 | hb = hb & 0xF;
243 | return hb < 10 ? '0' + hb : hb - 10 + 'a';
244 | }
245 |
246 | string md5(const void* dat, size_t len) {
247 | string res;
248 | unsigned char out[16];
249 | md5bin(dat, len, out);
250 | for (size_t i = 0; i < 16; ++i) {
251 | res.push_back(hb2hex(out[i] >> 4));
252 | res.push_back(hb2hex(out[i]));
253 | }
254 | return res;
255 | }
256 |
257 | std::string md5(std::string dat) {
258 | return md5(dat.c_str(), dat.length());
259 | }
260 |
261 | /* Generate shorter md5sum by something like base62 instead of base16 or base10. 0~61 are represented by 0-9a-zA-Z */
262 | string md5sum6(const void* dat, size_t len) {
263 | static const char* tbl = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
264 | string res;
265 | unsigned char out[16];
266 | md5bin(dat, len, out);
267 | for (size_t i = 0; i < 6; ++i) {
268 | res.push_back(tbl[out[i] % 62]);
269 | }
270 | return res;
271 | }
272 |
273 | std::string md5sum6(std::string dat) {
274 | return md5sum6(dat.c_str(), dat.length());
275 | }
--------------------------------------------------------------------------------
/Version 1/NoREpls/md5.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef MD5_H
3 | #define MD5_H
4 |
5 | #define _CRT_SECURE_NO_WARNINGS
6 |
7 | #include
8 | #include
9 |
10 | std::string md5(std::string dat);
11 | std::string md5(const void* dat, size_t len);
12 | std::string md5sum6(std::string dat);
13 | std::string md5sum6(const void* dat, size_t len);
14 |
15 | #endif // end of MD5_H
--------------------------------------------------------------------------------
/Version 1/NoREpls/nagdlg.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "helper.h"
4 | #include "nagdlg.h"
5 | #include "registration.h"
6 | #include "resource.h"
7 |
8 | #define IDT_TIMER 1
9 |
10 | INT_PTR CALLBACK NagDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
11 | static int i = 4;
12 |
13 | switch (uMsg) {
14 | case WM_INITDIALOG:
15 | i = 4;
16 | ::SetTimer(hDlg, IDT_TIMER, 1000, NULL);
17 | return TRUE;
18 | case WM_COMMAND:
19 | switch (LOWORD(wParam)) {
20 | case IDOK:
21 | ::EndDialog(hDlg, TRUE);
22 | return TRUE;
23 | }
24 | break;
25 | case WM_TIMER:
26 | switch (wParam) {
27 | case IDT_TIMER:
28 | if (i == 0) {
29 | MyLoadString(IDS_STRING_CONTUNREGW, lpContUnregW);
30 | ::SetDlgItemText(hDlg, IDOK, lpContUnregW);
31 | MyUnloadString(lpContUnregW);
32 | ::EnableWindow(::GetDlgItem(hDlg, IDOK), TRUE);
33 | ::KillTimer(hDlg, IDT_TIMER);
34 | } else {
35 | WCHAR szWaitText[26];
36 | MyLoadString(IDS_STRING_WAITFMTW, lpWaitFmtW);
37 | wsprintf(szWaitText, lpWaitFmtW, i);
38 | MyUnloadString(lpWaitFmtW);
39 | ::SetDlgItemText(hDlg, IDOK, szWaitText);
40 | i--;
41 | }
42 | }
43 | case WM_CLOSE:
44 | return TRUE;
45 | }
46 |
47 | return FALSE;
48 | }
--------------------------------------------------------------------------------
/Version 1/NoREpls/nagdlg.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef __NAGDLG_H__
3 | #define __NAGDLG_H__
4 |
5 | INT_PTR CALLBACK NagDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
6 |
7 | #endif // !__NAGDLG_H__
8 |
--------------------------------------------------------------------------------
/Version 1/NoREpls/package_installed_locked.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NtRaiseHardError/NoREpls/72b660fad95513afe8d544fb907f9e855bb223fd/Version 1/NoREpls/package_installed_locked.ico
--------------------------------------------------------------------------------
/Version 1/NoREpls/registration.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "anti.h"
4 | #include "helper.h"
5 | #include "md5.h"
6 | #include "registration.h"
7 | #include "resource.h"
8 | #include "str_obfuscator.hpp"
9 |
10 | //__declspec(noinline) bool Base64Encode(LPSTR& lpOutput, LPSTR lpInput) {
11 | // DWORD nDestinationSize;
12 | // if (CryptBinaryToStringA(reinterpret_cast (lpInput), wcslen(lpInput), CRYPT_STRING_BASE64, NULL, &nDestinationSize)) {
13 | // LPSTR pszDestination = new CHAR[nDestinationSize];
14 | // if (pszDestination) {
15 | // if (CryptBinaryToStringA(reinterpret_cast (lpInput), wcslen(lpInput), CRYPT_STRING_BASE64, pszDestination, &nDestinationSize)) {
16 | // lpOutput = pszDestination;
17 | // return true;
18 | // }
19 | // }
20 | // }
21 | //
22 | // return false;
23 | //}
24 |
25 | __declspec(noinline) void RegisterProgram(HWND hDlg) {
26 | DSTRYFUNCBOUND
27 | ANTIDIS_LINEAR
28 | ISDBGPRSNT
29 | g_bRegistered = true;
30 | ::EnableWindow(::GetDlgItem(hDlg, IDC_STATIC_DEMO), FALSE);
31 | MyLoadString(IDS_STRING_TITLEW, lpTitleW);
32 | ::SetWindowText(::GetParent(hDlg), lpTitleW);
33 | MyUnloadString(lpTitleW);
34 | ::EnableMenuItem(::GetMenu(::GetParent(hDlg)), ID_ABOUT_REGISTER, MF_GRAYED);
35 | }
36 |
37 | bool SerialAlgorithm(LPWSTR lpName, LPWSTR lpSerial) {
38 | DSTRYFUNCBOUND
39 | int iRes = 0;
40 | if (wcslen(lpName) > wcslen(lpSerial)) {
41 | for (int i = 0; i < wcslen(lpName); i+=2)
42 | iRes += ((((69 * iRes) + __LINE__) * i) >> __COUNTER__) ^ lpName[i % wcslen(lpName)];
43 | } else {
44 | for (int i = 0; i < wcslen(lpSerial); i+=2)
45 | iRes += ((((69 * iRes) + __LINE__) * i) >> __COUNTER__) ^ lpName[i % wcslen(lpName)];
46 | }
47 | ANTIDIS_LINEAR
48 | #ifndef _DEBUG
49 | return (iRes % 100 > 0x69);
50 | #else
51 | return true;
52 | #endif // !_DEBUG
53 |
54 | }
55 |
56 | __declspec(noinline) static bool CheckSerial(LPWSTR lpName, LPWSTR lpSerial) {
57 | BOOL bRet = false;
58 | int nPart[4];
59 |
60 | ANTIDIS_LINEAR
61 | MyLoadString(IDS_STRING_SERIALFMTW, lpSerialFmtW);
62 | if (swscanf(lpSerial, lpSerialFmtW, &nPart[0], &nPart[1], &nPart[2], &nPart[3]) == 4)
63 | if (SerialAlgorithm(lpName, lpSerial)) {
64 | wsprintf(g_szLicenseName, L"%s", lpName);
65 | bRet = true;
66 | }
67 | MyUnloadString(lpSerialFmtW);
68 |
69 | ANTIDIS_LINEAR
70 | return bRet;
71 | }
72 |
73 | __declspec(noinline) bool GetLicense(HWND hDlg) {
74 | bool bRet = false;
75 | WCHAR szName[MAX_PATH];
76 | WCHAR szSerial[MAX_PATH];
77 | ::GetDlgItemText(hDlg, IDC_USERNAME, szName, MAX_PATH);
78 | ::GetDlgItemText(hDlg, IDC_SERIAL, szSerial, MAX_PATH);
79 |
80 | if (wcslen(szSerial) == 0) {
81 | MyLoadString(IDS_STRING_NOSERW, lpNoSerialW);
82 | MyLoadString(IDS_STRING_ENTERSERW, lpEnterSerialW);
83 | ::MessageBox(hDlg, lpEnterSerialW, lpNoSerialW, MB_OK | MB_ICONINFORMATION);
84 | MyUnloadString(lpEnterSerialW);
85 | MyUnloadString(lpNoSerialW);
86 | return bRet;
87 | } else if (wcslen(szName) == 0) {
88 | MyLoadString(IDS_STRING_NONAMEW, lpNoNameW);
89 | MyLoadString(IDS_STRING_ENTERSERW, lpEnterSerialW);
90 | ::MessageBox(hDlg, lpEnterNameW, lpNoNameW, MB_OK | MB_ICONINFORMATION);
91 | MyUnloadString(lpEnterSerialW);
92 | MyUnloadString(lpNoSerialW);
93 | return bRet;
94 | }
95 |
96 | ANTIDIS_LINEAR
97 | bRet = CheckSerial(szName, szSerial);
98 |
99 | // write to registry
100 | if (bRet) {
101 | // create key
102 | HKEY hKey = NULL;
103 | if (::RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\NoREpls", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {
104 | // set name value
105 | if (::RegSetValueEx(hKey, L"Name", 0, REG_SZ, (LPBYTE)szName, wcslen(szName) * sizeof(WCHAR)) == ERROR_SUCCESS)
106 | // set name value
107 | if (::RegSetValueEx(hKey, L"SN", 0, REG_SZ, (LPBYTE)szSerial, wcslen(szSerial) * sizeof(WCHAR)) == ERROR_SUCCESS)
108 | ::RegCloseKey(hKey);
109 | }
110 | }
111 |
112 | ANTIDIS_LINEAR
113 | return bRet;
114 | }
115 |
116 | __declspec(noinline) bool CheckLicenseRegistry() {
117 | DSTRYFUNCBOUND
118 | bool bRet = false;
119 | // get handle to registry key
120 | HKEY hKey = NULL;
121 | if (::RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\NoREpls", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_QUERY_VALUE, NULL, &hKey, NULL) == ERROR_SUCCESS) {
122 | WCHAR szName[50];
123 | WCHAR szSerial[50];
124 | DWORD dwBufSize = sizeof(szName);
125 |
126 | wmemset(szName, '\0', sizeof(szName) / sizeof(WCHAR));
127 | wmemset(szSerial, '\0', sizeof(szSerial) / sizeof(WCHAR));
128 |
129 | // get name value
130 | if (::RegQueryValueExW(hKey, L"Name", 0, NULL, (LPBYTE)szName, &dwBufSize) == ERROR_SUCCESS) {
131 | // get name value
132 | DWORD dwBufSize = sizeof(szSerial);
133 | if (::RegQueryValueEx(hKey, L"SN", 0, NULL, (LPBYTE)szSerial, &dwBufSize) == ERROR_SUCCESS)
134 | bRet = CheckSerial(szName, szSerial);
135 | }
136 | ::RegCloseKey(hKey);
137 | }
138 |
139 | // compare
140 | ANTIDIS_LINEAR
141 | return bRet;
142 | }
143 |
144 | INT_PTR CALLBACK RegisterDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
145 | _anti a;
146 |
147 | switch (uMsg) {
148 | case WM_COMMAND:
149 | switch (LOWORD(wParam)) {
150 | case IDC_REGISTER:
151 | ANTIDIS_LINEAR
152 | if (GetLicense(hDlg)) {
153 | ISDBGPRSNT
154 | RegisterProgram(hDlg);
155 | WCHAR szTitle[MAX_PATH];
156 | MyLoadString(IDS_STRING_TITLEW, lpTitleW);
157 | MyLoadString(IDS_STRING_TITLEFMTW, lpTitleFmtW);
158 | wsprintf(szTitle, lpTitleFmtW, lpTitleW, g_szLicenseName);
159 | MyUnloadString(lpTitleFmtW);
160 | MyUnloadString(lpTitleW);
161 | ::SetWindowText(::GetParent(hDlg), szTitle);
162 | ::EndDialog(hDlg, TRUE);
163 | } else {
164 | MyLoadString(IDS_STRING_INVALIDSERW, lpInvalidSerialW);
165 | MyLoadString(IDS_STRING_REGFAILW, lpRegFailW);
166 | //ANTIDIS_LINEAR
167 | //CheckFuncInt3(MessageBox);
168 | ::MessageBox(hDlg, lpInvalidSerialW, lpRegFailW, MB_OK | MB_ICONERROR);
169 | MyUnloadString(lpRegFailW);
170 | MyUnloadString(lpInvalidSerialW);
171 | }
172 | return TRUE;
173 | }
174 | break;
175 |
176 | case WM_CLOSE:
177 | ::EndDialog(hDlg, FALSE);
178 | return TRUE;
179 |
180 | }
181 |
182 | return FALSE;
183 | }
--------------------------------------------------------------------------------
/Version 1/NoREpls/registration.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef __REGISTRATION_H__
3 | #define __REGISTRATION_H__
4 |
5 | //#define VERSION L"Version 1.3"
6 | //#define TITLEA "NoREpls - Version 1.3"
7 | //#define TITLE L"NoREpls - Version 1.3"
8 | //#define TITLE_DEMO L"NoREpls - Version 1.3 (demo version)"
9 | //#define LICENSE_FILE L"License.lic"
10 | // "NOREPLS-0892-H43O-19JG-3UAN"
11 | // "NOREPLS-MAST-ERKE-Y000-0000"
12 | // #define SERIAL "deab67dde2001dc1a078456015765ed6"
13 |
14 | extern LPWSTR lpVersionW;
15 | extern LPWSTR lpTitleW;
16 | extern LPWSTR lpTitleW;
17 | extern LPWSTR lpLicenseW;
18 | extern LPWSTR lpRegRequiredW;
19 | extern LPWSTR lpUnRegW;
20 | extern LPWSTR lpRegSuccessW;
21 | extern LPWSTR lpRegThankW;
22 | extern LPWSTR lpRegFailW;
23 | extern LPWSTR lpInvalidSerialW;
24 | extern LPWSTR lpNoSerialW;
25 | extern LPWSTR lpEnterSerialW;
26 | extern LPWSTR lpNoNameW;
27 | extern LPWSTR lpEnterNameW;
28 | extern LPWSTR lpSerialEqW;
29 | extern LPWSTR lpNameEqW;
30 | extern LPWSTR lpTitleFmtW;
31 | extern LPWSTR lpSerialFmtW;
32 | extern LPWSTR lpLicenseFmtW;
33 | extern LPWSTR lpContUnregW;
34 | extern LPWSTR lpWaitFmtW;
35 |
36 | extern bool g_bRegistered;
37 | extern WCHAR g_szLicenseName[MAX_PATH];
38 |
39 | void RegisterProgram(HWND hDlg);
40 | //bool CheckSerial(LPSTR lpName, LPSTR lpSerial);
41 | bool CheckLicenseRegistry();
42 | INT_PTR CALLBACK RegisterDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
43 |
44 | #endif // !__REGISTRATION_H__
45 |
--------------------------------------------------------------------------------
/Version 1/NoREpls/resource.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NtRaiseHardError/NoREpls/72b660fad95513afe8d544fb907f9e855bb223fd/Version 1/NoREpls/resource.h
--------------------------------------------------------------------------------
/Version 1/NoREpls/str_obfuscator.hpp:
--------------------------------------------------------------------------------
1 | #ifndef STR_OBFUSCATOR_HPP_
2 | #define STR_OBFUSCATOR_HPP_
3 |
4 | namespace detail {
5 | template
6 | struct encryptor {
7 | static constexpr void encrypt(wchar_t *dest, const wchar_t *str, wchar_t key) {
8 | dest[index] = str[index] ^ key;
9 |
10 | encryptor::encrypt(dest, str, key);
11 | }
12 | };
13 |
14 | template<>
15 | struct encryptor<0> {
16 | static constexpr void encrypt(wchar_t *dest, const wchar_t *str, wchar_t key) {
17 | dest[0] = str[0] ^ key;
18 | }
19 | };
20 | };
21 |
22 | class cryptor {
23 | public:
24 | template
25 | class string_encryptor {
26 | public:
27 | constexpr string_encryptor(const wchar_t str[S], wchar_t key) :
28 | _buffer{}, _decrypted{ false }, _key{ key } {
29 | detail::encryptor::encrypt(_buffer, str, key);
30 | }
31 |
32 | const wchar_t *decrypt(void) const {
33 | if (_decrypted) {
34 | return _buffer;
35 | }
36 |
37 | for (auto &c : _buffer) {
38 | c ^= _key;
39 | }
40 |
41 | _decrypted = true;
42 |
43 | return _buffer;
44 | }
45 |
46 | private:
47 | mutable wchar_t _buffer[S];
48 | mutable bool _decrypted;
49 | const wchar_t _key;
50 | };
51 |
52 | template
53 | static constexpr auto create(const wchar_t(&str)[S]) {
54 | return string_encryptor{ str, S };
55 | }
56 | };
57 |
58 | #endif // STR_OBFUSCATOR_HPP_
--------------------------------------------------------------------------------
/Version 1/README.md:
--------------------------------------------------------------------------------
1 | # Version 1
2 | Simple text-editor application with some basic anti-reverse engineering techniques.
3 |
--------------------------------------------------------------------------------