mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 14:49:29 +00:00
Get rid of "using namespace std".
Importing the whole std namespace caused a problem with Clang and the punning of bind and std::bind. http://seclists.org/nmap-dev/2012/q4/58 The Web's opinion of "using namespace std" also seems to be more against than for.
This commit is contained in:
parent
c47c5c52a1
commit
03d4b03d2c
7 changed files with 116 additions and 130 deletions
4
nmap.cc
4
nmap.cc
|
|
@ -135,8 +135,6 @@
|
|||
#endif
|
||||
#define DNET_VERSION VERSION
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* global options */
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
|
@ -1569,7 +1567,7 @@ void apply_delayed_options() {
|
|||
|
||||
int nmap_main(int argc, char *argv[]) {
|
||||
int i;
|
||||
vector<Target *> Targets;
|
||||
std::vector<Target *> Targets;
|
||||
time_t now;
|
||||
struct hostent *target = NULL;
|
||||
time_t timep;
|
||||
|
|
|
|||
67
osscan2.cc
67
osscan2.cc
|
|
@ -107,7 +107,6 @@
|
|||
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
extern NmapOps o;
|
||||
|
||||
/* 8 options:
|
||||
|
|
@ -316,7 +315,7 @@ int get_ipid_sequence(int numSamples, int *ipids, int islocalhost) {
|
|||
|
||||
/* Start the timeout clocks of any targets that aren't already timedout */
|
||||
static void startTimeOutClocks(OsScanInfo *OSI) {
|
||||
list<HostOsScanInfo *>::iterator hostI;
|
||||
std::list<HostOsScanInfo *>::iterator hostI;
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
for (hostI = OSI->incompleteHosts.begin();
|
||||
|
|
@ -329,7 +328,7 @@ static void startTimeOutClocks(OsScanInfo *OSI) {
|
|||
|
||||
/** Sets up the pcap descriptor in HOS (obtains a descriptor and sets the
|
||||
* appropriate BPF filter, based on the supplied list of targets). */
|
||||
static void begin_sniffer(HostOsScan *HOS, vector<Target *> &Targets) {
|
||||
static void begin_sniffer(HostOsScan *HOS, std::vector<Target *> &Targets) {
|
||||
char pcap_filter[2048];
|
||||
/* 20 IPv6 addresses is max (45 byte addy + 14 (" or src host ")) * 20 == 1180 */
|
||||
char dst_hosts[1200];
|
||||
|
|
@ -385,7 +384,7 @@ static void begin_sniffer(HostOsScan *HOS, vector<Target *> &Targets) {
|
|||
* reinitializing some variables of the supplied objects and deleting
|
||||
* some old information. */
|
||||
static void startRound(OsScanInfo *OSI, HostOsScan *HOS, int roundNum) {
|
||||
list<HostOsScanInfo *>::iterator hostI;
|
||||
std::list<HostOsScanInfo *>::iterator hostI;
|
||||
HostOsScanInfo *hsi = NULL;
|
||||
|
||||
/* Reinitial some parameters of the scan system. */
|
||||
|
|
@ -403,7 +402,7 @@ static void startRound(OsScanInfo *OSI, HostOsScan *HOS, int roundNum) {
|
|||
|
||||
/* Run the sequence generation tests (6 TCP probes sent 100ms apart) */
|
||||
static void doSeqTests(OsScanInfo *OSI, HostOsScan *HOS) {
|
||||
list<HostOsScanInfo *>::iterator hostI;
|
||||
std::list<HostOsScanInfo *>::iterator hostI;
|
||||
HostOsScanInfo *hsi = NULL;
|
||||
HostOsScanStats *hss = NULL;
|
||||
unsigned int unableToSend = 0; /* # of times in a row that hosts were unable to send probe */
|
||||
|
|
@ -569,7 +568,7 @@ static void doSeqTests(OsScanInfo *OSI, HostOsScan *HOS) {
|
|||
|
||||
/* TCP, UDP, ICMP Tests */
|
||||
static void doTUITests(OsScanInfo *OSI, HostOsScan *HOS) {
|
||||
list<HostOsScanInfo *>::iterator hostI;
|
||||
std::list<HostOsScanInfo *>::iterator hostI;
|
||||
HostOsScanInfo *hsi = NULL;
|
||||
HostOsScanStats *hss = NULL;
|
||||
unsigned int unableToSend; /* # of times in a row that hosts were unable to send probe */
|
||||
|
|
@ -738,7 +737,7 @@ static void doTUITests(OsScanInfo *OSI, HostOsScan *HOS) {
|
|||
|
||||
|
||||
static void endRound(OsScanInfo *OSI, HostOsScan *HOS, int roundNum) {
|
||||
list<HostOsScanInfo *>::iterator hostI;
|
||||
std::list<HostOsScanInfo *>::iterator hostI;
|
||||
HostOsScanInfo *hsi = NULL;
|
||||
int distance = -1;
|
||||
enum dist_calc_method distance_calculation_method = DIST_METHOD_NONE;
|
||||
|
|
@ -791,7 +790,7 @@ static void endRound(OsScanInfo *OSI, HostOsScan *HOS, int roundNum) {
|
|||
|
||||
|
||||
static void findBestFPs(OsScanInfo *OSI) {
|
||||
list<HostOsScanInfo *>::iterator hostI;
|
||||
std::list<HostOsScanInfo *>::iterator hostI;
|
||||
HostOsScanInfo *hsi = NULL;
|
||||
int i;
|
||||
|
||||
|
|
@ -826,7 +825,7 @@ static void findBestFPs(OsScanInfo *OSI) {
|
|||
|
||||
|
||||
static void printFP(OsScanInfo *OSI) {
|
||||
list<HostOsScanInfo *>::iterator hostI;
|
||||
std::list<HostOsScanInfo *>::iterator hostI;
|
||||
HostOsScanInfo *hsi = NULL;
|
||||
FingerPrintResultsIPv4 *FPR;
|
||||
|
||||
|
|
@ -851,8 +850,8 @@ static void printFP(OsScanInfo *OSI) {
|
|||
the maximum number of OS detection tries allowed for it without
|
||||
matching, it is transferred to the passed in unMatchedHosts list.
|
||||
Returns the number of hosts moved to unMatchedHosts. */
|
||||
static int expireUnmatchedHosts(OsScanInfo *OSI, list<HostOsScanInfo *> *unMatchedHosts) {
|
||||
list<HostOsScanInfo *>::iterator hostI, nextHost;
|
||||
static int expireUnmatchedHosts(OsScanInfo *OSI, std::list<HostOsScanInfo *> *unMatchedHosts) {
|
||||
std::list<HostOsScanInfo *>::iterator hostI, nextHost;
|
||||
int hostsRemoved = 0;
|
||||
HostOsScanInfo *HOS;
|
||||
|
||||
|
|
@ -1123,7 +1122,7 @@ void HostOsScanStats::addNewProbe(OFProbeType type, int subid) {
|
|||
|
||||
|
||||
/* Remove a probe from the probesActive. */
|
||||
void HostOsScanStats::removeActiveProbe(list<OFProbe *>::iterator probeI) {
|
||||
void HostOsScanStats::removeActiveProbe(std::list<OFProbe *>::iterator probeI) {
|
||||
OFProbe *probe = *probeI;
|
||||
probesActive.erase(probeI);
|
||||
delete probe;
|
||||
|
|
@ -1132,8 +1131,8 @@ void HostOsScanStats::removeActiveProbe(list<OFProbe *>::iterator probeI) {
|
|||
|
||||
/* Get an active probe from active probe list identified by probe type
|
||||
and subid. Returns probesActive.end() if there isn't one */
|
||||
list<OFProbe *>::iterator HostOsScanStats::getActiveProbe(OFProbeType type, int subid) {
|
||||
list<OFProbe *>::iterator probeI;
|
||||
std::list<OFProbe *>::iterator HostOsScanStats::getActiveProbe(OFProbeType type, int subid) {
|
||||
std::list<OFProbe *>::iterator probeI;
|
||||
OFProbe *probe = NULL;
|
||||
|
||||
for (probeI = probesActive.begin(); probeI != probesActive.end(); probeI++) {
|
||||
|
|
@ -1154,14 +1153,14 @@ list<OFProbe *>::iterator HostOsScanStats::getActiveProbe(OFProbeType type, int
|
|||
|
||||
|
||||
/* Move a probe from probesToSend to probesActive. */
|
||||
void HostOsScanStats::moveProbeToActiveList(list<OFProbe *>::iterator probeI) {
|
||||
void HostOsScanStats::moveProbeToActiveList(std::list<OFProbe *>::iterator probeI) {
|
||||
probesActive.push_back(*probeI);
|
||||
probesToSend.erase(probeI);
|
||||
}
|
||||
|
||||
|
||||
/* Move a probe from probesActive to probesToSend. */
|
||||
void HostOsScanStats::moveProbeToUnSendList(list<OFProbe *>::iterator probeI) {
|
||||
void HostOsScanStats::moveProbeToUnSendList(std::list<OFProbe *>::iterator probeI) {
|
||||
probesToSend.push_back(*probeI);
|
||||
probesActive.erase(probeI);
|
||||
}
|
||||
|
|
@ -1193,7 +1192,7 @@ double HostOsScanStats::timingRatio() {
|
|||
bool HostOsScan::nextTimeout(HostOsScanStats *hss, struct timeval *when) {
|
||||
assert(hss);
|
||||
struct timeval probe_to, earliest_to;
|
||||
list<OFProbe *>::iterator probeI;
|
||||
std::list<OFProbe *>::iterator probeI;
|
||||
bool firstgood = true;
|
||||
|
||||
assert(when);
|
||||
|
|
@ -1323,7 +1322,7 @@ void HostOsScan::buildSeqProbeList(HostOsScanStats *hss) {
|
|||
* timed out. */
|
||||
void HostOsScan::updateActiveSeqProbes(HostOsScanStats *hss) {
|
||||
assert(hss);
|
||||
list<OFProbe *>::iterator probeI, nxt;
|
||||
std::list<OFProbe *>::iterator probeI, nxt;
|
||||
OFProbe *probe = NULL;
|
||||
|
||||
for (probeI = hss->probesActive.begin(); probeI != hss->probesActive.end(); probeI = nxt) {
|
||||
|
|
@ -1405,7 +1404,7 @@ void HostOsScan::buildTUIProbeList(HostOsScanStats *hss) {
|
|||
* 2) Move timedout probes to probeNeedToSend; */
|
||||
void HostOsScan::updateActiveTUIProbes(HostOsScanStats *hss) {
|
||||
assert(hss);
|
||||
list<OFProbe *>::iterator probeI, nxt;
|
||||
std::list<OFProbe *>::iterator probeI, nxt;
|
||||
OFProbe *probe = NULL;
|
||||
|
||||
for (probeI = hss->probesActive.begin(); probeI != hss->probesActive.end(); probeI = nxt) {
|
||||
|
|
@ -1436,7 +1435,7 @@ void HostOsScan::updateActiveTUIProbes(HostOsScanStats *hss) {
|
|||
* return true. */
|
||||
bool HostOsScan::hostSendOK(HostOsScanStats *hss, struct timeval *when) {
|
||||
assert(hss);
|
||||
list<OFProbe *>::iterator probeI;
|
||||
std::list<OFProbe *>::iterator probeI;
|
||||
int packTime;
|
||||
struct timeval probe_to, earliest_to, sendTime;
|
||||
long tdiff;
|
||||
|
|
@ -1505,7 +1504,7 @@ bool HostOsScan::hostSendOK(HostOsScanStats *hss, struct timeval *when) {
|
|||
* false; else, fill it with now and return true. */
|
||||
bool HostOsScan::hostSeqSendOK(HostOsScanStats *hss, struct timeval *when) {
|
||||
assert(hss);
|
||||
list<OFProbe *>::iterator probeI;
|
||||
std::list<OFProbe *>::iterator probeI;
|
||||
int packTime = 0, maxWait = 0;
|
||||
struct timeval probe_to, earliest_to, sendTime;
|
||||
long tdiff;
|
||||
|
|
@ -1586,7 +1585,7 @@ unsigned long HostOsScan::timeProbeTimeout(HostOsScanStats *hss) {
|
|||
|
||||
void HostOsScan::sendNextProbe(HostOsScanStats *hss) {
|
||||
assert(hss);
|
||||
list<OFProbe *>::iterator probeI;
|
||||
std::list<OFProbe *>::iterator probeI;
|
||||
OFProbe *probe = NULL;
|
||||
|
||||
if (hss->probesToSend.empty())
|
||||
|
|
@ -1791,7 +1790,7 @@ bool HostOsScan::processResp(HostOsScanStats *hss, struct ip *ip, unsigned int l
|
|||
struct icmp *icmp;
|
||||
int testno;
|
||||
bool isPktUseful = false;
|
||||
list<OFProbe *>::iterator probeI;
|
||||
std::list<OFProbe *>::iterator probeI;
|
||||
OFProbe *probe;
|
||||
|
||||
if (len < 20 || len < (4 * ip->ip_hl) + 4U)
|
||||
|
|
@ -3309,7 +3308,7 @@ HostOsScanInfo::~HostOsScanInfo() {
|
|||
* Implementation of class OsScanInfo *
|
||||
******************************************************************************/
|
||||
|
||||
OsScanInfo::OsScanInfo(vector<Target *> &Targets) {
|
||||
OsScanInfo::OsScanInfo(std::vector<Target *> &Targets) {
|
||||
unsigned int targetno;
|
||||
HostOsScanInfo *hsi;
|
||||
int num_timedout = 0;
|
||||
|
|
@ -3368,7 +3367,7 @@ OsScanInfo::~OsScanInfo()
|
|||
/* Find a HostScanStats by IP its address in the incomplete list. Returns NULL if
|
||||
none are found. */
|
||||
HostOsScanInfo *OsScanInfo::findIncompleteHost(struct sockaddr_storage *ss) {
|
||||
list<HostOsScanInfo *>::iterator hostI;
|
||||
std::list<HostOsScanInfo *>::iterator hostI;
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *) ss;
|
||||
|
||||
if (sin->sin_family != AF_INET)
|
||||
|
|
@ -3404,7 +3403,7 @@ HostOsScanInfo *OsScanInfo::nextIncompleteHost() {
|
|||
/* Removes any hosts that have completed their scans from the incompleteHosts
|
||||
list. Returns the number of hosts removed. */
|
||||
int OsScanInfo::removeCompletedHosts() {
|
||||
list<HostOsScanInfo *>::iterator hostI, nxt;
|
||||
std::list<HostOsScanInfo *>::iterator hostI, nxt;
|
||||
HostOsScanInfo *hsi = NULL;
|
||||
int hostsRemoved = 0;
|
||||
bool timedout = false;
|
||||
|
|
@ -3469,10 +3468,10 @@ void OSScan::reset() {
|
|||
* too many to be processed at the same time. The threshold is based on Nmap's
|
||||
* timing level (when timing level is above 4, no chunking is performed).
|
||||
* The reason targets are processed in smaller groups is to improve accuracy. */
|
||||
int OSScan::chunk_and_do_scan(vector<Target *> &Targets, int family) {
|
||||
int OSScan::chunk_and_do_scan(std::vector<Target *> &Targets, int family) {
|
||||
unsigned int max_os_group_sz = 20;
|
||||
double fudgeratio = 1.2; /* Allow a slightly larger final group rather than finish with a tiny one */
|
||||
vector<Target *> tmpTargets;
|
||||
std::vector<Target *> tmpTargets;
|
||||
unsigned int startidx = 0;
|
||||
|
||||
if (o.timing_level == 4)
|
||||
|
|
@ -3506,11 +3505,11 @@ int OSScan::chunk_and_do_scan(vector<Target *> &Targets, int family) {
|
|||
/* Performs the OS detection for IPv4 hosts. This method should not be called
|
||||
* directly. os_scan() should be used instead, as it handles chunking so
|
||||
* you don't do too many targets in parallel */
|
||||
int OSScan::os_scan_ipv4(vector<Target *> &Targets) {
|
||||
int OSScan::os_scan_ipv4(std::vector<Target *> &Targets) {
|
||||
int itry = 0;
|
||||
/* Hosts which haven't matched and have been removed from incompleteHosts because
|
||||
* they have exceeded the number of retransmissions the host is allowed. */
|
||||
list<HostOsScanInfo *> unMatchedHosts;
|
||||
std::list<HostOsScanInfo *> unMatchedHosts;
|
||||
|
||||
/* Check we have at least one target*/
|
||||
if (Targets.size() == 0) {
|
||||
|
|
@ -3572,7 +3571,7 @@ int OSScan::os_scan_ipv4(vector<Target *> &Targets) {
|
|||
/* Performs the OS detection for IPv6 hosts. This method should not be called
|
||||
* directly. os_scan() should be used instead, as it handles chunking so
|
||||
* you don't do too many targets in parallel */
|
||||
int OSScan::os_scan_ipv6(vector<Target *> &Targets) {
|
||||
int OSScan::os_scan_ipv6(std::vector<Target *> &Targets) {
|
||||
|
||||
/* Object instantiation */
|
||||
FPEngine6 fp6;
|
||||
|
|
@ -3590,9 +3589,9 @@ int OSScan::os_scan_ipv6(vector<Target *> &Targets) {
|
|||
* targets and classifies it into two groups: IPv4 and IPv6 targets. Then,
|
||||
* OS detection is carried out for those two separate groups. It returns
|
||||
* OP_SUCCESS on success or OP_FAILURE in case of error. */
|
||||
int OSScan::os_scan(vector<Target *> &Targets) {
|
||||
vector<Target *> ip4_targets;
|
||||
vector<Target *> ip6_targets;
|
||||
int OSScan::os_scan(std::vector<Target *> &Targets) {
|
||||
std::vector<Target *> ip4_targets;
|
||||
std::vector<Target *> ip6_targets;
|
||||
int res4 = OP_SUCCESS, res6 = OP_SUCCESS;
|
||||
|
||||
/* Make sure we have at least one target */
|
||||
|
|
|
|||
18
output.cc
18
output.cc
|
|
@ -118,10 +118,6 @@
|
|||
#include <list>
|
||||
#include <sstream>
|
||||
|
||||
/* Workaround for lack of namespace std on HP-UX 11.00 */
|
||||
namespace std {};
|
||||
using namespace std;
|
||||
|
||||
extern NmapOps o;
|
||||
static const char *logtypes[LOG_NUM_FILES] = LOG_NAMES;
|
||||
|
||||
|
|
@ -273,8 +269,8 @@ void win32_fatal_raw_sockets(const char *devname) {
|
|||
static void print_iflist_pcap_mapping(const struct interface_info *iflist,
|
||||
int numifs) {
|
||||
pcap_if_t *pcap_ifs;
|
||||
list<const pcap_if_t *> leftover_pcap_ifs;
|
||||
list<const pcap_if_t *>::iterator leftover_p;
|
||||
std::list<const pcap_if_t *> leftover_pcap_ifs;
|
||||
std::list<const pcap_if_t *>::iterator leftover_p;
|
||||
int i;
|
||||
|
||||
/* Build a list of "leftover" libpcap interfaces. Initially it contains all
|
||||
|
|
@ -295,7 +291,7 @@ static void print_iflist_pcap_mapping(const struct interface_info *iflist,
|
|||
|
||||
if (DnetName2PcapName(iflist[i].devname, pcap_name, sizeof(pcap_name))) {
|
||||
/* We got a name. Remove it from the list of leftovers. */
|
||||
list<const pcap_if_t *>::iterator next;
|
||||
std::list<const pcap_if_t *>::iterator next;
|
||||
for (leftover_p = leftover_pcap_ifs.begin();
|
||||
leftover_p != leftover_pcap_ifs.end(); leftover_p = next) {
|
||||
next = leftover_p;
|
||||
|
|
@ -523,7 +519,7 @@ void printportoutput(Target *currenths, PortList *plist) {
|
|||
int numignoredports = plist->numIgnoredPorts();
|
||||
int numports = plist->numPorts();
|
||||
|
||||
vector<const char *> saved_servicefps;
|
||||
std::vector<const char *> saved_servicefps;
|
||||
|
||||
if (o.noportscan)
|
||||
return;
|
||||
|
|
@ -1141,7 +1137,7 @@ static void doscanflags() {
|
|||
};
|
||||
|
||||
if (o.scanflags != -1) {
|
||||
string flagstring;
|
||||
std::string flagstring;
|
||||
|
||||
for (unsigned int i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
|
||||
if (o.scanflags & flags[i].flag)
|
||||
|
|
@ -2230,7 +2226,7 @@ static void printtraceroute_normal(Target *currenths) {
|
|||
static const int HOP_COL = 0, RTT_COL = 1, HOST_COL = 2;
|
||||
NmapOutputTable Tbl(currenths->traceroute_hops.size() + 1, 3);
|
||||
struct probespec probe;
|
||||
list<TracerouteHop>::iterator it;
|
||||
std::list<TracerouteHop>::iterator it;
|
||||
int row;
|
||||
|
||||
/* No trace, must be localhost. */
|
||||
|
|
@ -2337,7 +2333,7 @@ static void printtraceroute_normal(Target *currenths) {
|
|||
|
||||
static void printtraceroute_xml(Target *currenths) {
|
||||
struct probespec probe;
|
||||
list<TracerouteHop>::iterator it;
|
||||
std::list<TracerouteHop>::iterator it;
|
||||
|
||||
/* No trace, must be localhost. */
|
||||
if (currenths->traceroute_hops.size() == 0)
|
||||
|
|
|
|||
|
|
@ -102,8 +102,6 @@
|
|||
#include "tcpip.h"
|
||||
#include "libnetutil/netutil.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#if HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif /* HAVE_STRINGS_H */
|
||||
|
|
|
|||
101
scan_engine.cc
101
scan_engine.cc
|
|
@ -114,7 +114,6 @@
|
|||
#include <list>
|
||||
#include <map>
|
||||
|
||||
using namespace std;
|
||||
extern NmapOps o;
|
||||
class UltraScanInfo;
|
||||
|
||||
|
|
@ -499,7 +498,7 @@ public:
|
|||
|
||||
/* Removes a probe from probes_outstanding, adjusts HSS and USS
|
||||
active probe stats accordingly, then deletes the probe. */
|
||||
void destroyOutstandingProbe(list<UltraProbe *>::iterator probeI);
|
||||
void destroyOutstandingProbe(std::list<UltraProbe *>::iterator probeI);
|
||||
|
||||
/* Removes all probes from probes_outstanding using
|
||||
destroyOutstandingProbe. This is used in ping scan to quit waiting
|
||||
|
|
@ -509,7 +508,7 @@ public:
|
|||
|
||||
/* Mark an outstanding probe as timedout. Adjusts stats
|
||||
accordingly. For connect scans, this closes the socket. */
|
||||
void markProbeTimedout(list<UltraProbe *>::iterator probeI);
|
||||
void markProbeTimedout(std::list<UltraProbe *>::iterator probeI);
|
||||
|
||||
/* New (active) probes are appended to the end of this list. When a
|
||||
host times out, it will be marked as such, but may hang around on
|
||||
|
|
@ -518,7 +517,7 @@ public:
|
|||
are outstanding. Probes on the bench (reached the current
|
||||
maximum tryno and expired) are not counted in
|
||||
probes_outstanding. */
|
||||
list<UltraProbe *> probes_outstanding;
|
||||
std::list<UltraProbe *> probes_outstanding;
|
||||
/* The number of probes in probes_outstanding, minus the inactive (timed out) ones */
|
||||
unsigned int num_probes_active;
|
||||
/* Probes timed out but not yet retransmitted because of congestion
|
||||
|
|
@ -537,20 +536,20 @@ public:
|
|||
tryno of benh members is bench_tryno. If the maximum tryno
|
||||
increases, everyone on the bench is moved to the retry_stack.
|
||||
*/
|
||||
vector<probespec> probe_bench;
|
||||
std::vector<probespec> probe_bench;
|
||||
unsigned int bench_tryno; /* # tryno of probes on the bench */
|
||||
/* The retry_stack are probespecs that were on the bench but are now
|
||||
slated to be retried. It is kept sorted such that probes with highest
|
||||
retry counts are on top, ready to be taken first. */
|
||||
vector<probespec> retry_stack;
|
||||
std::vector<probespec> retry_stack;
|
||||
/* retry_stack_tries MUST BE KEPT IN SYNC WITH retry_stack.
|
||||
retry_stack_tries[i] is the number of completed retries for the
|
||||
probe in retry_stack[i] */
|
||||
vector<u8> retry_stack_tries;
|
||||
std::vector<u8> retry_stack_tries;
|
||||
/* tryno of probes on the retry queue */
|
||||
/* Moves the given probe from the probes_outstanding list, to
|
||||
probe_bench, and decrements num_probes_waiting_retransmit accordingly */
|
||||
void moveProbeToBench(list<UltraProbe *>::iterator probeI);
|
||||
void moveProbeToBench(std::list<UltraProbe *>::iterator probeI);
|
||||
/* Dismiss all probe attempts on bench -- the ports are marked
|
||||
'filtered' or whatever is appropriate for having no response */
|
||||
void dismissBench();
|
||||
|
|
@ -623,12 +622,12 @@ private:
|
|||
class UltraScanInfo {
|
||||
public:
|
||||
UltraScanInfo();
|
||||
UltraScanInfo(vector<Target *> &Targets, struct scan_lists *pts, stype scantype) {
|
||||
UltraScanInfo(std::vector<Target *> &Targets, struct scan_lists *pts, stype scantype) {
|
||||
Init(Targets, pts, scantype);
|
||||
}
|
||||
~UltraScanInfo();
|
||||
/* Must call Init if you create object with default constructor */
|
||||
void Init(vector<Target *> &Targets, struct scan_lists *pts, stype scantp);
|
||||
void Init(std::vector<Target *> &Targets, struct scan_lists *pts, stype scantp);
|
||||
|
||||
unsigned int numProbesPerHost();
|
||||
|
||||
|
|
@ -705,11 +704,11 @@ public:
|
|||
|
||||
/* Any function which messes with (removes elements from)
|
||||
incompleteHosts may have to manipulate nextI */
|
||||
list<HostScanStats *> incompleteHosts;
|
||||
std::list<HostScanStats *> incompleteHosts;
|
||||
/* Hosts are moved from incompleteHosts to completedHosts as they are
|
||||
completed. We keep them around because sometimes responses come back very
|
||||
late, after we consider a host completed. */
|
||||
list<HostScanStats *> completedHosts;
|
||||
std::list<HostScanStats *> completedHosts;
|
||||
/* How long (in msecs) we keep a host in completedHosts */
|
||||
unsigned int completedHostLifetime;
|
||||
/* The last time we went through completedHosts to remove hosts */
|
||||
|
|
@ -726,7 +725,7 @@ public:
|
|||
private:
|
||||
|
||||
unsigned int numInitialTargets;
|
||||
list<HostScanStats *>::iterator nextI;
|
||||
std::list<HostScanStats *>::iterator nextI;
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -1203,7 +1202,7 @@ HostScanStats::HostScanStats(Target *t, UltraScanInfo *UltraSI) {
|
|||
}
|
||||
|
||||
HostScanStats::~HostScanStats() {
|
||||
list<UltraProbe *>::iterator probeI, next;
|
||||
std::list<UltraProbe *>::iterator probeI, next;
|
||||
|
||||
/* Move any hosts from the bench to probes_outstanding for easier deletion */
|
||||
for (probeI = probes_outstanding.begin(); probeI != probes_outstanding.end();
|
||||
|
|
@ -1261,7 +1260,7 @@ unsigned long HostScanStats::probeExpireTime(const UltraProbe *probe) {
|
|||
true. */
|
||||
bool HostScanStats::sendOK(struct timeval *when) {
|
||||
struct ultra_timing_vals tmng;
|
||||
list<UltraProbe *>::iterator probeI;
|
||||
std::list<UltraProbe *>::iterator probeI;
|
||||
struct timeval probe_to, earliest_to, sendTime;
|
||||
long tdiff;
|
||||
|
||||
|
|
@ -1355,7 +1354,7 @@ bool HostScanStats::sendOK(struct timeval *when) {
|
|||
puts now in when. */
|
||||
bool HostScanStats::nextTimeout(struct timeval *when) {
|
||||
struct timeval probe_to, earliest_to;
|
||||
list<UltraProbe *>::iterator probeI;
|
||||
std::list<UltraProbe *>::iterator probeI;
|
||||
bool firstgood = true;
|
||||
|
||||
assert(when);
|
||||
|
|
@ -1388,7 +1387,7 @@ bool HostScanStats::nextTimeout(struct timeval *when) {
|
|||
the allowedTryno may increase again. If it is false, any probes
|
||||
which have reached the given limit may be dealth with. */
|
||||
unsigned int HostScanStats::allowedTryno(bool *capped, bool *mayincrease) {
|
||||
list<UltraProbe *>::iterator probeI;
|
||||
std::list<UltraProbe *>::iterator probeI;
|
||||
UltraProbe *probe = NULL;
|
||||
bool allfinished = true;
|
||||
unsigned int maxval = 0;
|
||||
|
|
@ -1485,7 +1484,7 @@ HostScanStats *UltraScanInfo::nextIncompleteHost() {
|
|||
/* Return a number between 0.0 and 1.0 inclusive indicating how much of the scan
|
||||
is done. */
|
||||
double UltraScanInfo::getCompletionFraction() {
|
||||
list<HostScanStats *>::iterator hostI;
|
||||
std::list<HostScanStats *>::iterator hostI;
|
||||
double total;
|
||||
|
||||
/* Add 1 for each completed host. */
|
||||
|
|
@ -1510,8 +1509,8 @@ double UltraScanInfo::getCompletionFraction() {
|
|||
|
||||
/* Initialize the state for ports that don't receive a response in all the
|
||||
targets. */
|
||||
static void set_default_port_state(vector<Target *> &targets, stype scantype) {
|
||||
vector<Target *>::iterator target;
|
||||
static void set_default_port_state(std::vector<Target *> &targets, stype scantype) {
|
||||
std::vector<Target *>::iterator target;
|
||||
|
||||
for (target = targets.begin(); target != targets.end(); target++) {
|
||||
switch (scantype) {
|
||||
|
|
@ -1551,7 +1550,7 @@ static void set_default_port_state(vector<Target *> &targets, stype scantype) {
|
|||
|
||||
/* Order of initializations in this function CAN BE IMPORTANT, so be careful
|
||||
mucking with it. */
|
||||
void UltraScanInfo::Init(vector<Target *> &Targets, struct scan_lists *pts, stype scantp) {
|
||||
void UltraScanInfo::Init(std::vector<Target *> &Targets, struct scan_lists *pts, stype scantp) {
|
||||
unsigned int targetno = 0;
|
||||
HostScanStats *hss;
|
||||
int num_timedout = 0;
|
||||
|
|
@ -1728,7 +1727,7 @@ unsigned int UltraScanInfo::numProbesPerHost() {
|
|||
bool UltraScanInfo::sendOK(struct timeval *when) {
|
||||
struct timeval lowhtime = {0};
|
||||
struct timeval tmptv;
|
||||
list<HostScanStats *>::iterator host;
|
||||
std::list<HostScanStats *>::iterator host;
|
||||
bool ggood = false;
|
||||
bool thisHostGood = false;
|
||||
bool foundgood = false;
|
||||
|
|
@ -1786,7 +1785,7 @@ bool UltraScanInfo::sendOK(struct timeval *when) {
|
|||
/* Find a HostScanStats by its IP address in the incomplete and completed lists.
|
||||
Returns NULL if none are found. */
|
||||
HostScanStats *UltraScanInfo::findHost(struct sockaddr_storage *ss) {
|
||||
list<HostScanStats *>::iterator hss;
|
||||
std::list<HostScanStats *>::iterator hss;
|
||||
struct sockaddr_storage target_addr;
|
||||
size_t target_addr_len;
|
||||
|
||||
|
|
@ -1833,7 +1832,7 @@ static bool pingprobe_is_better(const probespec *new_probe, int new_state,
|
|||
list, and remove any hosts from completedHosts which have exceeded their
|
||||
lifetime. Returns the number of hosts removed. */
|
||||
int UltraScanInfo::removeCompletedHosts() {
|
||||
list<HostScanStats *>::iterator hostI, nxt;
|
||||
std::list<HostScanStats *>::iterator hostI, nxt;
|
||||
HostScanStats *hss = NULL;
|
||||
int hostsRemoved = 0;
|
||||
bool timedout = false;
|
||||
|
|
@ -2216,7 +2215,7 @@ int HostScanStats::freshPortsLeft() {
|
|||
|
||||
/* Removes a probe from probes_outstanding, adjusts HSS and USS
|
||||
active probe stats accordingly, then deletes the probe. */
|
||||
void HostScanStats::destroyOutstandingProbe(list<UltraProbe *>::iterator probeI) {
|
||||
void HostScanStats::destroyOutstandingProbe(std::list<UltraProbe *>::iterator probeI) {
|
||||
UltraProbe *probe = *probeI;
|
||||
assert(!probes_outstanding.empty());
|
||||
if (!probe->timedout) {
|
||||
|
|
@ -2336,7 +2335,7 @@ static void ultrascan_adjust_timing(UltraScanInfo *USI, HostScanStats *hss,
|
|||
|
||||
/* Mark an outstanding probe as timedout. Adjusts stats
|
||||
accordingly. For connect scans, this closes the socket. */
|
||||
void HostScanStats::markProbeTimedout(list<UltraProbe *>::iterator probeI) {
|
||||
void HostScanStats::markProbeTimedout(std::list<UltraProbe *>::iterator probeI) {
|
||||
UltraProbe *probe = *probeI;
|
||||
assert(!probe->timedout);
|
||||
assert(!probe->retransmitted);
|
||||
|
|
@ -2774,7 +2773,7 @@ void HostScanStats::retransmitBench() {
|
|||
/* Moves the given probe from the probes_outstanding list, to
|
||||
probe_bench, and decrements num_probes_waiting_retransmit
|
||||
accordingly */
|
||||
void HostScanStats::moveProbeToBench(list<UltraProbe *>::iterator probeI) {
|
||||
void HostScanStats::moveProbeToBench(std::list<UltraProbe *>::iterator probeI) {
|
||||
UltraProbe *probe = *probeI;
|
||||
if (!probe_bench.empty())
|
||||
assert(bench_tryno == probe->tryno);
|
||||
|
|
@ -2791,7 +2790,7 @@ void HostScanStats::moveProbeToBench(list<UltraProbe *>::iterator probeI) {
|
|||
/* Called when a ping response is discovered. If adjust_timing is false, timing
|
||||
stats are not updated. */
|
||||
static void ultrascan_ping_update(UltraScanInfo *USI, HostScanStats *hss,
|
||||
list<UltraProbe *>::iterator probeI,
|
||||
std::list<UltraProbe *>::iterator probeI,
|
||||
struct timeval *rcvdtime,
|
||||
bool adjust_timing = true) {
|
||||
ultrascan_adjust_timeouts(USI, hss, *probeI, rcvdtime);
|
||||
|
|
@ -2834,7 +2833,7 @@ static bool ultrascan_host_pspec_update(UltraScanInfo *USI, HostScanStats *hss,
|
|||
timing information and other stats as appropriate. If
|
||||
adjust_timing_hint is false, packet stats are not updated. */
|
||||
static void ultrascan_host_probe_update(UltraScanInfo *USI, HostScanStats *hss,
|
||||
list<UltraProbe *>::iterator probeI,
|
||||
std::list<UltraProbe *>::iterator probeI,
|
||||
int newstate, struct timeval *rcvdtime,
|
||||
bool adjust_timing_hint = true) {
|
||||
UltraProbe *probe = *probeI;
|
||||
|
|
@ -2897,7 +2896,7 @@ static void ultrascan_host_probe_update(UltraScanInfo *USI, HostScanStats *hss,
|
|||
instead. If adjust_timing_hint is false, packet stats are not
|
||||
updated. */
|
||||
static void ultrascan_port_probe_update(UltraScanInfo *USI, HostScanStats *hss,
|
||||
list<UltraProbe *>::iterator probeI,
|
||||
std::list<UltraProbe *>::iterator probeI,
|
||||
int newstate, struct timeval *rcvdtime,
|
||||
bool adjust_timing_hint = true) {
|
||||
UltraProbe *probe = *probeI;
|
||||
|
|
@ -3017,7 +3016,7 @@ static UltraProbe *sendConnectScanProbe(UltraScanInfo *USI, HostScanStats *hss,
|
|||
u16 destport, u8 tryno, u8 pingseq) {
|
||||
|
||||
UltraProbe *probe = new UltraProbe();
|
||||
list<UltraProbe *>::iterator probeI;
|
||||
std::list<UltraProbe *>::iterator probeI;
|
||||
static bool connecterror = false;
|
||||
int rc;
|
||||
int connect_errno = 0;
|
||||
|
|
@ -3758,7 +3757,7 @@ static void sendGlobalPingProbe(UltraScanInfo *USI) {
|
|||
}
|
||||
|
||||
static void doAnyPings(UltraScanInfo *USI) {
|
||||
list<HostScanStats *>::iterator hostI;
|
||||
std::list<HostScanStats *>::iterator hostI;
|
||||
HostScanStats *hss = NULL;
|
||||
|
||||
gettimeofday(&USI->now, NULL);
|
||||
|
|
@ -3833,11 +3832,11 @@ static void retransmitProbe(UltraScanInfo *USI, HostScanStats *hss,
|
|||
/* Go through the ProbeQueue of each host, identify any
|
||||
timed out probes, then try to retransmit them as appropriate */
|
||||
static void doAnyOutstandingRetransmits(UltraScanInfo *USI) {
|
||||
list<HostScanStats *>::iterator hostI;
|
||||
list<UltraProbe *>::iterator probeI;
|
||||
std::list<HostScanStats *>::iterator hostI;
|
||||
std::list<UltraProbe *>::iterator probeI;
|
||||
/* A cache of the last processed probe from each host, to avoid re-examining a
|
||||
bunch of probes to find the next one that needs to be retransmitted. */
|
||||
std::map<HostScanStats *, list<UltraProbe *>::iterator> probe_cache;
|
||||
std::map<HostScanStats *, std::list<UltraProbe *>::iterator> probe_cache;
|
||||
HostScanStats *host = NULL;
|
||||
UltraProbe *probe = NULL;
|
||||
int retrans = 0; /* Number of retransmissions during a loop */
|
||||
|
|
@ -3914,7 +3913,7 @@ static void doAnyOutstandingRetransmits(UltraScanInfo *USI) {
|
|||
debugging information */
|
||||
static void printAnyStats(UltraScanInfo *USI) {
|
||||
|
||||
list<HostScanStats *>::iterator hostI;
|
||||
std::list<HostScanStats *>::iterator hostI;
|
||||
HostScanStats *hss;
|
||||
struct ultra_timing_vals hosttm;
|
||||
|
||||
|
|
@ -3962,9 +3961,9 @@ static bool do_one_select_round(UltraScanInfo *USI, struct timeval *stime) {
|
|||
int timeleft;
|
||||
ConnectScanInfo *CSI = USI->gstats->CSI;
|
||||
int sd;
|
||||
list<HostScanStats *>::iterator hostI;
|
||||
std::list<HostScanStats *>::iterator hostI;
|
||||
HostScanStats *host;
|
||||
list<UltraProbe *>::iterator probeI, nextProbeI;
|
||||
std::list<UltraProbe *>::iterator probeI, nextProbeI;
|
||||
UltraProbe *probe = NULL;
|
||||
unsigned int listsz;
|
||||
unsigned int probenum;
|
||||
|
|
@ -4016,7 +4015,7 @@ static bool do_one_select_round(UltraScanInfo *USI, struct timeval *stime) {
|
|||
and find the relevant ones. Note the peculiar structure of the loop--we
|
||||
iterate through both incompleteHosts and completedHosts, because global
|
||||
timing pings are sent to hosts in completedHosts. */
|
||||
list<HostScanStats *>::iterator incompleteHostI, completedHostI;
|
||||
std::list<HostScanStats *>::iterator incompleteHostI, completedHostI;
|
||||
incompleteHostI = USI->incompleteHosts.begin();
|
||||
completedHostI = USI->completedHosts.begin();
|
||||
while ((incompleteHostI != USI->incompleteHosts.end()
|
||||
|
|
@ -4202,7 +4201,7 @@ static bool get_arp_result(UltraScanInfo *USI, struct timeval *stime) {
|
|||
bool timedout = false;
|
||||
struct sockaddr_in sin;
|
||||
HostScanStats *hss = NULL;
|
||||
list<UltraProbe *>::iterator probeI;
|
||||
std::list<UltraProbe *>::iterator probeI;
|
||||
int gotone = 0;
|
||||
|
||||
gettimeofday(&USI->now, NULL);
|
||||
|
|
@ -4273,7 +4272,7 @@ static bool get_ns_result(UltraScanInfo *USI, struct timeval *stime) {
|
|||
bool has_mac = false;
|
||||
struct sockaddr_in6 sin6;
|
||||
HostScanStats *hss = NULL;
|
||||
list<UltraProbe *>::iterator probeI;
|
||||
std::list<UltraProbe *>::iterator probeI;
|
||||
int gotone = 0;
|
||||
|
||||
gettimeofday(&USI->now, NULL);
|
||||
|
|
@ -4351,7 +4350,7 @@ static bool get_pcap_result(UltraScanInfo *USI, struct timeval *stime) {
|
|||
unsigned int bytes;
|
||||
long to_usec;
|
||||
HostScanStats *hss = NULL;
|
||||
list<UltraProbe *>::iterator probeI;
|
||||
std::list<UltraProbe *>::iterator probeI;
|
||||
UltraProbe *probe = NULL;
|
||||
int newstate = PORT_UNKNOWN;
|
||||
unsigned int probenum;
|
||||
|
|
@ -4960,7 +4959,7 @@ static int get_ping_pcap_result(UltraScanInfo *USI, struct timeval *stime) {
|
|||
} *ping;
|
||||
long to_usec;
|
||||
HostScanStats *hss = NULL;
|
||||
list<UltraProbe *>::iterator probeI;
|
||||
std::list<UltraProbe *>::iterator probeI;
|
||||
UltraProbe *probe = NULL;
|
||||
unsigned int trynum = 0;
|
||||
int newstate = HOST_UNKNOWN;
|
||||
|
|
@ -5455,10 +5454,10 @@ static void waitForResponses(UltraScanInfo *USI) {
|
|||
|
||||
/* Initiate libpcap or some other sniffer as appropriate to be able to catch
|
||||
responses */
|
||||
static void begin_sniffer(UltraScanInfo *USI, vector<Target *> &Targets) {
|
||||
string pcap_filter = "";
|
||||
static void begin_sniffer(UltraScanInfo *USI, std::vector<Target *> &Targets) {
|
||||
std::string pcap_filter = "";
|
||||
/* 20 IPv6 addresses is max (45 byte addy + 14 (" or src host ")) * 20 == 1180 */
|
||||
string dst_hosts = "";
|
||||
std::string dst_hosts = "";
|
||||
unsigned int len = 0;
|
||||
unsigned int targetno;
|
||||
bool doIndividual = Targets.size() <= 20; // Don't bother IP limits if scanning huge # of hosts
|
||||
|
|
@ -5557,8 +5556,8 @@ static void begin_sniffer(UltraScanInfo *USI, vector<Target *> &Targets) {
|
|||
/* Go through the data structures, making appropriate changes (such as expiring
|
||||
probes, noting when hosts are complete, etc. */
|
||||
static void processData(UltraScanInfo *USI) {
|
||||
list<HostScanStats *>::iterator hostI;
|
||||
list<UltraProbe *>::iterator probeI, nextProbeI;
|
||||
std::list<HostScanStats *>::iterator hostI;
|
||||
std::list<UltraProbe *>::iterator probeI, nextProbeI;
|
||||
HostScanStats *host = NULL;
|
||||
UltraProbe *probe = NULL;
|
||||
unsigned int maxtries = 0;
|
||||
|
|
@ -5691,9 +5690,9 @@ static void processData(UltraScanInfo *USI) {
|
|||
}
|
||||
|
||||
/* Start the timeout clocks of any targets that aren't already timedout */
|
||||
static void startTimeOutClocks(vector<Target *> &Targets) {
|
||||
static void startTimeOutClocks(std::vector<Target *> &Targets) {
|
||||
struct timeval tv;
|
||||
vector<Target *>::iterator hostI;
|
||||
std::vector<Target *>::iterator hostI;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
for (hostI = Targets.begin(); hostI != Targets.end(); hostI++) {
|
||||
|
|
@ -5708,7 +5707,7 @@ static void startTimeOutClocks(vector<Target *> &Targets) {
|
|||
changed timing information will be stored in it when the function returns. It
|
||||
exists so timing can be shared across invocations of this function. If to is
|
||||
NULL (its default value), a default timeout_info will be used. */
|
||||
void ultra_scan(vector<Target *> &Targets, struct scan_lists *ports,
|
||||
void ultra_scan(std::vector<Target *> &Targets, struct scan_lists *ports,
|
||||
stype scantype, struct timeout_info *to) {
|
||||
o.current_scantype = scantype;
|
||||
|
||||
|
|
|
|||
|
|
@ -130,10 +130,6 @@
|
|||
#include <algorithm>
|
||||
#include <list>
|
||||
|
||||
/* Workaround for lack of namespace std on HP-UX 11.00 */
|
||||
namespace std {};
|
||||
using namespace std;
|
||||
|
||||
extern NmapOps o;
|
||||
|
||||
// Details on a particular service (open port) we are trying to match
|
||||
|
|
@ -217,7 +213,7 @@ private:
|
|||
void addServiceChar(char c, int wrapat);
|
||||
// Like addServiceChar, but for a whole zero-terminated string
|
||||
void addServiceString(const char *s, int wrapat);
|
||||
vector<ServiceProbe *>::iterator current_probe;
|
||||
std::vector<ServiceProbe *>::iterator current_probe;
|
||||
u8 *currentresp;
|
||||
int currentresplen;
|
||||
char *servicefp;
|
||||
|
|
@ -228,11 +224,11 @@ private:
|
|||
// This holds the service information for a group of Targets being service scanned.
|
||||
class ServiceGroup {
|
||||
public:
|
||||
ServiceGroup(vector<Target *> &Targets, AllProbes *AP);
|
||||
ServiceGroup(std::vector<Target *> &Targets, AllProbes *AP);
|
||||
~ServiceGroup();
|
||||
list<ServiceNFO *> services_finished; // Services finished (discovered or not)
|
||||
list<ServiceNFO *> services_in_progress; // Services currently being probed
|
||||
list<ServiceNFO *> services_remaining; // Probes not started yet
|
||||
std::list<ServiceNFO *> services_finished; // Services finished (discovered or not)
|
||||
std::list<ServiceNFO *> services_in_progress; // Services currently being probed
|
||||
std::list<ServiceNFO *> services_remaining; // Probes not started yet
|
||||
unsigned int ideal_parallelism; // Max (and desired) number of probes out at once.
|
||||
ScanProgressMeter *SPM;
|
||||
int num_hosts_timedout; // # of hosts timed out during (or before) scan
|
||||
|
|
@ -1039,7 +1035,7 @@ ServiceProbe::ServiceProbe() {
|
|||
}
|
||||
|
||||
ServiceProbe::~ServiceProbe() {
|
||||
vector<ServiceProbeMatch *>::iterator vi;
|
||||
std::vector<ServiceProbeMatch *>::iterator vi;
|
||||
|
||||
if (probename) free(probename);
|
||||
if (probestring) free(probestring);
|
||||
|
|
@ -1106,7 +1102,7 @@ void ServiceProbe::setProbeString(const u8 *ps, int stringlen) {
|
|||
} else probestring = NULL;
|
||||
}
|
||||
|
||||
void ServiceProbe::setPortVector(vector<u16> *portv, const char *portstr,
|
||||
void ServiceProbe::setPortVector(std::vector<u16> *portv, const char *portstr,
|
||||
int lineno) {
|
||||
const char *current_range;
|
||||
char *endptr;
|
||||
|
|
@ -1184,7 +1180,7 @@ void ServiceProbe::setProbablePorts(enum service_tunnel_type tunnel,
|
|||
ports for this probe and tunnel type. Use a tunnel of
|
||||
SERVICE_TUNNEL_SSL or SERVICE_TUNNEL_NONE as appropriate */
|
||||
bool ServiceProbe::portIsProbable(enum service_tunnel_type tunnel, u16 portno) {
|
||||
vector<u16> *portv;
|
||||
std::vector<u16> *portv;
|
||||
|
||||
portv = (tunnel == SERVICE_TUNNEL_SSL)? &probablesslports : &probableports;
|
||||
|
||||
|
|
@ -1196,7 +1192,7 @@ bool ServiceProbe::portIsProbable(enum service_tunnel_type tunnel, u16 portno) {
|
|||
// Returns true if the passed in service name is among those that can
|
||||
// be detected by the matches in this probe;
|
||||
bool ServiceProbe::serviceIsPossible(const char *sname) {
|
||||
vector<const char *>::iterator vi;
|
||||
std::vector<const char *>::iterator vi;
|
||||
|
||||
for(vi = detectedServices.begin(); vi != detectedServices.end(); vi++) {
|
||||
if (strcmp(*vi, sname) == 0)
|
||||
|
|
@ -1387,7 +1383,7 @@ int AllProbes::check_excluded_port(unsigned short portno, int proto)
|
|||
// no version matched, that field will be NULL. This function may
|
||||
// return NULL if there are no match lines at all in this probe.
|
||||
const struct MatchDetails *ServiceProbe::testMatch(const u8 *buf, int buflen, int n = 0) {
|
||||
vector<ServiceProbeMatch *>::iterator vi;
|
||||
std::vector<ServiceProbeMatch *>::iterator vi;
|
||||
const struct MatchDetails *MD;
|
||||
|
||||
for(vi = matches.begin(); vi != matches.end(); vi++) {
|
||||
|
|
@ -1409,7 +1405,7 @@ AllProbes::AllProbes() {
|
|||
}
|
||||
|
||||
AllProbes::~AllProbes() {
|
||||
vector<ServiceProbe *>::iterator vi;
|
||||
std::vector<ServiceProbe *>::iterator vi;
|
||||
|
||||
// Delete all the ServiceProbe's inside the probes vector
|
||||
for(vi = probes.begin(); vi != probes.end(); vi++) {
|
||||
|
|
@ -1423,7 +1419,7 @@ AllProbes::~AllProbes() {
|
|||
// Tries to find the probe in this AllProbes class which have the
|
||||
// given name and protocol. It can return the NULL probe.
|
||||
ServiceProbe *AllProbes::getProbeByName(const char *name, int proto) {
|
||||
vector<ServiceProbe *>::iterator vi;
|
||||
std::vector<ServiceProbe *>::iterator vi;
|
||||
|
||||
if (proto == IPPROTO_TCP && nullProbe && strcmp(nullProbe->getName(), name) == 0)
|
||||
return nullProbe;
|
||||
|
|
@ -1480,7 +1476,7 @@ int AllProbes::isExcluded(unsigned short port, int proto) {
|
|||
// back to probes later in the file. This function also free()s all the
|
||||
// fallbackStrs.
|
||||
void AllProbes::compileFallbacks() {
|
||||
vector<ServiceProbe *>::iterator curr;
|
||||
std::vector<ServiceProbe *>::iterator curr;
|
||||
char *tp;
|
||||
int i;
|
||||
|
||||
|
|
@ -1832,7 +1828,7 @@ u8 *ServiceNFO::getcurrentproberesponse(int *respstrlen) {
|
|||
}
|
||||
|
||||
|
||||
ServiceGroup::ServiceGroup(vector<Target *> &Targets, AllProbes *AP) {
|
||||
ServiceGroup::ServiceGroup(std::vector<Target *> &Targets, AllProbes *AP) {
|
||||
unsigned int targetno;
|
||||
ServiceNFO *svc;
|
||||
Port *nxtport;
|
||||
|
|
@ -1887,7 +1883,7 @@ ServiceGroup::ServiceGroup(vector<Target *> &Targets, AllProbes *AP) {
|
|||
}
|
||||
|
||||
ServiceGroup::~ServiceGroup() {
|
||||
list<ServiceNFO *>::iterator i;
|
||||
std::list<ServiceNFO *>::iterator i;
|
||||
|
||||
for(i = services_finished.begin(); i != services_finished.end(); i++)
|
||||
delete *i;
|
||||
|
|
@ -2101,7 +2097,7 @@ static void considerPrintingStats(ServiceGroup *SG) {
|
|||
/* Check if target is done (no more probes remaining for it in service group),
|
||||
and responds appropriately if so */
|
||||
static void handleHostIfDone(ServiceGroup *SG, Target *target) {
|
||||
list<ServiceNFO *>::iterator svcI;
|
||||
std::list<ServiceNFO *>::iterator svcI;
|
||||
bool found = false;
|
||||
|
||||
for(svcI = SG->services_in_progress.begin();
|
||||
|
|
@ -2132,7 +2128,7 @@ static void handleHostIfDone(ServiceGroup *SG, Target *target) {
|
|||
// set it to the given probe_state pass NULL for nsi if you don't want
|
||||
// it to be deleted (for example, if you already have done so).
|
||||
static void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi) {
|
||||
list<ServiceNFO *>::iterator member;
|
||||
std::list<ServiceNFO *>::iterator member;
|
||||
Target *target = svc->target;
|
||||
|
||||
svc->probe_state = probe_state;
|
||||
|
|
@ -2544,11 +2540,11 @@ static int shouldWePrintFingerprint(ServiceNFO *svc) {
|
|||
// Nmap to output later.
|
||||
|
||||
static void processResults(ServiceGroup *SG) {
|
||||
list<ServiceNFO *>::iterator svc;
|
||||
std::list<ServiceNFO *>::iterator svc;
|
||||
|
||||
for(svc = SG->services_finished.begin(); svc != SG->services_finished.end(); svc++) {
|
||||
if ((*svc)->probe_state != PROBESTATE_FINISHED_NOMATCH) {
|
||||
vector<const char *> cpe;
|
||||
std::vector<const char *> cpe;
|
||||
|
||||
if (*(*svc)->cpe_a_matched)
|
||||
cpe.push_back((*svc)->cpe_a_matched);
|
||||
|
|
@ -2583,7 +2579,7 @@ list<ServiceNFO *>::iterator svc;
|
|||
that this is called before any probes have been launched (so they
|
||||
are all in services_remaining */
|
||||
static void startTimeOutClocks(ServiceGroup *SG) {
|
||||
list<ServiceNFO *>::iterator svcI;
|
||||
std::list<ServiceNFO *>::iterator svcI;
|
||||
Target *target = NULL;
|
||||
struct timeval tv;
|
||||
|
||||
|
|
@ -2602,7 +2598,7 @@ static void startTimeOutClocks(ServiceGroup *SG) {
|
|||
// pairs that are excluded. We use AP->isExcluded() to determine which ports
|
||||
// are excluded.
|
||||
static void remove_excluded_ports(AllProbes *AP, ServiceGroup *SG) {
|
||||
list<ServiceNFO *>::iterator i, nxt;
|
||||
std::list<ServiceNFO *>::iterator i, nxt;
|
||||
ServiceNFO *svc;
|
||||
|
||||
for(i = SG->services_remaining.begin(); i != SG->services_remaining.end(); i=nxt) {
|
||||
|
|
@ -2631,7 +2627,7 @@ static void remove_excluded_ports(AllProbes *AP, ServiceGroup *SG) {
|
|||
|
||||
/* Execute a service fingerprinting scan against all open ports of the
|
||||
Targets specified. */
|
||||
int service_scan(vector<Target *> &Targets) {
|
||||
int service_scan(std::vector<Target *> &Targets) {
|
||||
// int service_scan(Target *targets[], int num_targets)
|
||||
AllProbes *AP;
|
||||
ServiceGroup *SG;
|
||||
|
|
|
|||
|
|
@ -106,15 +106,15 @@
|
|||
#include "nmap_tty.h"
|
||||
#include "utils.h"
|
||||
#include "xml.h"
|
||||
using namespace std;
|
||||
|
||||
extern NmapOps o;
|
||||
|
||||
/* Conducts an ARP ping sweep of the given hosts to determine which ones
|
||||
are up on a local ethernet network */
|
||||
static void arpping(Target *hostbatch[], int num_hosts) {
|
||||
/* First I change hostbatch into a vector<Target *>, which is what ultra_scan
|
||||
/* First I change hostbatch into a std::vector<Target *>, which is what ultra_scan
|
||||
takes. I remove hosts that cannot be ARP scanned (such as localhost) */
|
||||
vector<Target *> targets;
|
||||
std::vector<Target *> targets;
|
||||
int targetno;
|
||||
targets.reserve(num_hosts);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue