HyperDbg/hyperdbg/libhyperdbg/code/debugger/commands/meta-commands/status.cpp

109 lines
2.8 KiB
C++
Raw Permalink Normal View History

2020-08-28 04:03:12 -07:00
/**
* @file status.cpp
2022-01-18 22:38:56 +03:30
* @author Sina Karvandi (sina@hyperdbg.org)
2020-12-19 15:09:14 -08:00
* @brief .status command
2020-08-28 04:03:12 -07:00
* @details
* @version 0.1
* @date 2020-08-23
*
* @copyright This project is released under the GNU Public License v3.
*
*/
#include "pch.h"
2020-08-28 04:03:12 -07:00
//
// Global Variables
//
extern BOOLEAN g_IsConnectedToHyperDbgLocally;
extern BOOLEAN g_IsConnectedToRemoteDebuggee;
extern BOOLEAN g_IsConnectedToRemoteDebugger;
2020-12-30 10:56:13 -08:00
extern BOOLEAN g_IsSerialConnectedToRemoteDebuggee;
2021-04-27 02:13:31 +04:30
extern BOOLEAN g_IsSerialConnectedToRemoteDebugger;
2021-03-22 18:19:39 +04:30
extern string g_ServerPort;
extern string g_ServerIp;
2020-08-28 04:03:12 -07:00
/**
2023-07-13 16:05:42 +09:00
* @brief help of the .status command
2020-12-30 10:56:13 -08:00
*
* @return VOID
2020-08-28 04:03:12 -07:00
*/
2021-03-22 18:19:39 +04:30
VOID
CommandStatusHelp()
{
2022-04-10 22:24:56 +04:30
ShowMessages(".status | status : gets the status of current debugger in local "
2021-03-22 18:19:39 +04:30
"system (if you connected to a remote system then '.status' "
"shows the state of current debugger, while 'status' shows the "
"state of remote debuggee).\n\n");
2021-03-22 18:19:39 +04:30
ShowMessages("syntax : \t.status\n");
ShowMessages("syntax : \tstatus\n");
2020-08-28 04:03:12 -07:00
}
/**
* @brief .status and status command handler
2020-12-30 10:56:13 -08:00
*
2024-07-30 15:47:35 +09:00
* @param CommandTokens
* @param Command
2024-07-30 15:47:35 +09:00
*
2020-12-30 10:56:13 -08:00
* @return VOID
2020-08-28 04:03:12 -07:00
*/
2021-03-22 18:19:39 +04:30
VOID
CommandStatus(vector<CommandToken> CommandTokens, string Command)
2021-03-22 18:19:39 +04:30
{
2024-07-30 15:47:35 +09:00
if (CommandTokens.size() != 1)
2021-03-22 18:19:39 +04:30
{
ShowMessages("incorrect use of the '%s'\n\n",
GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
2021-03-22 18:19:39 +04:30
CommandStatusHelp();
}
2020-08-28 04:03:12 -07:00
2021-03-22 18:19:39 +04:30
if (g_IsSerialConnectedToRemoteDebuggee)
2021-04-27 02:13:31 +04:30
{
//
// Connected to a remote debugger (serial port)
//
ShowMessages("remote debugging - debugger ('debugger mode')\n");
}
else if (g_IsSerialConnectedToRemoteDebugger)
2021-03-22 18:19:39 +04:30
{
//
// Connected to a remote debuggee (serial port)
//
2021-04-27 02:13:31 +04:30
ShowMessages("remote debugging - debuggee ('debugger mode')\n");
2021-03-22 18:19:39 +04:30
}
else if (g_IsConnectedToRemoteDebuggee)
{
//
// Connected to a remote debuggee
//
ShowMessages("remote debugging ('vmi mode'), ip : %s:%s \n",
g_ServerIp.c_str(),
g_ServerPort.c_str());
}
else if (g_IsConnectedToHyperDbgLocally)
{
//
// Connected to a local system
//
ShowMessages("local debugging ('vmi mode')\n");
}
else if (g_IsConnectedToRemoteDebugger)
{
//
2021-04-24 16:50:12 +04:30
// It's computer connect to a remote machine (this
// message shouldn't be showed)
2021-03-22 18:19:39 +04:30
//
ShowMessages("a remote debugger connected to this system in ('vmi "
"mode'), ip : %s:%s \n",
g_ServerIp.c_str(),
g_ServerPort.c_str());
}
else
{
//
// we never should see this message
//
2021-04-18 23:22:28 +04:30
ShowMessages("err, you're not connected to any instance of HyperDbg\n");
2021-03-22 18:19:39 +04:30
}
2020-08-28 04:03:12 -07:00
}