summaryrefslogtreecommitdiff
path: root/enc_file/source.cpp
diff options
context:
space:
mode:
authorJustSomePwner <crotchyalt@gmail.com>2018-08-30 14:01:54 +0200
committerJustSomePwner <crotchyalt@gmail.com>2018-08-30 14:01:54 +0200
commit7ccb819f867493f8ec202ea3b39c94c198c64584 (patch)
tree94622e61af0ff359e3d6689cf274d74f60b2492a /enc_file/source.cpp
parent564d979b79e8a5aaa5014eba0ecd36c61575934f (diff)
first
Diffstat (limited to 'enc_file/source.cpp')
-rw-r--r--enc_file/source.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/enc_file/source.cpp b/enc_file/source.cpp
new file mode 100644
index 0000000..9056764
--- /dev/null
+++ b/enc_file/source.cpp
@@ -0,0 +1,40 @@
+#include <iostream>
+#include <Windows.h>
+
+int main( ) {
+ uint8_t key{ };
+ std::cin >> key;
+ printf( "key: %d", key );
+
+ auto file = CreateFileA( "./enc.dll", GENERIC_READ, 0, 0, OPEN_ALWAYS, 0, 0 );
+ if( !file ) return 0;
+
+ auto size = GetFileSize( file, 0 );
+ if( !size ) {
+ CloseHandle( file );
+ return 0;
+ }
+
+ uint8_t* data = ( uint8_t* )( malloc( size ) );
+ if( !ReadFile( file, data, size, 0, 0 ) ) {
+ CloseHandle( file );
+ free( data );
+ return 0;
+ }
+
+ CloseHandle( file );
+
+ for( size_t i{ }; i < size; ++i ) {
+ data[ i ] ^= key;
+ }
+
+ data[ 0 ] = 'c';
+ data[ 1 ] = 'd';
+
+ FILE* f;
+ fopen_s( &f, "./out.dll", "wb" );
+ fwrite( data, 1, size, f );
+ fclose( f );
+
+ return 0;
+} \ No newline at end of file