1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-10 17:59:04 +00:00

Some patches from Marek

This commit is contained in:
fyodor
2006-07-04 08:00:11 +00:00
parent 30190d664a
commit d3055b26bf
9 changed files with 18 additions and 141 deletions

View File

@@ -9,6 +9,8 @@ o Added IP options support. This allows you to specify loose/strict
further details on using these advanced options. Thanks to Marek Majkowski
(majek(a)forest.one.pl) for this patch.
o Applied several code cleanup patches from Marek Majkowski.
o Fixed a bug related to bogus completion time estimates when you
request an estimate (through runtime interaction) right when Nmap is
starting.a subsystem (such as a port scan or version detection).

View File

@@ -16,6 +16,7 @@ export NSOCKDIR=@NSOCKDIR@
CC = @CC@
CXX = @CXX@
CCOPT =
DBGFLAGS =
LIBPCAPDIR = @libpcapdir@
LIBPCREDIR = @LIBPCREDIR@
export LIBDNETDIR = @LIBDNETDIR@
@@ -23,12 +24,12 @@ DEFS = @DEFS@ -DNMAP_VERSION=\"$(NMAP_VERSION)\" -DNMAP_NAME=\"$(NMAP_NAME)\" -D
# For mtrace debugging -- see MTRACE define in main.cc for instructions
# Should only be enabled during debugging and not in any real release.
# DEFS += -DMTRACE=1
CXXFLAGS = @CXXFLAGS@ $(CCOPT) $(DEFS)
CXXFLAGS = @CXXFLAGS@ $(DBGFLAGS) $(CCOPT) $(DEFS)
CPPFLAGS = @CPPFLAGS@
# CFLAGS = $(CXXFLAGS)
# CFLAGS = $(DEFS) $(INCLS)
STATIC =
LDFLAGS = @LDFLAGS@ $(STATIC)
LDFLAGS = @LDFLAGS@ $(DBGFLAGS) $(STATIC)
LIBS = @LIBNBASE_LIBS@ @LIBNSOCK_LIBS@ @LIBPCRE_LIBS@ @LIBPCAP_LIBS@ @OPENSSL_LIBS@ @LIBDNET_LIBS@ @LIBS@
# LIBS = -lefence @LIBS@
# LIBS = -lrmalloc @LIBS@
@@ -37,6 +38,7 @@ INSTALL = $(SHTOOL) install
MAKEDEPEND = @MAKEDEPEND@
export RPMTDIR=$(HOME)/rpm
# DESTDIR is used by some package maintainers to install Nmap under
# its usual directory structure into a different tree. See the
# CHANGELOG for more info.
@@ -99,6 +101,9 @@ nmapfe/nmapfe:
static:
$(MAKE) STATIC=-static
debug:
$(MAKE) DBGFLAGS="-O0 -g -pg -ftest-coverage -fprofile-arcs"
# Make the Nmap tarball
distro:
cd scripts && $(MAKE) distro
@@ -132,6 +137,8 @@ dnet_dist_clean:
-cd $(LIBDNETDIR) && $(MAKE) distclean
nmapfe_dist_clean:
-cd nmapfe && $(MAKE) distclean
debugclean:
rm -f *.gcov *.gcda *.gcno gmon.out
distclean: my_clean my_distclean @PCAP_DIST_CLEAN@ @PCRE_DIST_CLEAN@ @DNET_DIST_CLEAN@ nmapfe_dist_clean

View File

@@ -252,6 +252,8 @@ void NmapOps::Initialize() {
dns_servers = NULL;
noninteractive = false;
current_scantype = STYPE_UNKNOWN;
release_memory = false;
}
bool NmapOps::TCPScan() {
@@ -431,7 +433,7 @@ void NmapOps::ValidateOptions() {
}
if (max_parallelism && min_parallelism && (min_parallelism > max_parallelism)) {
fatal("--min-parallelism must be less than or equal to --max-parallelism");
fatal("--min-parallelism=%i must be less than or equal to --max-parallelism=%i",min_parallelism,max_parallelism);
}
if (af() == AF_INET6 && (numdecoys|osscan|bouncescan|fragscan|ackscan|finscan|idlescan|ipprotscan|maimonscan|nullscan|rpcscan|synscan|udpscan|windowscan|xmasscan)) {

View File

@@ -186,7 +186,7 @@ void NmapOutputTable::addItemFormatted(unsigned int row,
res = vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
if (res < 0 || res > sizeof(buf))
if (res > sizeof(buf))
fatal("NmapOutputTable only supports adding up to 4096 to a cell via addItemFormatString.");
addItem(row, column, true, buf, res);

View File

@@ -1075,6 +1075,8 @@ int nmap_main(int argc, char *argv[]) {
if (o.scan_delay > o.maxTCPScanDelay()) o.setMaxTCPScanDelay(o.scan_delay);
if (o.scan_delay > o.maxUDPScanDelay()) o.setMaxUDPScanDelay(o.scan_delay);
o.max_parallelism = 1;
if(pre_max_parallelism != -1)
fatal("You can't use --max-parallelism with --scan-delay.");
}
if (pre_max_scan_delay != -1) {
o.setMaxTCPScanDelay(pre_max_scan_delay);

View File

@@ -1719,6 +1719,7 @@ static void parse_classline(FingerPrint *FP, char *thisline, int lineno,
int *classno) {
char *p, *q;
// Wtf????
fflush(stdout);
if (!thisline || strncmp(thisline, "Class ", 6) == 1) {

View File

@@ -661,8 +661,6 @@ UltraProbe::~UltraProbe() {
void UltraProbe::setARP(u8 *arppkt, u32 arplen) {
type = UP_ARP;
/* probes.AP = new ArpProbe;
probes.AP->storePacket(arppkt, arplen); */
mypspec.type = PS_ARP;
return;
}

View File

@@ -2927,84 +2927,3 @@ if (echots) *echots = 0;
return 0;
}
IPProbe::IPProbe() {
packetbuflen = 0;
packetbuf = NULL;
Reset();
}
void IPProbe::Reset() {
if (packetbuf)
free(packetbuf);
packetbuflen = 0;
packetbuf = NULL;
ipv4 = NULL;
icmp = NULL;
tcp = NULL;
udp = NULL;
}
IPProbe::~IPProbe() {
if (packetbuf) {
free(packetbuf);
packetbuf = NULL;
packetbuflen = 0;
}
Reset();
}
int IPProbe::storePacket(u8 *ippacket, u32 len) {
assert(packetbuf == NULL);
af = AF_INET;
packetbuf = (u8 *) safe_malloc(len);
memcpy(packetbuf, ippacket, len);
packetbuflen = len;
ipv4 = (struct ip *) packetbuf;
assert(ipv4->ip_v == 4);
assert(len >= 20);
assert(len == (u32) ntohs(ipv4->ip_len));
if (ipv4->ip_p == IPPROTO_TCP) {
if (len >= (unsigned) ipv4->ip_hl * 4 + 20)
tcp = (struct tcphdr *) ((u8 *) ipv4 + ipv4->ip_hl * 4);
} else if (ipv4->ip_p == IPPROTO_ICMP) {
if (len >= (unsigned) ipv4->ip_hl * 4 + 8)
icmp = (struct icmp *) ((u8 *) ipv4 + ipv4->ip_hl * 4);
} else if (ipv4->ip_p == IPPROTO_UDP) {
if (len >= (unsigned) ipv4->ip_hl * 4 + 8)
udp = (udphdr_bsd *) ((u8 *) ipv4 + ipv4->ip_hl * 4);
}
return 0;
}
ArpProbe::ArpProbe() {
packetbuflen = 0;
packetbuf = NULL;
Reset();
}
void ArpProbe::Reset() {
if (packetbuf)
free(packetbuf);
packetbuflen = 0;
packetbuf = NULL;
ipquery = NULL;
}
ArpProbe::~ArpProbe() {
if (packetbuf) {
free(packetbuf);
packetbuf = NULL;
packetbuflen = 0;
}
Reset();
}
int ArpProbe::storePacket(u8 *arppacket, u32 len) {
assert(packetbuf == NULL);
assert(len == 42);
packetbuf = (u8 *) safe_malloc(len);
memcpy(packetbuf, arppacket, len);
packetbuflen = len;
ipquery = (struct in_addr *) ((u8 *)arppacket + 38);
return 0;
}

54
tcpip.h
View File

@@ -240,11 +240,6 @@ typedef enum { devt_ethernet, devt_loopback, devt_p2p, devt_other } devtype;
#include "nmap.h"
#include "global_structures.h"
#ifndef DEBUGGING
#define DEBUGGING 0
#endif
#ifndef TCPIP_DEBUGGING
#define TCPIP_DEBUGGING 0
#endif
@@ -476,55 +471,6 @@ struct icmp
};
#endif /* HAVE_STRUCT_ICMP */
/* Represents a single probe packet, such as a SYN to port 80 or an
ICMP netmask request packet. Values are still in network byte order. */
class IPProbe {
public:
IPProbe();
~IPProbe();
/* Takes an IP packet and stores _a copy_ of it, in this Probe,
adjusting proper header pointers and such */
int storePacket(u8 *ippacket, u32 len);
u32 packetbuflen; /* Length of the whole packet */
u8 *packetbuf; /* The packet itself */
struct ip *ipv4; /* IP header of packet */
struct icmp *icmp; /* icmp, tcp, and udp are NULL if the packet has no such header */
struct tcphdr *tcp;
udphdr_bsd *udp;
u8 af; /* AF_INET or AF_INET6 */
/* Resets everything to NULL. Frees packetbuf if it is filled. You
can reuse a Probe by calling Reset() and then a new
storePacket(). */
void Reset();
private:
};
/* Handles an *IPv4* Arp probe */
class ArpProbe {
public:
ArpProbe();
~ArpProbe();
/* Takes an ARP packet and stores _a copy_ of it, in this Probe,
adjusting proper header pointers and such. Then length better
equal 42! */
int storePacket(u8 *arppacket, u32 len);
u32 packetbuflen; /* Length of the whole packet */
u8 *packetbuf; /* The packet itself */
struct in_addr *ipquery; /* IP address this ARP seeks */
/* Resets everything to NULL. Frees packetbuf if it is filled. You
can reuse a Probe by calling Reset() and then a new
storePacket(). */
void Reset();
private:
};
/* This ideally should be a port that isn't in use for any protocol on our machine or on the target */
#define MAGIC_PORT 49724
#define TVAL2LONG(X) X.tv_sec * 1e6 + X.tv_usec
#define SA struct sockaddr
/* Prototypes */
/* Converts an IP address given in a sockaddr_storage to an IPv4 or