updated some files

did some more testing and added the yara.h header
This commit is contained in:
jakani24
2023-09-24 10:01:36 +02:00
parent 62f156d0b6
commit 89e911488e
33 changed files with 121 additions and 16 deletions

View File

@@ -1,23 +1,20 @@
#pragma warning(disable:4996)
#include <iostream>
#include <curl/curl.h>
#include <openssl/md5.h>
#include <yara.h>
#include "md5hash.h"
#include "connect.h"
#include "scan.h"
int main() {
printf("welcome to the jakach security tool\n");
char md5Hash[2 * MD5_DIGEST_LENGTH + 1]; // +1 for null-terminator
printf("Hash of the executable: ");
md5_file("C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\x64\\Debug\\client_backend.exe", md5Hash);
printf("%s", md5Hash);
CURL* curl = curl_easy_init();
if (!curl) {
std::cerr << "Failed to initialize libcurl." << std::endl;
return 1;
}
std::cout << "libcurl is correctly installed and initialized." << std::endl;
// Clean up libcurl
curl_easy_cleanup(curl);
char a[2000];
printf("\nerror:%d\n",connect_to_srv("https://self-signed.badssl.com/", a, 2000,1)); //error 60: self signed => option f<>r self-signed ignorieren aktivieren (bool ignore_invalid=true)
printf("%s", a); //error 6: not reachable
return 0;
}

View File

@@ -43,7 +43,7 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CharacterSet>Multi-Byte-Zeichensatz verwenden</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
@@ -136,10 +136,14 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="client_backend.cpp" />
<ClCompile Include="connect.cpp" />
<ClCompile Include="md5hash.cpp" />
<ClCompile Include="scan.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="connect.h" />
<ClInclude Include="md5hash.h" />
<ClInclude Include="scan.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@@ -21,10 +21,22 @@
<ClCompile Include="md5hash.cpp">
<Filter>Headerdateien</Filter>
</ClCompile>
<ClCompile Include="connect.cpp">
<Filter>Headerdateien</Filter>
</ClCompile>
<ClCompile Include="scan.cpp">
<Filter>Headerdateien</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="md5hash.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="connect.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="scan.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,35 @@
#pragma warning(disable:4996)
#ifndef CONNECT_CPP
#define CONNECT_CPP
#include "connect.h"
static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
int connect_to_srv(const char*url,char*out,int max_len, bool ignore_insecure) {
CURL* curl;
CURLcode res;
std::string readBuffer;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
if(ignore_insecure==true)
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if (max_len > (int)strlen(readBuffer.c_str())) {
strcpy(out, readBuffer.c_str());
return res;
}
else
return 1;
}
return 2;
}
#endif

View File

@@ -0,0 +1,5 @@
#pragma once
#include <iostream>
#include <string>
#include <curl/curl.h>
int connect_to_srv(const char* url, char* out, int max_len, bool ignore_insecure);

View File

@@ -0,0 +1,43 @@
#include "scan.h"
#include <windows.h>
#include <iostream>
#include <windows.h>
#include <iostream>
#ifndef SCAN_CPP
#define SCAN_CPP
#include <string>
int cnt = 0;
void ListFilesRecursive(const std::string& directory) {
std::string search_path = directory + "\\*.*";
WIN32_FIND_DATA find_file_data;
HANDLE hFind = FindFirstFile(search_path.c_str(), &find_file_data);
if (hFind == INVALID_HANDLE_VALUE) {
std::cerr << "Error opening directory: " << directory << std::endl;
return;
}
do {
if (strcmp(find_file_data.cFileName, ".") == 0 || strcmp(find_file_data.cFileName, "..") == 0) {
continue; // Skip the current and parent directories
}
std::string full_path = directory + "\\" + find_file_data.cFileName;
if (find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
// If it's a directory, recurse into it
ListFilesRecursive(full_path);
}
else {
// If it's a file, print its name
cnt++;
if (cnt % 1000 == 0) {
printf("Processed %d files\n", cnt);
}
}
} while (FindNextFile(hFind, &find_file_data) != 0);
FindClose(hFind);
}
#endif

View File

@@ -0,0 +1,3 @@
#pragma once
#include <string>
void ListFilesRecursive(const std::string& directory);

View File

@@ -1 +1,2 @@
 client_backend.vcxproj -> C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.exe
 client_backend.cpp
client_backend.vcxproj -> C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.exe

View File

@@ -1,2 +1,4 @@
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp;C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.obj
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\connect.cpp;C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\connect.obj
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\md5hash.cpp;C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\md5hash.obj
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\scan.cpp;C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\scan.obj

View File

@@ -1 +1,3 @@
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.exe
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.vcxproj.CopyComplete
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\libcrypto-3-x64.dll

View File

@@ -1 +1,2 @@
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\libcrypto-3-x64.dll