mirror of
https://github.com/nmap/nmap.git
synced 2025-12-08 13:41:29 +00:00
Remove the unused Port::owner member.
This commit is contained in:
@@ -960,10 +960,10 @@ static int idle_treescan(struct idle_proxy_info *proxy, Target *target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (firstHalfSz == 1 && flatcount1 == 1)
|
if (firstHalfSz == 1 && flatcount1 == 1)
|
||||||
target->ports.addPort(ports[0], IPPROTO_TCP, NULL, PORT_OPEN);
|
target->ports.addPort(ports[0], IPPROTO_TCP, PORT_OPEN);
|
||||||
|
|
||||||
if ((secondHalfSz == 1) && flatcount2 == 1)
|
if ((secondHalfSz == 1) && flatcount2 == 1)
|
||||||
target->ports.addPort(ports[firstHalfSz], IPPROTO_TCP, NULL, PORT_OPEN);
|
target->ports.addPort(ports[firstHalfSz], IPPROTO_TCP, PORT_OPEN);
|
||||||
return totalfound;
|
return totalfound;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1044,8 +1044,7 @@ void idle_scan(Target *target, u16 *portarray, int numports,
|
|||||||
but not determined to be open, and add them in the "closed" state */
|
but not determined to be open, and add them in the "closed" state */
|
||||||
for(portidx = 0; portidx < numports; portidx++) {
|
for(portidx = 0; portidx < numports; portidx++) {
|
||||||
if (target->ports.getPortEntry(portarray[portidx], IPPROTO_TCP) == NULL) {
|
if (target->ports.getPortEntry(portarray[portidx], IPPROTO_TCP) == NULL) {
|
||||||
target->ports.addPort(portarray[portidx], IPPROTO_TCP, NULL,
|
target->ports.addPort(portarray[portidx], IPPROTO_TCP, PORT_CLOSEDFILTERED);
|
||||||
PORT_CLOSEDFILTERED);
|
|
||||||
target->ports.setStateReason(portarray[portidx], IPPROTO_TCP, ER_NOIPIDCHANGE, 0, 0);
|
target->ports.setStateReason(portarray[portidx], IPPROTO_TCP, ER_NOIPIDCHANGE, 0, 0);
|
||||||
} else
|
} else
|
||||||
target->ports.setStateReason(portarray[portidx], IPPROTO_TCP, ER_IPIDCHANGE, 0, 0);
|
target->ports.setStateReason(portarray[portidx], IPPROTO_TCP, ER_IPIDCHANGE, 0, 0);
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ static int rpc_are_we_done(char *msg, int msg_len, Target *target,
|
|||||||
if (rsi->rpc_current_port->state == PORT_OPENFILTERED) {
|
if (rsi->rpc_current_port->state == PORT_OPENFILTERED) {
|
||||||
/* Received a packet, so this port is actually open */
|
/* Received a packet, so this port is actually open */
|
||||||
target->ports.addPort(rsi->rpc_current_port->portno,
|
target->ports.addPort(rsi->rpc_current_port->portno,
|
||||||
rsi->rpc_current_port->proto, NULL, PORT_OPEN);
|
rsi->rpc_current_port->proto, PORT_OPEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
rpc_pack = (struct rpc_hdr_rcv *) msg;
|
rpc_pack = (struct rpc_hdr_rcv *) msg;
|
||||||
|
|||||||
@@ -486,13 +486,13 @@ static int l_set_port_state (lua_State *L)
|
|||||||
case PORT_OPEN:
|
case PORT_OPEN:
|
||||||
if (port->state == PORT_OPEN)
|
if (port->state == PORT_OPEN)
|
||||||
return 0;
|
return 0;
|
||||||
target->ports.addPort(port->portno, port->proto, NULL, PORT_OPEN);
|
target->ports.addPort(port->portno, port->proto, PORT_OPEN);
|
||||||
port->state = PORT_OPEN;
|
port->state = PORT_OPEN;
|
||||||
break;
|
break;
|
||||||
case PORT_CLOSED:
|
case PORT_CLOSED:
|
||||||
if (port->state == PORT_CLOSED)
|
if (port->state == PORT_CLOSED)
|
||||||
return 0;
|
return 0;
|
||||||
target->ports.addPort(port->portno, port->proto, NULL, PORT_CLOSED);
|
target->ports.addPort(port->portno, port->proto, PORT_CLOSED);
|
||||||
port->state = PORT_CLOSED;
|
port->state = PORT_CLOSED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
21
output.cc
21
output.cc
@@ -540,7 +540,6 @@ void printportoutput(Target * currenths, PortList * plist) {
|
|||||||
char rpcmachineinfo[64];
|
char rpcmachineinfo[64];
|
||||||
char portinfo[64];
|
char portinfo[64];
|
||||||
char grepvers[256];
|
char grepvers[256];
|
||||||
char grepown[64];
|
|
||||||
char *p;
|
char *p;
|
||||||
char *xmlBuf = NULL;
|
char *xmlBuf = NULL;
|
||||||
const char *state;
|
const char *state;
|
||||||
@@ -801,23 +800,13 @@ void printportoutput(Target * currenths, PortList * plist) {
|
|||||||
// such as \/ and \\ . // But that makes it harder to pick
|
// such as \/ and \\ . // But that makes it harder to pick
|
||||||
// out fields with awk, cut, and such. So I'm gonna use the
|
// out fields with awk, cut, and such. So I'm gonna use the
|
||||||
// ugly hat (fitting to grepable output) or replacing the '/'
|
// ugly hat (fitting to grepable output) or replacing the '/'
|
||||||
// character with '|' in the version and owner fields.
|
// character with '|' in the version field.
|
||||||
Strncpy(grepvers, sd.fullversion, sizeof(grepvers) / sizeof(*grepvers));
|
Strncpy(grepvers, sd.fullversion, sizeof(grepvers) / sizeof(*grepvers));
|
||||||
p = grepvers;
|
p = grepvers;
|
||||||
while ((p = strchr(p, '/'))) {
|
while ((p = strchr(p, '/'))) {
|
||||||
*p = '|';
|
*p = '|';
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
if (!current->owner)
|
|
||||||
*grepown = '\0';
|
|
||||||
else {
|
|
||||||
Strncpy(grepown, current->owner, sizeof(grepown) / sizeof(*grepown));
|
|
||||||
p = grepown;
|
|
||||||
while ((p = strchr(p, '/'))) {
|
|
||||||
*p = '|';
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!sd.name)
|
if (!sd.name)
|
||||||
serviceinfo[0] = '\0';
|
serviceinfo[0] = '\0';
|
||||||
else {
|
else {
|
||||||
@@ -827,9 +816,8 @@ void printportoutput(Target * currenths, PortList * plist) {
|
|||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log_write(LOG_MACHINE, "%d/%s/%s/%s/%s/%s/%s/", current->portno,
|
log_write(LOG_MACHINE, "%d/%s/%s//%s/%s/%s/", current->portno,
|
||||||
state, protocol, grepown, serviceinfo, rpcmachineinfo,
|
state, protocol, serviceinfo, rpcmachineinfo, grepvers);
|
||||||
grepvers);
|
|
||||||
|
|
||||||
log_write(LOG_XML, "<port protocol=\"%s\" portid=\"%d\">",
|
log_write(LOG_XML, "<port protocol=\"%s\" portid=\"%d\">",
|
||||||
protocol, current->portno);
|
protocol, current->portno);
|
||||||
@@ -839,9 +827,6 @@ void printportoutput(Target * currenths, PortList * plist) {
|
|||||||
if (current->reason.ip_addr.s_addr)
|
if (current->reason.ip_addr.s_addr)
|
||||||
log_write(LOG_XML, " reason_ip=\"%s\"", inet_ntoa(current->reason.ip_addr));
|
log_write(LOG_XML, " reason_ip=\"%s\"", inet_ntoa(current->reason.ip_addr));
|
||||||
log_write(LOG_XML, "/>");
|
log_write(LOG_XML, "/>");
|
||||||
if (current->owner && *current->owner) {
|
|
||||||
log_write(LOG_XML, "<owner name=\"%s\" />", current->owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sd.name || sd.service_fp) {
|
if (sd.name || sd.service_fp) {
|
||||||
xmlBuf = getServiceXMLBuf(&sd);
|
xmlBuf = getServiceXMLBuf(&sd);
|
||||||
|
|||||||
22
portlist.cc
22
portlist.cc
@@ -109,7 +109,6 @@ extern NmapOps o; /* option structure */
|
|||||||
|
|
||||||
Port::Port() {
|
Port::Port() {
|
||||||
portno = proto = 0;
|
portno = proto = 0;
|
||||||
owner = NULL;
|
|
||||||
rpc_status = RPC_STATUS_UNTESTED;
|
rpc_status = RPC_STATUS_UNTESTED;
|
||||||
rpc_program = rpc_lowver = rpc_highver = 0;
|
rpc_program = rpc_lowver = rpc_highver = 0;
|
||||||
state = 0;
|
state = 0;
|
||||||
@@ -123,8 +122,6 @@ Port::Port() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Port::~Port() {
|
Port::~Port() {
|
||||||
if (owner)
|
|
||||||
free(owner);
|
|
||||||
if (serviceprobe_product)
|
if (serviceprobe_product)
|
||||||
free(serviceprobe_product);
|
free(serviceprobe_product);
|
||||||
if (serviceprobe_version)
|
if (serviceprobe_version)
|
||||||
@@ -426,21 +423,16 @@ PortList::~PortList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PortList::addPort(u16 portno, u8 protocol, char *owner, int state) {
|
int PortList::addPort(u16 portno, u8 protocol, int state) {
|
||||||
Port *current;
|
Port *current;
|
||||||
char msg[128];
|
|
||||||
int proto = INPROTO2PORTLISTPROTO(protocol);
|
int proto = INPROTO2PORTLISTPROTO(protocol);
|
||||||
|
|
||||||
assert(state < PORT_HIGHEST_STATE);
|
assert(state < PORT_HIGHEST_STATE);
|
||||||
|
|
||||||
if ((state == PORT_OPEN && o.verbose) || (o.debugging > 1)) {
|
if ((state == PORT_OPEN && o.verbose) || (o.debugging > 1)) {
|
||||||
if (owner && *owner) {
|
log_write(LOG_STDOUT, "Discovered %s port %hu/%s%s\n",
|
||||||
Snprintf(msg, sizeof(msg), " (owner: %s)", owner);
|
|
||||||
} else msg[0] = '\0';
|
|
||||||
|
|
||||||
log_write(LOG_STDOUT, "Discovered %s port %hu/%s%s%s\n",
|
|
||||||
statenum2str(state), portno,
|
statenum2str(state), portno,
|
||||||
proto2ascii(protocol), msg, idstr? idstr : "");
|
proto2ascii(protocol), idstr? idstr : "");
|
||||||
log_flush(LOG_STDOUT);
|
log_flush(LOG_STDOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,7 +449,7 @@ int PortList::addPort(u16 portno, u8 protocol, char *owner, int state) {
|
|||||||
if (current) {
|
if (current) {
|
||||||
/* We must discount our statistics from the old values. Also warn
|
/* We must discount our statistics from the old values. Also warn
|
||||||
if a complete duplicate */
|
if a complete duplicate */
|
||||||
if (o.debugging && current->state == state && (!owner || !*owner)) {
|
if (o.debugging && current->state == state) {
|
||||||
error("Duplicate port (%hu/%s)", portno, proto2ascii(protocol));
|
error("Duplicate port (%hu/%s)", portno, proto2ascii(protocol));
|
||||||
}
|
}
|
||||||
state_counts_proto[proto][current->state]--;
|
state_counts_proto[proto][current->state]--;
|
||||||
@@ -473,12 +465,6 @@ int PortList::addPort(u16 portno, u8 protocol, char *owner, int state) {
|
|||||||
current->state = state;
|
current->state = state;
|
||||||
state_counts_proto[proto][state]++;
|
state_counts_proto[proto][state]++;
|
||||||
|
|
||||||
if (owner && *owner) {
|
|
||||||
if (current->owner)
|
|
||||||
free(current->owner);
|
|
||||||
current->owner = strdup(owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(state == PORT_FILTERED || state == PORT_OPENFILTERED)
|
if(state == PORT_FILTERED || state == PORT_OPENFILTERED)
|
||||||
setStateReason(portno, protocol, ER_NORESPONSE, 0, 0);
|
setStateReason(portno, protocol, ER_NORESPONSE, 0, 0);
|
||||||
return 0; /*success */
|
return 0; /*success */
|
||||||
|
|||||||
@@ -208,7 +208,6 @@ class Port {
|
|||||||
|
|
||||||
u16 portno;
|
u16 portno;
|
||||||
u8 proto;
|
u8 proto;
|
||||||
char *owner;
|
|
||||||
int state;
|
int state;
|
||||||
state_reason_t reason;
|
state_reason_t reason;
|
||||||
|
|
||||||
@@ -264,7 +263,7 @@ class PortList {
|
|||||||
|
|
||||||
/* Add a new port to this list. If the state has changed, it is
|
/* Add a new port to this list. If the state has changed, it is
|
||||||
OK to call this function to effect the change */
|
OK to call this function to effect the change */
|
||||||
int addPort(u16 portno, u8 protocol, char *owner, int state);
|
int addPort(u16 portno, u8 protocol, int state);
|
||||||
int removePort(u16 portno, u8 protocol);
|
int removePort(u16 portno, u8 protocol);
|
||||||
/* Saves an identification string for the target containing these
|
/* Saves an identification string for the target containing these
|
||||||
ports (an IP addrss might be a good example, but set what you
|
ports (an IP addrss might be a good example, but set what you
|
||||||
|
|||||||
@@ -2631,25 +2631,25 @@ static bool ultrascan_port_pspec_update(UltraScanInfo *USI,
|
|||||||
in a SYN scan, but not neccessarily for UDP scan */
|
in a SYN scan, but not neccessarily for UDP scan */
|
||||||
case PORT_TESTING:
|
case PORT_TESTING:
|
||||||
/* Brand new port -- add it to the list */
|
/* Brand new port -- add it to the list */
|
||||||
hss->target->ports.addPort(portno, proto, NULL, newstate);
|
hss->target->ports.addPort(portno, proto, newstate);
|
||||||
break;
|
break;
|
||||||
case PORT_OPEN:
|
case PORT_OPEN:
|
||||||
if (newstate != PORT_OPEN) {
|
if (newstate != PORT_OPEN) {
|
||||||
if (noresp_open_scan) {
|
if (noresp_open_scan) {
|
||||||
hss->target->ports.addPort(portno, proto, NULL, newstate);
|
hss->target->ports.addPort(portno, proto, newstate);
|
||||||
} /* Otherwise The old open takes precendence */
|
} /* Otherwise The old open takes precendence */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PORT_CLOSED:
|
case PORT_CLOSED:
|
||||||
if (newstate != PORT_CLOSED) {
|
if (newstate != PORT_CLOSED) {
|
||||||
if (!noresp_open_scan && newstate != PORT_FILTERED)
|
if (!noresp_open_scan && newstate != PORT_FILTERED)
|
||||||
hss->target->ports.addPort(portno, proto, NULL, newstate);
|
hss->target->ports.addPort(portno, proto, newstate);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PORT_FILTERED:
|
case PORT_FILTERED:
|
||||||
if (newstate != PORT_FILTERED) {
|
if (newstate != PORT_FILTERED) {
|
||||||
if (!noresp_open_scan || newstate != PORT_OPEN)
|
if (!noresp_open_scan || newstate != PORT_OPEN)
|
||||||
hss->target->ports.addPort(portno, proto, NULL, newstate);
|
hss->target->ports.addPort(portno, proto, newstate);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PORT_UNFILTERED:
|
case PORT_UNFILTERED:
|
||||||
@@ -2658,11 +2658,11 @@ static bool ultrascan_port_pspec_update(UltraScanInfo *USI,
|
|||||||
case. I'll change it if the new state is open or closed,
|
case. I'll change it if the new state is open or closed,
|
||||||
though I don't expect that to ever happen */
|
though I don't expect that to ever happen */
|
||||||
if (newstate == PORT_OPEN || newstate == PORT_CLOSED)
|
if (newstate == PORT_OPEN || newstate == PORT_CLOSED)
|
||||||
hss->target->ports.addPort(portno, proto, NULL, newstate);
|
hss->target->ports.addPort(portno, proto, newstate);
|
||||||
break;
|
break;
|
||||||
case PORT_OPENFILTERED:
|
case PORT_OPENFILTERED:
|
||||||
if (newstate != PORT_OPENFILTERED) {
|
if (newstate != PORT_OPENFILTERED) {
|
||||||
hss->target->ports.addPort(portno, proto, NULL, newstate);
|
hss->target->ports.addPort(portno, proto, newstate);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -5258,10 +5258,8 @@ void bounce_scan(Target *target, u16 *portarray, int numports,
|
|||||||
perror("recv problem from FTP bounce server");
|
perror("recv problem from FTP bounce server");
|
||||||
} else if (res == 0) {
|
} else if (res == 0) {
|
||||||
if (timedout)
|
if (timedout)
|
||||||
target->ports.addPort(portarray[i], IPPROTO_TCP, NULL,
|
target->ports.addPort(portarray[i], IPPROTO_TCP, PORT_FILTERED);
|
||||||
PORT_FILTERED);
|
else target->ports.addPort(portarray[i], IPPROTO_TCP, PORT_CLOSED);
|
||||||
else target->ports.addPort(portarray[i], IPPROTO_TCP, NULL,
|
|
||||||
PORT_CLOSED);
|
|
||||||
} else {
|
} else {
|
||||||
recvbuf[res] = '\0';
|
recvbuf[res] = '\0';
|
||||||
if (o.debugging) log_write(LOG_STDOUT, "result of LIST: %s", recvbuf);
|
if (o.debugging) log_write(LOG_STDOUT, "result of LIST: %s", recvbuf);
|
||||||
@@ -5272,7 +5270,7 @@ void bounce_scan(Target *target, u16 *portarray, int numports,
|
|||||||
res = recvtime(sd, recvbuf, 2048,10, NULL);
|
res = recvtime(sd, recvbuf, 2048,10, NULL);
|
||||||
}
|
}
|
||||||
if (recvbuf[0] == '1' || recvbuf[0] == '2') {
|
if (recvbuf[0] == '1' || recvbuf[0] == '2') {
|
||||||
target->ports.addPort(portarray[i], IPPROTO_TCP, NULL, PORT_OPEN);
|
target->ports.addPort(portarray[i], IPPROTO_TCP, PORT_OPEN);
|
||||||
if (recvbuf[0] == '1') {
|
if (recvbuf[0] == '1') {
|
||||||
res = recvtime(sd, recvbuf, 2048,5, NULL);
|
res = recvtime(sd, recvbuf, 2048,5, NULL);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
@@ -5292,7 +5290,7 @@ void bounce_scan(Target *target, u16 *portarray, int numports,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* This means the port is closed ... */
|
/* This means the port is closed ... */
|
||||||
target->ports.addPort(portarray[i], IPPROTO_TCP, NULL, PORT_CLOSED);
|
target->ports.addPort(portarray[i], IPPROTO_TCP, PORT_CLOSED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1700,7 +1700,7 @@ static void adjustPortStateIfNeccessary(ServiceNFO *svc) {
|
|||||||
char host[128];
|
char host[128];
|
||||||
|
|
||||||
if (svc->port->state == PORT_OPENFILTERED) {
|
if (svc->port->state == PORT_OPENFILTERED) {
|
||||||
svc->target->ports.addPort(svc->portno, svc->proto, NULL, PORT_OPEN);
|
svc->target->ports.addPort(svc->portno, svc->proto, PORT_OPEN);
|
||||||
if (svc->proto == IPPROTO_TCP)
|
if (svc->proto == IPPROTO_TCP)
|
||||||
svc->target->ports.setStateReason(svc->portno, svc->proto, ER_TCPRESPONSE, 0, 0);
|
svc->target->ports.setStateReason(svc->portno, svc->proto, ER_TCPRESPONSE, 0, 0);
|
||||||
if (svc->proto == IPPROTO_UDP)
|
if (svc->proto == IPPROTO_UDP)
|
||||||
|
|||||||
Reference in New Issue
Block a user