/* * Paglo Crawler * Copyright (C) 2006-2008 Paglo Labs Inc. All rights reserved. * www.paglo.com * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ //--------------------------------------------------------------------------- #ifndef ScanAgentAPIH #define ScanAgentAPIH //--------------------------------------------------------------------------- #include #include "ScanAgentUtils.h" #include "DataStore.h" #include "ScanData.h" #include "NetworkDevice.h" using namespace std; extern TDataStore _DataStore; typedef void TDeviceHandle; /* * Initialize the agent. Returns true if the agent was successfully initialized. */ bool ScanAgentInitialize(int argc, char **argv); /* * Periodically poll the agent to allow the main thread to run. Returns false * if the agent has requested a shutdown. */ bool ScanAgentPoll(void); void ScanAgentShutdown(void); /* * Access the issues. */ int IssueCount(void); TIssueInfo *GetIssue(int Index); void ClearIssue(int Index); /* * Detailed information about a device. */ typedef struct { string IPAddress; string MacAddress; string Vendor; string Model; string Classes; int Score; } TDeviceDetail; /* * Get the network devices one by one. */ int DeviceCount(void); TDeviceHandle *GetDevice(int Index); void GetDeviceDetail(TDeviceHandle *Device, TDeviceDetail *Detail); /* * Information about a probe. */ class TProbeInfo { public: TProbeInfo(int AScanID, TScanType AScanType, string ADescription, time_t AStartTime) : ScanID(AScanID), ScanType(AScanType), Description(ADescription), StartTime(AStartTime) {} int ScanID; TScanType ScanType; string Description; time_t StartTime; }; //--------------------------------------------------------------------------- /* * Statistics about the scanning process. */ class TScanningStatistics { public: /* * Whether the crawler is running. */ bool Running; int CompletedProbes; int Submissions; int Runtime; int AddressesScanned; int DevicesFound; int ThreadsActive; int PendingProbes; int CommBackoffSeconds; int FramesReceived; int FramesDropped; /* * Queue sizes. */ int CommunicationInputQueueSize; int CommunicationFailedCmdSize; int RubyInputQueueSize; int ScanReqQueueSize; int AnalysisInputQueueSize; int AnalysisOutputQueueSize; int AnalysisPktQueueSize; int NumPacketQueues; /* * Count of evidence by type. */ int NumEvidenceTypes; string EvidenceTypeNames[MAX_MULTIMAP_TYPE]; int EvidenceTypeCounts[MAX_MULTIMAP_TYPE]; /* * Time next network scan will start. */ time_t NextNetworkScanAt; /* * List of active threads. */ std::vector ActiveThreadList; /* * List of pending scans. */ std::vector PendingScanList; TScanningStatistics() { CompletedProbes = 0; Submissions = 0; Runtime = 0; AddressesScanned = 0; DevicesFound = 0; ThreadsActive = 0; PendingProbes = 0; NumEvidenceTypes = 0; } }; //--------------------------------------------------------------------------- extern TScanningStatistics _Stats; /* * Get the current scanning statistics. This method is quite expensive and * should not be called more than once per 5 seconds. */ void GetScanningStatistics(TScanningStatistics *Stats, bool IncludeEvidenceTypeCounts = false); /* * Send feedback about the classification results. */ void ClassificationCorrect(TDeviceHandle *Device); void ClassificationUpdate(TDeviceHandle *Device, const char *Vendor, const char *Model); /* * Delete all discovered devices. */ void DeleteDevices(); /* * Flush the submission cache. */ void FlushSubmissionCache(); /* * Force a network scan to start immediately. */ void StartCrawlNow(); /* * Expose the logging function. */ void LogMesg(char *Format, ...); /* * Dump information about memory usage to a file. */ void DumpMemory(); /* * Install a new plugin. This can only be called from the main/UI thread. * Returns error message if there is an issue. Empty string on succes. */ std::string InstallPlugin(std::string Path, bool FromURL); /* * Immediately initiate a scan against a device. */ std::string ImmediateScanDevice(std::string IPAddrStr); //--------------------------------------------------------------------------- #endif