Exemplo n.º 1
0
void StatusHaystackWrapper()
{
	if(IsHaystackUp())
	{
		cout << "Haystack Status: Running" << endl;
	}
	else
	{
		cout << "Haystack Status: Not running" << endl;
	}
}
Exemplo n.º 2
0
void CaptureData(std::string captureFolder, std::string interface)
{
	LOG(DEBUG, "Starting data capture. Storing results in folder:" + captureFolder, "");

	boost::filesystem::path create = captureFolder;

	try
	{
		boost::filesystem::create_directory(create);
	}
	catch(boost::filesystem::filesystem_error const& e)
	{
		LOG(DEBUG, ("Problem creating directory " + captureFolder), ("Problem creating directory " + captureFolder + ": " + e.what()));
	}

    // Write out the state of the haystack at capture
    if(IsHaystackUp())
    {
    	LOG(DEBUG, "Haystack appears up. Recording current state.", "");
    	string haystackFile = captureFolder + "/haystackIps.txt";
        haystackAddresses = Config::GetHaystackAddresses(Config::Inst()->GetPathHome() + "/" + Config::Inst()->GetPathConfigHoneydHS());
        haystackDhcpAddresses = Config::GetHoneydIpAddresses(Config::Inst()->GetIpListPath());

        LOG(DEBUG, "Writing haystack IPs to file " + haystackFile, "");
        ofstream haystackIpStream(haystackFile);
        for(uint i = 0; i < haystackDhcpAddresses.size(); i++)
        {
        	LOG(DEBUG, "Found haystack DHCP IP " + haystackDhcpAddresses.at(i).ip, "");
            haystackIpStream << haystackDhcpAddresses.at(i).ip << endl;
        }
        for(uint i = 0; i < haystackAddresses.size(); i++)
        {
        	LOG(DEBUG, "Found haystack static IP " + haystackAddresses.at(i).ip, "");
            haystackIpStream << haystackAddresses.at(i).ip << endl;
        }

        haystackIpStream.close();
    }

    // Prepare for packet capture
	string trainingCapFile = captureFolder + "/capture.pcap";

    InterfacePacketCapture *capture = new InterfacePacketCapture(interface);
    capture->Init();
    capture->SetPacketCb(SavePacket);

    pcap_t *handle = capture->GetPcapHandle();
    pcap_activate(handle);
    pcapDumpStream = pcap_dump_open(handle, trainingCapFile.c_str());

    capture->StartCaptureBlocking();
 }
Exemplo n.º 3
0
void StartHaystackWrapper(bool debug)
{
	if(!IsHaystackUp())
	{
		if(StartHaystack(debug))
		{
			cout << "Started Haystack" << endl;
		}
		else
		{
			cout << "Failed to start Haystack" << endl;
		}
	}
	else
	{
		cout << "Haystack is already running" << endl;
	}
}