portlist.h
来自「Ubuntu packages of security software。 相」· C头文件 代码 · 共 351 行 · 第 1/2 页
H
351 行
but we couldn't find a match RPC_STATUS_GOOD_PROG means rpc_program gives the prog # RPC_STATUS_NOT_RPC means the port doesn't appear to be RPC */ unsigned long rpc_program; /* Only valid if rpc_state == RPC_STATUS_GOOD_PROG */ unsigned int rpc_lowver; unsigned int rpc_highver;};class Port { public: Port(); ~Port(); // pass in an allocated struct serviceDeductions (don't worry about initializing, and // you don't have to free any internal ptrs. See the serviceDeductions definition for // the fields that are populated. Returns 0 if at least a name is available. int getServiceDeductions(struct serviceDeductions *sd); // sname should be NULL if sres is not // PROBESTATE_FINISHED_MATCHED. product,version, and/or extrainfo // will be NULL if unavailable. Note that this function makes its // own copy of sname and product/version/extrainfo. This function // also takes care of truncating the version strings to a // 'reasonable' length if neccessary, and cleaning up any unprinable // chars. (these tests are to avoid annoying DOS (or other) attacks // by malicious services). The fingerprint should be NULL unless // one is available and the user should submit it. tunnel must be // SERVICE_TUNNEL_NULL (normal) or SERVICE_TUNNEL_SSL (means ssl was // detected and we tried to tunnel through it ). void setServiceProbeResults(enum serviceprobestate sres, const char *sname, enum service_tunnel_type tunnel, const char *product, const char *version, const char *hostname, const char *ostype, const char *devicetype, const char *extrainfo, const char *fingerprint); char* cstringSanityCheck(const char* string, int len); /* Sets the results of an RPC scan. if rpc_status is not RPC_STATUS_GOOD_PROGRAM, pass 0 for the other args. This function takes care of setting the port's service and version appropriately. */ void setRPCProbeResults(int rpc_status, unsigned long rpc_program, unsigned int rpc_lowver, unsigned int rpc_highver); u16 portno; u8 proto; char *owner; int state; int confidence; /* How sure are we about the state? */ state_reason_t reason;#ifndef NOLUA ScriptResults scriptResults;#endif private: int rpc_status; /* RPC_STATUS_UNTESTED means we haven't checked RPC_STATUS_UNKNOWN means the port appears to be RPC but we couldn't find a match RPC_STATUS_GOOD_PROG means rpc_program gives the prog # RPC_STATUS_NOT_RPC means the port doesn't appear to be RPC */ unsigned long rpc_program; /* Only valid if rpc_state == RPC_STATUS_GOOD_PROG */ unsigned int rpc_lowver; unsigned int rpc_highver; Port *next; /* Internal use only -- we sometimes like to link them together */ enum serviceprobestate serviceprobe_results; // overall results of service scan char *serviceprobe_service; // If a service was discovered, points to the name // Any of these next three can be NULL if the details are not available char *serviceprobe_product; char *serviceprobe_version; char *serviceprobe_extrainfo; char *serviceprobe_hostname; char *serviceprobe_ostype; char *serviceprobe_devicetype; enum service_tunnel_type serviceprobe_tunnel; // A fingerprint that the user can submit if the service wasn't recognized char *serviceprobe_fp;};/* Needed enums to address some arrays. This values * should never be used directly. Use INPROTO2PORTLISTPROTO macro */enum portlist_proto { // PortList Protocols PORTLIST_PROTO_TCP = 0, PORTLIST_PROTO_UDP = 1, PORTLIST_PROTO_IP = 2, PORTLIST_PROTO_MAX = 3};class PortList { public: PortList(); ~PortList(); /* Set ports that will be scanned for each protocol. This function * must be called before any PortList object will be created. */ static void initializePortMap(int protocol, u16 *ports, int portcount); /* Free memory used by port_map. It should be done somewhere before quitting*/ static void freePortMap(); /* Add a new port to this list. If the state has changed, it is OK to call this function to effect the change */ int addPort(u16 portno, u8 protocol, char *owner, int state); int removePort(u16 portno, u8 protocol); /* Saves an identification string for the target containing these ports (an IP addrss might be a good example, but set what you want). Only used when printing new port updates. Optional. A copy is made. */ void setIdStr(const char *id); /* A function for iterating through the ports. Give NULL for the first "afterthisport". Then supply the most recent returned port for each subsequent call. When no more matching ports remain, NULL will be returned. To restrict returned ports to just one protocol, specify IPPROTO_TCP or IPPROTO_UDP for allowed_protocol. A TCPANDUDP for allowed_protocol matches either. A 0 for allowed_state matches all possible states. This function returns ports in numeric order from lowest to highest, except that if you ask for both TCP & UDP, every TCP port will be returned before we start returning UDP ports */ Port *nextPort(Port *afterthisport, int allowed_protocol, int allowed_state); /* Get Port structure from PortList structure.*/ Port *getPortEntry(u16 portno, u8 protocol); /* Set Port structure to PortList structure.*/ void setPortEntry(u16 portno, u8 protocol, Port *port); int setStateReason(u16 portno, u8 proto, reason_t reason, u8 ttl, u32 ip_addr); int numports; /* Total number of ports in list in ANY state */ int numscriptresults; /* Total number of scripts which produced output */ /* Get number of ports in this state. This a sum for protocols. */ int getStateCounts(int state); /* Get number of ports in this state for requested protocol. */ int getStateCounts(int protocol, int state); /* Cycles through the 0 or more "ignored" ports which should be consolidated for Nmap output. They are returned sorted by the number of prots in the state, starting with the most common. It should first be called with PORT_UNKNOWN to obtain the most popular ignored state (if any). Then call with that state to get the next most popular one. Returns the state if there is one, but returns PORT_UNKNOWN if there are no (more) states which qualify for consolidation */ int nextIgnoredState(int prevstate); /* Returns true if a state should be ignored (consolidated), false otherwise */ bool isIgnoredState(int state); int numIgnoredStates(); int numIgnoredPorts(); private: /* A string identifying the system these ports are on. Just used for printing open ports, if it is set with setIdStr() */ char *idstr; /* Number of ports in each state per each protocol */ int state_counts_proto[PORTLIST_PROTO_MAX][PORT_HIGHEST_STATE]; Port **port_list[PORTLIST_PROTO_MAX]; protected: /* Maps port_number to index in port_list array. * Only functions: getPortEntry, setPortEntry, initializePortMap and * nextPort should access this structure directly. */ static u16 *port_map[PORTLIST_PROTO_MAX]; /* Number of allocated elements in port_list per each protocol. */ static int port_list_count[PORTLIST_PROTO_MAX];};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?