/* * 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 ScanDataH #define ScanDataH //--------------------------------------------------------------------------- #include "PacketUtils.h" #include "Packet.h" #include "PacketQueue.h" #include "Debug.h" #include "AgentConfig.h" class TScanRequest; class TScanResult; class TPEvent; class TEventQueue; class TPThread; /* * Types of scan that can be performed. */ typedef enum { SCAN_ARP_QUERY = 0, SCAN_PROMISC, SCAN_TCP_PORTS, SCAN_UDP_PORTS, SCAN_IP_PROTOS, SCAN_SERVICE, SCAN_SNMP, SCAN_SUBNET_ARP, SCAN_PING, SCAN_SWITCH, SCAN_TELNET, SCAN_DNS_QUERY, SCAN_NBNS_QUERY, SCAN_BLOCKPORT, SCAN_UNBLOCKPORT, SCAN_VERIFYPORT, SCAN_SINGLESWITCH, SCAN_SWITCHPROBE, SCAN_PLUGINS, INSTALL_PLUGIN, #ifndef ROGUESCANNER SCAN_WMI, SCAN_NMAP, #endif /* * This entry must always be last. */ N_SCAN_TYPES } TScanType; #ifdef ScanDataCPP /* * Scans automatically conducted on all detected devices. */ int _AutoScanTypes[] = { SCAN_ARP_QUERY, SCAN_DNS_QUERY, SCAN_NBNS_QUERY, SCAN_TCP_PORTS, SCAN_UDP_PORTS, #ifdef ENABLE_SCAN_PROMISC SCAN_PROMISC, #endif #ifndef ROGUESCANNER #ifdef ENABLE_NMAP SCAN_NMAP, #endif #endif //TODO: Remove this comment. //SCAN_IP_PROTOS -1 }; #else extern TScanType _AutoScanTypes[]; #endif #include "EventQueue.h" #include #include using namespace std; /* * A request for a particular type of scan. Each scan type is a subclass of * this class. */ class TScanRequest { public: TScanRequest() { ReplyQueue = NULL; ScanID = ScanIDs++; StartTime = time(NULL); } TScanRequest(TEventQueue *ReplyQueue) { this->ReplyQueue = ReplyQueue; ScanID = ScanIDs++; } virtual ~TScanRequest(void) {} /* * Generate strings describing this scan. */ virtual string TypeString() { return "UNKNOWN"; } virtual string Description() { return TypeString(); } /* * Get the type of this scan. * * TODO: Deprecate this function. */ virtual TScanType GetType() = 0; /* * Perform the scan and generate a result. */ virtual TScanResult *PerformScan(TPThread *Thread) = 0; /* * Specify the queue that results should go into. */ TEventQueue *GetReplyQueue(void) { return ReplyQueue; } void SetReplyQueue(TEventQueue *Queue) { ReplyQueue = Queue; } /* * Return a unique ID for this request. */ int GetID() { return ScanID; } /* * Return the IP address that will be scanned. */ TIPAddress GetTargetIP(void) { return TargetIP; } /* * Time that the scan was last actioned (either enqueued or started to be * processed. */ time_t StartTime; protected: /* * Set the IP address to be scanned. */ void SetTargetIP(TIPAddress &IPAddr) { TargetIP = IPAddr; } /* * IP address to scan. */ TIPAddress TargetIP; private: /* * If the scan will generate a reply, the queue to send the reply to. */ TEventQueue *ReplyQueue; /* * Unique ID of this scan. */ int ScanID; static int ScanIDs; }; //--------------------------------------------------------------------------- /* * Generate a scan request of the specified type. This function can only be * used to generate scans which take an IP address. */ TScanRequest *ScanRequestFactory(TScanType Type, TIPAddress TargetIP, TEventQueue *ReplyQueue); /* * Include the subclasses here so they are available everywhere. */ #include "ScanARPQuery.h" #include "ScanPromisc.h" #include "ScanARP.h" #include "ScanPing.h" #include "ScanIPProtocol.h" #include "ScanUDP.h" #include "ScanTCP.h" #include "ScanService.h" #include "ScanSNMP.h" #include "RubyThread.h" #include "ScanTelnet.h" #include "ScanDNSQuery.h" #include "ScanNBNSQuery.h" #ifndef ROGUESCANNER #include "ScanWMI.h" #include "ScanNMAP.h" #endif typedef enum { RESULT_NONE, RESULT_MAC_ADDRESS, RESULT_PROMISC, RESULT_TCP_PORTS, RESULT_PROBE, RESULT_HOSTNAME, RESULT_NETBIOS_NAME, RESULT_SUBNET_ARP, RESULT_MESSAGE } TResultType; //--------------------------------------------------------------------------- class TScanResult { public: TScanResult(); TScanResult(TIPAddress TargetIP); TScanResult(TMacAddress m, TIPAddress TargetIP); TScanResult(TResultType t, bool b, TIPAddress TargetIP); TScanResult(TResultType t, std::list *l, TIPAddress TargetIP); TScanResult(std::string Str); TScanResult(std::string Str, TIPAddress TargetIP); TScanResult(std::string Str, TMacAddress m, TIPAddress TargetIP); ~TScanResult(void); TResultType GetType(void){ return Type; } void SetType(TResultType t) { Type = t; } TMacAddress GetMacAddress(void){ return MacAddr; } bool GetFlag(void){ return Flag; } std::list *GetPorts(void){ return PortList; } std::string GetResponse(void){ return ResponseString; } TIPAddress GetIP() { return TargetIP; } void SetRequestID(int RequestID) { this->RequestID = RequestID; } int GetRequestID() { return RequestID; } private: TResultType Type; TMacAddress MacAddr; TIPAddress TargetIP; bool Flag; std::list *PortList; std::string ResponseString; int RequestID; }; //--------------------------------------------------------------------------- #endif