#ifndef __SMALL_SOCKET_H #include "small_socket.h" #endif #ifndef __FP_H #include "fp.h" #endif #ifndef __MFILE_H #include "mfile.h" #endif class scanner_server { private: protected: /** * Every scanner must have a socket, so hold it here */ small_socket& sock; /** * Flag, if we should be polite when reading fps from file */ bool polite; /** * @name Connection Options * These options choose how the connection will be handled and initialized * over the scan. */ //@{ /** * Also the target host is for all servers in common */ mstring target_host; /** * Also the target port is for all servers in common */ int target_port; /** * The debuglevel, that says, what to output */ int debuglevel; /** * Connection timeout. */ long conn_timeout; /** * */ long recv_timeout; //@} /** * @name Internal Helper Functions * These functions help to do often used things easily, like readingfiles * or answers from the files. */ //@{ /** * Gets the next line of a file, but ignores comment lines, and also strips comments out * @param mfile& datei File from that the next line will be read * @return mstring String that contains the next valid non-comment line, without additional comments */ mstring get_next_line ( mfile& datei); /** * Gets the whole answer from the network, that is sent as reaction to a command. * @param none * @return the complete (maybe multilined) answer from the server */ mstring get_rfc_answer ( void ); //@} public: /** * Constructs the actual scanner base. * @param small_socket& sk Socket that will be used to connect (should not be connected) * @param int debug Debuglevel to be used in this instantiation. * @param bool pol If to be polite when reading input * @param long ct Connection Timeout in milliseconds * @param long rt Receive Timeout in milliseconds */ scanner_server( small_socket& sk, int debug, bool pol, long ct, long rt) : sock(sk),polite(pol),target_host("127.0.0.1"), target_port(25),debuglevel(debug), conn_timeout(ct), recv_timeout(rt){}; /** * Actually the data will be held in derived classes, so nothing to be done here */ virtual ~scanner_server() { } /** * Initializes the scanner, needs to be done before scanning process (reads fingerprints) * @return bool If the init was succesfully. If not, the scanner should not be used */ virtual bool initialize( void ) = 0; /** * @return mstring that will contain the protocoll name, i.e. POP3 or SMTP or FTP or... */ virtual mstring protocol( void ) { return "Virtual Protocol"; } /** * @return mstring Short information, what scanner this might be (fast scanning) */ virtual mstring is_server( void ) = 0; /** * Ends the scanning process, and calculates the matching values of the fingerprints */ virtual void finalize( void ) = 0; /** * @return list of list of fingerprints. Defined list, that helds the error mathces of the fps */ virtual dllist < dllist < fp > > get_fps( void ) =0; /** * @return list of mstrings that helds the type information of the fingerprint lists */ virtual dllist< mstring > get_descs( void ) =0; /** * That does the actual scan * @return bool if something went wrong. */ virtual bool do_scan( void ) =0; /** * Sets the target and port, that will be used for the scanning process, so the scanner can be reused * for multiple scans. * @param mstring target Target host to be scanned, preffereble as an IP * @param int port Port to be used for this scan, depends on derived service type */ inline virtual void set_target( mstring target, int port) { target_host = target; target_port = port; } };