mirror of
https://github.com/nmap/nmap.git
synced 2026-10-20 19:01:56 +00:00
o Nmap now saves the target name (if any) specified on the command
line, since this can differ from the reverse DNS results. It can be particularly important when doing HTTP tests against virtual hosts. The data can be accessed from target->HostName() from Nmap proper and host.targetname from NSE scripts. The NSE HTTP library now uses this for the Host header. Thanks to Sven Klemm for adding this useful feature.
This commit is contained in:
parent
c22505bf5a
commit
61b976a45c
9 changed files with 63 additions and 3 deletions
15
Target.cc
15
Target.cc
|
|
@ -119,6 +119,7 @@ Target::Target() {
|
|||
|
||||
void Target::Initialize() {
|
||||
hostname = NULL;
|
||||
targetname = NULL;
|
||||
memset(&seq, 0, sizeof(seq));
|
||||
distance = -1;
|
||||
FPR1 = NULL;
|
||||
|
|
@ -169,6 +170,9 @@ void Target::FreeInternal() {
|
|||
if (hostname)
|
||||
free(hostname);
|
||||
|
||||
if (targetname)
|
||||
free(targetname);
|
||||
|
||||
if (nameIPBuf) {
|
||||
free(nameIPBuf);
|
||||
nameIPBuf = NULL;
|
||||
|
|
@ -221,6 +225,7 @@ void Target::setTargetSockAddr(struct sockaddr_storage *ss, size_t ss_len) {
|
|||
/* We had an old target sock, so we better blow away the hostname as
|
||||
this one may be new. */
|
||||
setHostName(NULL);
|
||||
setTargetName(NULL);
|
||||
}
|
||||
memcpy(&targetsock, ss, ss_len);
|
||||
targetsocklen = ss_len;
|
||||
|
|
@ -308,6 +313,16 @@ void Target::setHostName(char *name) {
|
|||
}
|
||||
}
|
||||
|
||||
void Target::setTargetName(char *name) {
|
||||
if (targetname) {
|
||||
free(targetname);
|
||||
targetname = NULL;
|
||||
}
|
||||
if (name) {
|
||||
targetname = strdup(name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Generates a printable string consisting of the host's IP
|
||||
address and hostname (if available). Eg "www.insecure.org
|
||||
(64.71.184.53)" or "fe80::202:e3ff:fe14:1102". The name is
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue