2020-04-11 08:27:51 -07:00
|
|
|
/**
|
|
|
|
|
* @file hyperdbg-cli.cpp
|
|
|
|
|
* @author Sina Karvandi (sina@rayanfam.com)
|
2020-04-11 10:28:37 -07:00
|
|
|
* @brief Main HyperDbg Cli source coede
|
2020-04-11 08:27:51 -07:00
|
|
|
* @details
|
|
|
|
|
* @version 0.1
|
|
|
|
|
* @date 2020-04-11
|
2020-04-11 10:28:37 -07:00
|
|
|
*
|
2020-04-11 08:27:51 -07:00
|
|
|
* @copyright This project is released under the GNU Public License v3.
|
2020-04-11 10:28:37 -07:00
|
|
|
*
|
2020-04-11 08:27:51 -07:00
|
|
|
*/
|
2020-03-24 06:35:02 -07:00
|
|
|
#include <Windows.h>
|
2020-04-11 20:43:08 -07:00
|
|
|
#include <string>
|
2020-03-24 06:35:02 -07:00
|
|
|
#include <conio.h>
|
2020-04-11 10:28:37 -07:00
|
|
|
#include <iostream>
|
|
|
|
|
#include "Definition.h"
|
|
|
|
|
#include "Configuration.h"
|
2020-03-24 06:35:02 -07:00
|
|
|
|
2020-03-26 11:02:50 -07:00
|
|
|
#pragma comment(lib, "HPRDBGCTRL.lib")
|
2020-03-24 06:35:02 -07:00
|
|
|
|
2020-04-11 20:43:08 -07:00
|
|
|
using namespace std;
|
|
|
|
|
|
2020-04-11 10:28:37 -07:00
|
|
|
//
|
|
|
|
|
// Header file of HPRDBGCTRL
|
|
|
|
|
// Imports
|
|
|
|
|
//
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
__declspec (dllimport) int __cdecl HyperdbgLoad();
|
|
|
|
|
__declspec (dllimport) int __cdecl HyperdbgUnload();
|
|
|
|
|
__declspec (dllimport) int __cdecl HyperdbgInstallDriver();
|
|
|
|
|
__declspec (dllimport) int __cdecl HyperdbgUninstallDriver();
|
2020-04-11 20:43:08 -07:00
|
|
|
__declspec (dllimport) int __cdecl HyperdbgInterpreter(std::string Command);
|
2020-04-11 10:28:37 -07:00
|
|
|
__declspec (dllimport) void __stdcall HyperdbgSetTextMessageCallback(Callback handler);
|
|
|
|
|
|
2020-04-01 09:34:24 -07:00
|
|
|
}
|
2020-03-24 06:35:02 -07:00
|
|
|
|
2020-04-11 20:43:08 -07:00
|
|
|
|
2020-04-11 10:28:37 -07:00
|
|
|
/**
|
|
|
|
|
* @brief Print HyperDbg Header
|
|
|
|
|
*
|
|
|
|
|
*/
|
2020-03-24 06:35:02 -07:00
|
|
|
void PrintAppearance() {
|
|
|
|
|
|
2020-04-11 10:28:37 -07:00
|
|
|
printf("\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
" _ _ _ _____ ____ _ _ \n"
|
|
|
|
|
" | | | |_ _ _ __ ___ _ ____ _(_)___ ___ _ __ | ___| __ ___ _ __ ___ / ___| ___ _ __ __ _| |_ ___| |__ \n"
|
|
|
|
|
" | |_| | | | | '_ \\ / _ \\ '__\\ \\ / / / __|/ _ \\| '__| | |_ | '__/ _ \\| '_ ` _ \\ \\___ \\ / __| '__/ _` | __/ __| '_ \\ \n"
|
|
|
|
|
" | _ | |_| | |_) | __/ | \\ V /| \\__ \\ (_) | | | _|| | | (_) | | | | | | ___) | (__| | | (_| | || (__| | | |\n"
|
|
|
|
|
" |_| |_|\\__, | .__/ \\___|_| \\_/ |_|___/\\___/|_| |_| |_| \\___/|_| |_| |_| |____/ \\___|_| \\__,_|\\__\\___|_| |_|\n"
|
|
|
|
|
" |___/|_| \n"
|
|
|
|
|
"\n\n");
|
2020-03-24 06:35:02 -07:00
|
|
|
}
|
|
|
|
|
|
2020-04-11 10:28:37 -07:00
|
|
|
/**
|
|
|
|
|
* @brief CLI main function
|
|
|
|
|
*
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
// Print Hypervisor From Scratch Message
|
|
|
|
|
//
|
|
|
|
|
PrintAppearance();
|
|
|
|
|
|
2020-04-11 20:43:08 -07:00
|
|
|
|
|
|
|
|
//std::string command = "salam";
|
|
|
|
|
//HyperdbgInterpreter(command);
|
|
|
|
|
|
|
|
|
|
//_getch();
|
|
|
|
|
//return 0;
|
|
|
|
|
|
2020-04-11 10:28:37 -07:00
|
|
|
//
|
|
|
|
|
// Installing Driver
|
|
|
|
|
//
|
|
|
|
|
if (HyperdbgInstallDriver())
|
|
|
|
|
{
|
|
|
|
|
printf("Failed to install driver\n");
|
|
|
|
|
printf("Press any key to exit ...");
|
|
|
|
|
_getch();
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (HyperdbgLoad())
|
|
|
|
|
{
|
|
|
|
|
printf("Failed to load driver\n");
|
|
|
|
|
printf("Press any key to exit ...");
|
|
|
|
|
_getch();
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("Press any key to exit vmx ...");
|
|
|
|
|
_getch();
|
|
|
|
|
|
|
|
|
|
HyperdbgUnload();
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Installing Driver
|
|
|
|
|
//
|
|
|
|
|
if (HyperdbgUninstallDriver())
|
|
|
|
|
{
|
|
|
|
|
printf("Failed to uninstall driver\n");
|
|
|
|
|
printf("Press any key to exit ...");
|
|
|
|
|
_getch();
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("Press any key to exit...");
|
|
|
|
|
_getch();
|
|
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
|
|
return 0;
|
2020-03-24 06:35:02 -07:00
|
|
|
}
|
2020-04-11 10:28:37 -07:00
|
|
|
|