mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Spellcheck for Ncat, Nping source files
This commit is contained in:
@@ -131,7 +131,7 @@ static int b64enc_internal(const unsigned char *data, int len, char *dest)
|
|||||||
|
|
||||||
char *buf = dest;
|
char *buf = dest;
|
||||||
|
|
||||||
/* Encode three bytes per iteration ala rfc3548. */
|
/* Encode three bytes per iteration a la rfc3548. */
|
||||||
while (len >= 3) {
|
while (len >= 3) {
|
||||||
buf[0] = b64alpha[(data[0] >> 2) & 0x3f];
|
buf[0] = b64alpha[(data[0] >> 2) & 0x3f];
|
||||||
buf[1] = b64alpha[((data[0] << 4) & 0x30) | ((data[1] >> 4) & 0xf)];
|
buf[1] = b64alpha[((data[0] << 4) & 0x30) | ((data[1] >> 4) & 0xf)];
|
||||||
|
|||||||
@@ -570,7 +570,7 @@ static int field_name_equal(const char *a, const char *b)
|
|||||||
|
|
||||||
/* Get the value of every header with the given name, separated by commas. If
|
/* Get the value of every header with the given name, separated by commas. If
|
||||||
you only want the first value for header fields that should not be
|
you only want the first value for header fields that should not be
|
||||||
concatentated in this way, use http_header_get_first. The returned string
|
concatenated in this way, use http_header_get_first. The returned string
|
||||||
must be freed. */
|
must be freed. */
|
||||||
char *http_header_get(const struct http_header *header, const char *name)
|
char *http_header_get(const struct http_header *header, const char *name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ char *http_digest_proxy_authorization(const struct http_challenge *challenge,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check that a nonce is one that we issued, and that the response is what is
|
/* Check that a nonce is one that we issued, and that the response is what is
|
||||||
expected. This doesn't do any checking aginst the lifetime of the nonce. */
|
expected. This doesn't do any checking against the lifetime of the nonce. */
|
||||||
int http_digest_check_credentials(const char *username, const char *realm,
|
int http_digest_check_credentials(const char *username, const char *realm,
|
||||||
const char *password, const char *method,
|
const char *password, const char *method,
|
||||||
const struct http_credentials *credentials)
|
const struct http_credentials *credentials)
|
||||||
|
|||||||
@@ -705,7 +705,7 @@ static int do_proxy_socks5(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* For username/password authentication the client's authentication request is
|
* For username/password authentication the client's authentication request is
|
||||||
* field 1: version number, 1 byte (must be 0x01 -- version of subnegotion)
|
* field 1: version number, 1 byte (must be 0x01 -- version of subnegotiation)
|
||||||
* field 2: username length, 1 byte
|
* field 2: username length, 1 byte
|
||||||
* field 3: username
|
* field 3: username
|
||||||
* field 4: password length, 1 byte
|
* field 4: password length, 1 byte
|
||||||
@@ -861,7 +861,7 @@ int ncat_connect(void)
|
|||||||
nsock_pool mypool;
|
nsock_pool mypool;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Unless explicitely asked not to do so, ncat uses the
|
/* Unless explicitly asked not to do so, ncat uses the
|
||||||
* fallback nsock engine to maximize compatibility between
|
* fallback nsock engine to maximize compatibility between
|
||||||
* operating systems and the different use cases.
|
* operating systems and the different use cases.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* ncat_core.c -- Contains option defintions and miscellaneous functions. *
|
* ncat_core.c -- Contains option definitions and miscellaneous functions. *
|
||||||
***********************IMPORTANT NMAP LICENSE TERMS************************
|
***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||||
* *
|
* *
|
||||||
* The Nmap Security Scanner is (C) 1996-2013 Insecure.Com LLC. Nmap is *
|
* The Nmap Security Scanner is (C) 1996-2013 Insecure.Com LLC. Nmap is *
|
||||||
|
|||||||
@@ -508,7 +508,7 @@ static DWORD WINAPI subprocess_thread_func(void *data)
|
|||||||
break;
|
break;
|
||||||
/* Restore the select event (and non-block the socket again.) */
|
/* Restore the select event (and non-block the socket again.) */
|
||||||
WSAEventSelect(info->fdn.fd, events[0], FD_READ | FD_CLOSE);
|
WSAEventSelect(info->fdn.fd, events[0], FD_READ | FD_CLOSE);
|
||||||
/* Queue another ansychronous read. */
|
/* Queue another asychronous read. */
|
||||||
ReadFile(info->child_out_r, pipe_buffer, sizeof(pipe_buffer), NULL, &overlap);
|
ReadFile(info->child_out_r, pipe_buffer, sizeof(pipe_buffer), NULL, &overlap);
|
||||||
} else {
|
} else {
|
||||||
if (GetLastError() != ERROR_IO_PENDING)
|
if (GetLastError() != ERROR_IO_PENDING)
|
||||||
|
|||||||
@@ -165,7 +165,7 @@
|
|||||||
from us, like a pending ssl negotiation. */
|
from us, like a pending ssl negotiation. */
|
||||||
static fd_set master_readfds, master_writefds, master_broadcastfds;
|
static fd_set master_readfds, master_writefds, master_broadcastfds;
|
||||||
#ifdef HAVE_OPENSSL
|
#ifdef HAVE_OPENSSL
|
||||||
/* sslpending_fds containts the list of ssl sockets that are waiting to complete
|
/* sslpending_fds contains the list of ssl sockets that are waiting to complete
|
||||||
the ssl handshake */
|
the ssl handshake */
|
||||||
static fd_set sslpending_fds;
|
static fd_set sslpending_fds;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -429,7 +429,7 @@ int main(int argc, char *argv[])
|
|||||||
o.proto = IPPROTO_UDP;
|
o.proto = IPPROTO_UDP;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
/* One -v activites verbose, after that it's debugging. */
|
/* One -v activates verbose, after that it's debugging. */
|
||||||
if (o.verbose == 0)
|
if (o.verbose == 0)
|
||||||
o.verbose++;
|
o.verbose++;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ void netexec(struct fdinfo *info, char *cmdexec)
|
|||||||
maxfd = info->fd;
|
maxfd = info->fd;
|
||||||
|
|
||||||
/* This is the parent process. Enter a "caretaker" loop that reads from the
|
/* This is the parent process. Enter a "caretaker" loop that reads from the
|
||||||
socket and writes to the suprocess, and reads from the subprocess and
|
socket and writes to the subprocess, and reads from the subprocess and
|
||||||
writes to the socket. We exit the loop on any read error (or EOF). On a
|
writes to the socket. We exit the loop on any read error (or EOF). On a
|
||||||
write error we just close the opposite side of the conversation. */
|
write error we just close the opposite side of the conversation. */
|
||||||
crlf_state = 0;
|
crlf_state = 0;
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ int ncat_http_server(void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make us not block on accepts in wierd cases. See ncat_listen.c:209 */
|
/* make us not block on accepts in weird cases. See ncat_listen.c:209 */
|
||||||
unblock_socket(listen_socket[num_sockets]);
|
unblock_socket(listen_socket[num_sockets]);
|
||||||
|
|
||||||
/* setup select sets and max fd */
|
/* setup select sets and max fd */
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ static struct lstr *check(SSL *ssl, const struct lstr names[])
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make a certificate object trusted by an SSL_CTX. I coulnd't find a way to do
|
/* Make a certificate object trusted by an SSL_CTX. I couldn't find a way to do
|
||||||
this directly, so the certificate is written in PEM format to a temporary
|
this directly, so the certificate is written in PEM format to a temporary
|
||||||
file and then loaded with SSL_CTX_load_verify_locations. Returns 1 on success
|
file and then loaded with SSL_CTX_load_verify_locations. Returns 1 on success
|
||||||
and 0 on failure. */
|
and 0 on failure. */
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
|||||||
/* CASE 2: User supplied a list of flags in the format "syn,ack,ecn" */
|
/* CASE 2: User supplied a list of flags in the format "syn,ack,ecn" */
|
||||||
}else if( contains(optarg, ",") ){
|
}else if( contains(optarg, ",") ){
|
||||||
if( ((strlen(optarg)+1)%4) !=0 )
|
if( ((strlen(optarg)+1)%4) !=0 )
|
||||||
nping_fatal(QT_3, "Invalid format in --flag. Make sure you specify a comma-separed list that contains 3-charater flag names (e.g: --flags syn,ack,psh)");
|
nping_fatal(QT_3, "Invalid format in --flag. Make sure you specify a comma-separated list that contains 3-character flag names (e.g: --flags syn,ack,psh)");
|
||||||
|
|
||||||
for( size_t f=0; f< strlen(optarg); f+=4 ){
|
for( size_t f=0; f< strlen(optarg); f+=4 ){
|
||||||
if(!strncasecmp((optarg+f), "CWR",3)){ o.setFlagTCP(FLAG_CWR); }
|
if(!strncasecmp((optarg+f), "CWR",3)){ o.setFlagTCP(FLAG_CWR); }
|
||||||
@@ -639,7 +639,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
|||||||
nping_fatal(QT_3,"You cannot specify mode %s if you want to send ICMP messages.", o.mode2Ascii(o.getMode()));
|
nping_fatal(QT_3,"You cannot specify mode %s if you want to send ICMP messages.", o.mode2Ascii(o.getMode()));
|
||||||
this->parseICMPTimestamp(optarg, &aux32);
|
this->parseICMPTimestamp(optarg, &aux32);
|
||||||
o.setICMPReceiveTimestamp(aux32);
|
o.setICMPReceiveTimestamp(aux32);
|
||||||
/* ICMP Timestamp trasnmit timestamp */
|
/* ICMP Timestamp transmit timestamp */
|
||||||
} else if (optcmp(long_options[option_index].name, "icmp-trans-time") == 0) {
|
} else if (optcmp(long_options[option_index].name, "icmp-trans-time") == 0) {
|
||||||
if ( o.issetMode() && o.getMode() != ICMP )
|
if ( o.issetMode() && o.getMode() != ICMP )
|
||||||
nping_fatal(QT_3,"You cannot specify mode %s if you want to send ICMP messages.", o.mode2Ascii(o.getMode()));
|
nping_fatal(QT_3,"You cannot specify mode %s if you want to send ICMP messages.", o.mode2Ascii(o.getMode()));
|
||||||
@@ -1351,7 +1351,7 @@ int ArgParser::parseAdvertEntry(char *str, struct in_addr *addr, u32 *pref){
|
|||||||
if(aux>=str+len-1 )
|
if(aux>=str+len-1 )
|
||||||
nping_fatal(QT_3, "Invalid Router Advertising Entry specification: Bad syntax, comma cannot be placed at the end");
|
nping_fatal(QT_3, "Invalid Router Advertising Entry specification: Bad syntax, comma cannot be placed at the end");
|
||||||
|
|
||||||
/* Looks like at least the syntax is corect */
|
/* Looks like at least the syntax is correct */
|
||||||
memcpy(first, str, aux-str);
|
memcpy(first, str, aux-str);
|
||||||
memcpy(last, aux+1, len-(aux-str) );
|
memcpy(last, aux+1, len-(aux-str) );
|
||||||
|
|
||||||
@@ -1375,7 +1375,7 @@ int ArgParser::parseAdvertEntry(char *str, struct in_addr *addr, u32 *pref){
|
|||||||
* Four letters - three letters: dest-unr
|
* Four letters - three letters: dest-unr
|
||||||
* Initials: du
|
* Initials: du
|
||||||
*
|
*
|
||||||
* In ICMP types that REQUEST something, the word "request" is always ommited.
|
* In ICMP types that REQUEST something, the word "request" is always omitted.
|
||||||
* For example: Echo request should be specified as "echo" or "e",
|
* For example: Echo request should be specified as "echo" or "e",
|
||||||
* not "echo-request"/"echo-req"/"er"
|
* not "echo-request"/"echo-req"/"er"
|
||||||
*
|
*
|
||||||
@@ -1483,7 +1483,7 @@ int ArgParser::atoICMPType(char *opt, u8 *type){
|
|||||||
* Four letters - three letters: need-fra
|
* Four letters - three letters: need-fra
|
||||||
* Our own version (varies): frag
|
* Our own version (varies): frag
|
||||||
*
|
*
|
||||||
* In ICMP types that REQUEST something, the word "request" is always ommited.
|
* In ICMP types that REQUEST something, the word "request" is always omitted.
|
||||||
* For example: Echo request should be specified as "echo" or "e",
|
* For example: Echo request should be specified as "echo" or "e",
|
||||||
* not "echo-request"/"echo-req"/"er"
|
* not "echo-request"/"echo-req"/"er"
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Crypto.cc -- The Crypto Class contains miscellanious methods and helpers*
|
* Crypto.cc -- The Crypto Class contains miscellaneous methods and helpers*
|
||||||
* that may be used to provide properties such as authentication, integrity*
|
* that may be used to provide properties such as authentication, integrity*
|
||||||
* or confidentiality. *
|
* or confidentiality. *
|
||||||
* *
|
* *
|
||||||
@@ -235,7 +235,7 @@ int Crypto::aes128_cbc_decrypt(u8 *inbuff, size_t inlen, u8 *dst_buff, u8 *key,
|
|||||||
* the last one and then EVP_DecryptFinal says we have decrypted nothing.
|
* the last one and then EVP_DecryptFinal says we have decrypted nothing.
|
||||||
* However I've tested this for hours and everything works fine. The
|
* However I've tested this for hours and everything works fine. The
|
||||||
* full buffer is decrypted correctly, from the first to the last byte,
|
* full buffer is decrypted correctly, from the first to the last byte,
|
||||||
* so we return OP_SUCCESS even if OpenSSL says the opossite. */
|
* so we return OP_SUCCESS even if OpenSSL says the opposite. */
|
||||||
|
|
||||||
/* NOTE for developers debugging memory issues with Valgrind:
|
/* NOTE for developers debugging memory issues with Valgrind:
|
||||||
* None of these seems to free OpenSSL's internal error structures.
|
* None of these seems to free OpenSSL's internal error structures.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Crypto.h -- The Crypto Class contains miscellanious methods and helpers *
|
* Crypto.h -- The Crypto Class contains miscellaneous methods and helpers *
|
||||||
* that may be used to provide properties such as authentication, integrity*
|
* that may be used to provide properties such as authentication, integrity*
|
||||||
* or confidentiality. *
|
* or confidentiality. *
|
||||||
* *
|
* *
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ int EchoClient::start(NpingTarget *target, u16 port){
|
|||||||
|
|
||||||
/* Init Nsock in the probe engine */
|
/* Init Nsock in the probe engine */
|
||||||
if( this->probe.init_nsock() != OP_SUCCESS ){
|
if( this->probe.init_nsock() != OP_SUCCESS ){
|
||||||
nping_warning(QT_2, "Couln't initialize Nsock.");
|
nping_warning(QT_2, "Couldn't initialize Nsock.");
|
||||||
return OP_FAILURE;
|
return OP_FAILURE;
|
||||||
}else{
|
}else{
|
||||||
/* Extract the nsock pool handler and store it here */
|
/* Extract the nsock pool handler and store it here */
|
||||||
@@ -950,7 +950,7 @@ int EchoClient::nep_recv_std_header_handler(nsock_pool nsp, nsock_event nse, voi
|
|||||||
nping_print(DBG_4, "%s() Received %d bytes", __func__, recvbytes);
|
nping_print(DBG_4, "%s() Received %d bytes", __func__, recvbytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Here there are different possibilites. We may have received exactly one
|
/* Here there are different possibilities. We may have received exactly one
|
||||||
* packet, we may have received more than one packet (as there is no way to
|
* packet, we may have received more than one packet (as there is no way to
|
||||||
* make Nsock return an exact amount of bytes), or we may have received
|
* make Nsock return an exact amount of bytes), or we may have received
|
||||||
* less than one packet. In the last case, we determine the number of bytes
|
* less than one packet. In the last case, we determine the number of bytes
|
||||||
@@ -1039,7 +1039,7 @@ int EchoClient::nep_recv_hs_final_handler(nsock_pool nsp, nsock_event nse, void
|
|||||||
|
|
||||||
|
|
||||||
/** Handles reception of NEP_READY message. It handles the received
|
/** Handles reception of NEP_READY message. It handles the received
|
||||||
* data provided by nsock and passes it to the parse_readyl() which is the
|
* data provided by nsock and passes it to the parse_ready() which is the
|
||||||
* one in charge of validating NEP_HANDSHAKE_FINAL packets and updating
|
* one in charge of validating NEP_HANDSHAKE_FINAL packets and updating
|
||||||
* the internal context accordingly. Returns OP_SUCCESS on success and
|
* the internal context accordingly. Returns OP_SUCCESS on success and
|
||||||
* OP_FAILURE in case of error. */
|
* OP_FAILURE in case of error. */
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ void EchoHeader::reset() {
|
|||||||
this->echo_mac=(u8 *)this->data_echo->payload_and_mac;
|
this->echo_mac=(u8 *)this->data_echo->payload_and_mac;
|
||||||
this->echo_bytes=0;
|
this->echo_bytes=0;
|
||||||
|
|
||||||
/* Some safe initilizations */
|
/* Some safe initializations */
|
||||||
this->setVersion(ECHO_CURRENT_PROTO_VER);
|
this->setVersion(ECHO_CURRENT_PROTO_VER);
|
||||||
this->setTotalLength(STD_NEP_HEADER_LEN + MAC_LENGTH);
|
this->setTotalLength(STD_NEP_HEADER_LEN + MAC_LENGTH);
|
||||||
this->length=STD_NEP_HEADER_LEN + MAC_LENGTH; /* Sets length in PacketElement superclass */
|
this->length=STD_NEP_HEADER_LEN + MAC_LENGTH; /* Sets length in PacketElement superclass */
|
||||||
@@ -184,7 +184,7 @@ int EchoHeader::storeRecvData(const u8 *buf, size_t len){
|
|||||||
} /* End of storeRecvData() */
|
} /* End of storeRecvData() */
|
||||||
|
|
||||||
|
|
||||||
/* Returns a protocol identifier. This is used by packet parsing funtions
|
/* Returns a protocol identifier. This is used by packet parsing functions
|
||||||
* that return linked lists of PacketElement objects, to determine the protocol
|
* that return linked lists of PacketElement objects, to determine the protocol
|
||||||
* the object represents. */
|
* the object represents. */
|
||||||
int EchoHeader::protocol_id() const {
|
int EchoHeader::protocol_id() const {
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ class EchoHeader : public ApplicationLayerElement {
|
|||||||
int echo_bytes;
|
int echo_bytes;
|
||||||
nep_error_data_t *data_error;
|
nep_error_data_t *data_error;
|
||||||
u8 *fs_off; /**< Current field spec offset */
|
u8 *fs_off; /**< Current field spec offset */
|
||||||
int fs_bytes; /**< Currend field spec byte count */
|
int fs_bytes; /**< Current field spec byte count */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int getFieldLength(u8 field);
|
int getFieldLength(u8 field);
|
||||||
|
|||||||
@@ -590,7 +590,7 @@ int NpingOps::getDebugging(){
|
|||||||
} /* End of getDebugging() */
|
} /* End of getDebugging() */
|
||||||
|
|
||||||
|
|
||||||
/** Increments debugginh level by one. (When it reaches DBG_9 it stops
|
/** Increments debugging level by one. (When it reaches DBG_9 it stops
|
||||||
* getting incremented)
|
* getting incremented)
|
||||||
* * @return previous verbosity level */
|
* * @return previous verbosity level */
|
||||||
int NpingOps::increaseDebugging(){
|
int NpingOps::increaseDebugging(){
|
||||||
@@ -793,7 +793,7 @@ bool NpingOps::issetDevice(){
|
|||||||
} /* End of issetDevice() */
|
} /* End of issetDevice() */
|
||||||
|
|
||||||
|
|
||||||
/** Returns true if user requested explicitely that he wants IP source
|
/** Returns true if user requested explicitly that he wants IP source
|
||||||
* spoofing */
|
* spoofing */
|
||||||
bool NpingOps::spoofSource(){
|
bool NpingOps::spoofSource(){
|
||||||
return this->spoofsource;
|
return this->spoofsource;
|
||||||
@@ -2287,7 +2287,7 @@ void NpingOps::validateOptions() {
|
|||||||
const char *privreq = "root privileges";
|
const char *privreq = "root privileges";
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
//if (!this->have_pcap)
|
//if (!this->have_pcap)
|
||||||
privreq = "that WinPcap version 3.1 or higher and iphlpapi.dll be installed. You seem to be missing one or both of these. Winpcap is available from http://www.winpcap.org. iphlpapi.dll comes with Win98 and later operating sytems and NT 4.0 with SP4 or greater. For previous windows versions, you may be able to take iphlpapi.dll from another system and place it in your system32 dir (e.g. c:\\windows\\system32)";
|
privreq = "that WinPcap version 3.1 or higher and iphlpapi.dll be installed. You seem to be missing one or both of these. Winpcap is available from http://www.winpcap.org. iphlpapi.dll comes with Win98 and later operating systems and NT 4.0 with SP4 or greater. For previous Windows versions, you may be able to take iphlpapi.dll from another system and place it in your system32 dir (e.g. c:\\windows\\system32)";
|
||||||
#endif
|
#endif
|
||||||
/* If user did not specify --privileged or --unprivileged explicitly, try to
|
/* If user did not specify --privileged or --unprivileged explicitly, try to
|
||||||
* determine if has root privileges. */
|
* determine if has root privileges. */
|
||||||
@@ -2396,14 +2396,14 @@ if (this->havePcap()==false){
|
|||||||
/** SOURCE IP, SOURCE MAC and NETWORK DEVICE *********************************/
|
/** SOURCE IP, SOURCE MAC and NETWORK DEVICE *********************************/
|
||||||
/* If we are in a mode where we need to craft IP packets, then we need to
|
/* If we are in a mode where we need to craft IP packets, then we need to
|
||||||
* obtain a network interface name and a source IP address. There are three
|
* obtain a network interface name and a source IP address. There are three
|
||||||
* different posibilities:
|
* different possibilities:
|
||||||
* 1. User did NOT specify both network interface and source IP address.
|
* 1. User did NOT specify both network interface and source IP address.
|
||||||
* 2. User did specify a network interface but not a source IP address.
|
* 2. User did specify a network interface but not a source IP address.
|
||||||
* 3. User did actually supply a source IP but not a network interface name
|
* 3. User did actually supply a source IP but not a network interface name
|
||||||
*
|
*
|
||||||
* I know the following code is ugly but the thing is that we want to determine
|
* I know the following code is ugly but the thing is that we want to determine
|
||||||
* interface and source IP without user intervention, so we try in many ways
|
* interface and source IP without user intervention, so we try in many ways
|
||||||
* until either we succeed or we run out of possibilites and fatal().
|
* until either we succeed or we run out of possibilities and fatal().
|
||||||
*/
|
*/
|
||||||
if( this->getMode()!=TCP_CONNECT && this->getMode()!=UDP_UNPRIV && this->getRole()!=ROLE_SERVER){
|
if( this->getMode()!=TCP_CONNECT && this->getMode()!=UDP_UNPRIV && this->getRole()!=ROLE_SERVER){
|
||||||
|
|
||||||
@@ -2540,11 +2540,11 @@ if(this->getRole()!=ROLE_SERVER){
|
|||||||
|
|
||||||
if( this->getMode()==ARP && !this->sendPreferenceEthernet() ){
|
if( this->getMode()==ARP && !this->sendPreferenceEthernet() ){
|
||||||
this->setSendEth(true);
|
this->setSendEth(true);
|
||||||
nping_warning(QT_2, "Warning: ARP mode requieres raw ethernet frame transmission. Specified preference will be ignored.");
|
nping_warning(QT_2, "Warning: ARP mode requires raw ethernet frame transmission. Specified preference will be ignored.");
|
||||||
}
|
}
|
||||||
else if( this->ipv6() ){
|
else if( this->ipv6() ){
|
||||||
|
|
||||||
/* CASE 1: User requested ethernet explicitely and supplied all
|
/* CASE 1: User requested ethernet explicitly and supplied all
|
||||||
* necessary options. */
|
* necessary options. */
|
||||||
if( this->sendPreferenceEthernet() && this->canDoIPv6Ethernet() ){
|
if( this->sendPreferenceEthernet() && this->canDoIPv6Ethernet() ){
|
||||||
this->setSendEth(true);
|
this->setSendEth(true);
|
||||||
@@ -2689,7 +2689,7 @@ bool NpingOps::canDoIPv6Ethernet(){
|
|||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Miscellanious *
|
* Miscellaneous *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
void NpingOps::displayNpingDoneMsg(){
|
void NpingOps::displayNpingDoneMsg(){
|
||||||
@@ -3050,7 +3050,7 @@ struct timeval NpingOps::getLastPacketSentTime(){
|
|||||||
/** Sets the RCVD output to be delayed. The supplied string is strdup()ed, so
|
/** Sets the RCVD output to be delayed. The supplied string is strdup()ed, so
|
||||||
* the caller may safely free() it or modify after calling this function.
|
* the caller may safely free() it or modify after calling this function.
|
||||||
* The "id" parameter is the nsock timer event scheduled for the output of
|
* The "id" parameter is the nsock timer event scheduled for the output of
|
||||||
* the RCVD string (usially scheduled by ProbeMode). It is provided to allow
|
* the RCVD string (usually scheduled by ProbeMode). It is provided to allow
|
||||||
* other objects (like EchoClient) to cancel the event if they take care of
|
* other objects (like EchoClient) to cancel the event if they take care of
|
||||||
* printing the RCVD string before the timer goes off.*/
|
* printing the RCVD string before the timer goes off.*/
|
||||||
int NpingOps::setDelayedRcvd(const char *str, nsock_event_id id){
|
int NpingOps::setDelayedRcvd(const char *str, nsock_event_id id){
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ class NpingOps {
|
|||||||
bool payload_len_set;
|
bool payload_len_set;
|
||||||
|
|
||||||
/* Roles */
|
/* Roles */
|
||||||
int role; /* Nping's role: normal|cliente|server. */
|
int role; /* Nping's role: normal|client|server. */
|
||||||
bool role_set;
|
bool role_set;
|
||||||
|
|
||||||
/* IPv4 */
|
/* IPv4 */
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class NpingTarget {
|
|||||||
char *hostname; /**< Resolved host name */
|
char *hostname; /**< Resolved host name */
|
||||||
int namedhost; /**< =1 is named host; =0 is an IP; =-1 unset */
|
int namedhost; /**< =1 is named host; =0 is an IP; =-1 unset */
|
||||||
char *targetname; /**< Name of the target host given on the *
|
char *targetname; /**< Name of the target host given on the *
|
||||||
* commmand line if it is a named host */
|
* command line if it is a named host */
|
||||||
|
|
||||||
struct sockaddr_storage targetsock; /**< Target address */
|
struct sockaddr_storage targetsock; /**< Target address */
|
||||||
size_t targetsocklen;
|
size_t targetsocklen;
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ class NpingTargets {
|
|||||||
unsigned long int freeTargets();
|
unsigned long int freeTargets();
|
||||||
NpingTarget *findTarget(struct sockaddr_storage *tt);
|
NpingTarget *findTarget(struct sockaddr_storage *tt);
|
||||||
|
|
||||||
/* TODO: MAke private */
|
/* TODO: Make private */
|
||||||
NpingTarget *currenths;
|
NpingTarget *currenths;
|
||||||
vector<NpingTarget *> Targets;
|
vector<NpingTarget *> Targets;
|
||||||
|
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ int ProbeMode::start(){
|
|||||||
u32 zero=0; /**< Empty payload */
|
u32 zero=0; /**< Empty payload */
|
||||||
u8 pktinfobuffer[512+1]; /**< Used in ippackethdrinfo() calls */
|
u8 pktinfobuffer[512+1]; /**< Used in ippackethdrinfo() calls */
|
||||||
u8 pkt[MAX_IP_PACKET_LEN]; /**< Holds packets returned by fillpacket */
|
u8 pkt[MAX_IP_PACKET_LEN]; /**< Holds packets returned by fillpacket */
|
||||||
int pktLen=0; /**< Lenght of current packet */
|
int pktLen=0; /**< Length of current packet */
|
||||||
NpingTarget *target=NULL; /**< Current target */
|
NpingTarget *target=NULL; /**< Current target */
|
||||||
u16 *targetPorts=NULL; /**< Pointer to array of target ports */
|
u16 *targetPorts=NULL; /**< Pointer to array of target ports */
|
||||||
int numTargetPorts=0; /**< Total number of target ports */
|
int numTargetPorts=0; /**< Total number of target ports */
|
||||||
@@ -221,7 +221,7 @@ int ProbeMode::start(){
|
|||||||
sendpkt_t pkts2send[MX_PKT]; /**< We have a race condition here but the
|
sendpkt_t pkts2send[MX_PKT]; /**< We have a race condition here but the
|
||||||
* problem is not trivial to solve because we cannot create a sendpkt_t
|
* problem is not trivial to solve because we cannot create a sendpkt_t
|
||||||
* struct for every probe we send. That could be alright in most cases but
|
* struct for every probe we send. That could be alright in most cases but
|
||||||
* not when targetting large networks or when doing flooding. The problem here
|
* not when targeting large networks or when doing flooding. The problem here
|
||||||
* is that we may need access to specific sendpkt_t vars inside the nsock
|
* is that we may need access to specific sendpkt_t vars inside the nsock
|
||||||
* event handlers but as some operations are asynchronous, we may exhaust
|
* event handlers but as some operations are asynchronous, we may exhaust
|
||||||
* the current array of sendpkt_t structs and overwrite some positions
|
* the current array of sendpkt_t structs and overwrite some positions
|
||||||
@@ -291,7 +291,7 @@ int ProbeMode::start(){
|
|||||||
|
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/** UDP UNPRIVILEGD MODE **/
|
/** UDP UNPRIVILEGED MODE **/
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
case UDP_UNPRIV:
|
case UDP_UNPRIV:
|
||||||
o.stats.startClocks();
|
o.stats.startClocks();
|
||||||
@@ -848,7 +848,7 @@ int ProbeMode::fillPacketTCP(NpingTarget *target, u16 port, u8 *buff, int buffle
|
|||||||
if( o.getFlagTCP(FLAG_FIN) == 1 ) t.setFIN();
|
if( o.getFlagTCP(FLAG_FIN) == 1 ) t.setFIN();
|
||||||
|
|
||||||
|
|
||||||
/* Now let's encapsule the TCP packet into an IP packet */
|
/* Now let's encapsulate the TCP packet into an IP packet */
|
||||||
switch( o.getIPVersion() ){
|
switch( o.getIPVersion() ){
|
||||||
|
|
||||||
case IP_VERSION_4:
|
case IP_VERSION_4:
|
||||||
@@ -966,7 +966,7 @@ int ProbeMode::fillPacketUDP(NpingTarget *target, u16 port, u8 *buff, int buffle
|
|||||||
u.setDestinationPort( port );
|
u.setDestinationPort( port );
|
||||||
u.setTotalLength();
|
u.setTotalLength();
|
||||||
|
|
||||||
/* Now let's encapsule the TCP packet into an IP packet */
|
/* Now let's encapsulate the TCP packet into an IP packet */
|
||||||
switch( o.getIPVersion() ){
|
switch( o.getIPVersion() ){
|
||||||
|
|
||||||
case IP_VERSION_4:
|
case IP_VERSION_4:
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ using namespace std;
|
|||||||
#define PKT_TYPE_ARP_RAW 6
|
#define PKT_TYPE_ARP_RAW 6
|
||||||
|
|
||||||
/* The sendpkt structure is the data normalProbeMode() function passes to
|
/* The sendpkt structure is the data normalProbeMode() function passes to
|
||||||
* the nsock event handler. It contains the neccessary information so a
|
* the nsock event handler. It contains the necessary information so a
|
||||||
* handler can send one probe. */
|
* handler can send one probe. */
|
||||||
typedef struct sendpkt{
|
typedef struct sendpkt{
|
||||||
int type;
|
int type;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* common.cc -- This file holds all those functions and classes that have *
|
* common.cc -- This file holds all those functions and classes that have *
|
||||||
* been copied verbatim from nmap's source code *
|
* been copied verbatim from Nmap's source code *
|
||||||
* *
|
* *
|
||||||
***********************IMPORTANT NMAP LICENSE TERMS************************
|
***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||||
* *
|
* *
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* common.h -- This file holds all those functions and classes that have *
|
* common.h -- This file holds all those functions and classes that have *
|
||||||
* been copied verbatim from nmap's source code *
|
* been copied verbatim from Nmap's source code *
|
||||||
* *
|
* *
|
||||||
***********************IMPORTANT NMAP LICENSE TERMS************************
|
***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||||
* *
|
* *
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* common_modified.cc -- This file holds all those functions and classes *
|
* common_modified.cc -- This file holds all those functions and classes *
|
||||||
* that have been reused from nmap's code but that needed to be modified *
|
* that have been reused from Nmap's code but that needed to be modified *
|
||||||
* in order to reuse them. *
|
* in order to reuse them. *
|
||||||
* *
|
* *
|
||||||
***********************IMPORTANT NMAP LICENSE TERMS************************
|
***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||||
@@ -152,7 +152,7 @@ void TargetGroup::Initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* take the object back to the beginning without (mdmcl)
|
/* take the object back to the beginning without (mdmcl)
|
||||||
* reinitalizing the data structures */
|
* reinitializing the data structures */
|
||||||
int TargetGroup::rewind() {
|
int TargetGroup::rewind() {
|
||||||
|
|
||||||
/* For netmasks we must set the current address to the
|
/* For netmasks we must set the current address to the
|
||||||
@@ -178,7 +178,7 @@ int TargetGroup::rewind() {
|
|||||||
}
|
}
|
||||||
#if HAVE_IPV6
|
#if HAVE_IPV6
|
||||||
/* For IPV6 there is only one address, this function doesn't
|
/* For IPV6 there is only one address, this function doesn't
|
||||||
* make much sence for IPv6 does it? */
|
* make much sense for IPv6 does it? */
|
||||||
else if (targets_type == IPV6_ADDRESS) {
|
else if (targets_type == IPV6_ADDRESS) {
|
||||||
ipsleft = 1;
|
ipsleft = 1;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -216,7 +216,7 @@ int TargetGroup::skip_range(_octet_nums octet) {
|
|||||||
oct = 2;
|
oct = 2;
|
||||||
hosts_skipped = (last[3] + 1);
|
hosts_skipped = (last[3] + 1);
|
||||||
break;
|
break;
|
||||||
default: /* Hmm, how'd you do that */
|
default: /* Hmm, how did you do that? */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,7 +456,7 @@ int TargetGroup::parse_expr(const char * const target_expr, int af) {
|
|||||||
* I haven't been able to find any problem with that code but
|
* I haven't been able to find any problem with that code but
|
||||||
* still, the fact that DNS queries are cached does not improve
|
* still, the fact that DNS queries are cached does not improve
|
||||||
* performance a lot. It may save one DNS query per execution
|
* performance a lot. It may save one DNS query per execution
|
||||||
* in those cases wher NpingOps::validateOptions() grabs the
|
* in those cases where NpingOps::validateOptions() grabs the
|
||||||
* first target and uses it to determine output network interface.
|
* first target and uses it to determine output network interface.
|
||||||
* It would also save some queries in the case where a user
|
* It would also save some queries in the case where a user
|
||||||
* specified the same host twice in the commandlined, something
|
* specified the same host twice in the commandlined, something
|
||||||
@@ -803,7 +803,7 @@ void getpts_aux(const char *origexpr, int nested, u8 *porttbl, int *portwarning)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* IPv6 compatible version of nmap's devname2ipaddr()
|
/* IPv6 compatible version of Nmap's devname2ipaddr()
|
||||||
* @warning For this to work we need getinterfaces() not to skip IPv6 */
|
* @warning For this to work we need getinterfaces() not to skip IPv6 */
|
||||||
int devname2ipaddr_alt(char *dev, struct sockaddr_storage *addr) {
|
int devname2ipaddr_alt(char *dev, struct sockaddr_storage *addr) {
|
||||||
struct interface_info *mydevs;
|
struct interface_info *mydevs;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* common_modified.h -- This file holds all those functions and classes *
|
* common_modified.h -- This file holds all those functions and classes *
|
||||||
* that have been reused from nmap's code but that needed to be modified *
|
* that have been reused from Nmap's code but that needed to be modified *
|
||||||
* in order to reuse them. *
|
* in order to reuse them. *
|
||||||
* *
|
* *
|
||||||
***********************IMPORTANT NMAP LICENSE TERMS************************
|
***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ typedef struct service_lookup {
|
|||||||
char *name;
|
char *name;
|
||||||
u8 proto;
|
u8 proto;
|
||||||
u16 portno;
|
u16 portno;
|
||||||
} sevice_lookup;
|
} service_lookup;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -235,7 +235,7 @@
|
|||||||
|
|
||||||
/* CONSTANT DEFINES ***********************************************************
|
/* CONSTANT DEFINES ***********************************************************
|
||||||
* @warning It's better not to play with these, because the code may make *
|
* @warning It's better not to play with these, because the code may make *
|
||||||
* SOME asumptions like "defined value A is an integer greater than defined *
|
* SOME assumptions like "defined value A is an integer greater than defined *
|
||||||
* value B" or "value C is an odd integer greater than 0", etc. */
|
* value B" or "value C is an odd integer greater than 0", etc. */
|
||||||
|
|
||||||
/* VERBOSITY LEVELS */
|
/* VERBOSITY LEVELS */
|
||||||
@@ -246,7 +246,7 @@
|
|||||||
* printed. For example, we have some calls to output functions that print out
|
* printed. For example, we have some calls to output functions that print out
|
||||||
* things like "%d target IPs resolved". We don't want that message to always
|
* things like "%d target IPs resolved". We don't want that message to always
|
||||||
* get printed during Nping's execution. We only want it out when the user
|
* get printed during Nping's execution. We only want it out when the user
|
||||||
* has increasse the verbosity.
|
* has increase the verbosity.
|
||||||
*
|
*
|
||||||
* So the thing here is that there are two things that should be taken
|
* So the thing here is that there are two things that should be taken
|
||||||
* into account:
|
* into account:
|
||||||
@@ -275,7 +275,7 @@
|
|||||||
* verbose to us, programmers, because calls that supply QT_X levels almost
|
* verbose to us, programmers, because calls that supply QT_X levels almost
|
||||||
* always get printed. This is because base verbosity is VB_0 and that
|
* always get printed. This is because base verbosity is VB_0 and that
|
||||||
* includes all QT_X levels. So you have to be careful with those. QT_ levels
|
* includes all QT_X levels. So you have to be careful with those. QT_ levels
|
||||||
* should only be used to print important stuff like fata errors, warnings,
|
* should only be used to print important stuff like fatal errors, warnings,
|
||||||
* and some basic running time information. Level QT_4 is the quiet-est one
|
* and some basic running time information. Level QT_4 is the quiet-est one
|
||||||
* and nothing is ever printed out.
|
* and nothing is ever printed out.
|
||||||
*
|
*
|
||||||
@@ -295,8 +295,8 @@
|
|||||||
#define QT_1 3 /**< Start and timing information but no sent/recv packets */
|
#define QT_1 3 /**< Start and timing information but no sent/recv packets */
|
||||||
|
|
||||||
/* Base level (QT_0 is provided for consistency but should not be used) */
|
/* Base level (QT_0 is provided for consistency but should not be used) */
|
||||||
#define QT_0 4 /**< Normal info (sent/recv packes, statistics...) (DEFAULT */
|
#define QT_0 4 /**< Normal info (sent/recv packets, statistics...) (DEFAULT */
|
||||||
#define VB_0 4 /**< Normal info (sent/recv packes, statistics...) (DEFAULT)*/
|
#define VB_0 4 /**< Normal info (sent/recv packets, statistics...) (DEFAULT)*/
|
||||||
|
|
||||||
/* More verbosity */
|
/* More verbosity */
|
||||||
#define VB_1 5 /**< Detailed information about times, flags, etc. */
|
#define VB_1 5 /**< Detailed information about times, flags, etc. */
|
||||||
@@ -364,7 +364,7 @@
|
|||||||
|
|
||||||
#define DEFAULT_DELAY 1000 /**< Milliseconds between each probe */
|
#define DEFAULT_DELAY 1000 /**< Milliseconds between each probe */
|
||||||
|
|
||||||
/** Millisenconds Nping waits for teplies after all probes have been sent */
|
/** Milliseconds Nping waits for replies after all probes have been sent */
|
||||||
#define DEFAULT_WAIT_AFTER_PROBES 1000
|
#define DEFAULT_WAIT_AFTER_PROBES 1000
|
||||||
|
|
||||||
#define DEFAULT_IP_TTL 64 /**< Default IP Time To Live */
|
#define DEFAULT_IP_TTL 64 /**< Default IP Time To Live */
|
||||||
@@ -399,7 +399,7 @@
|
|||||||
* of the whole IP packet is more than 16436 when using loopback interface or
|
* of the whole IP packet is more than 16436 when using loopback interface or
|
||||||
* more than 1500 when using a normal network interface, the kernel complains
|
* more than 1500 when using a normal network interface, the kernel complains
|
||||||
* and says "Message too long". This is obviously caused by the configured
|
* and says "Message too long". This is obviously caused by the configured
|
||||||
* MTU. So the thing is that altough we allow users to specify payloads up to
|
* MTU. So the thing is that although we allow users to specify payloads up to
|
||||||
* MAX_PAYLOAD_ALLOWED bytes, when we generate random payloads, we set our
|
* MAX_PAYLOAD_ALLOWED bytes, when we generate random payloads, we set our
|
||||||
* on limit on 1500-20-20=1460 bytes. Let's be conservative and consider that
|
* on limit on 1500-20-20=1460 bytes. Let's be conservative and consider that
|
||||||
* IP packet has 40bytes of options and TCP has 20. So max length should be
|
* IP packet has 40bytes of options and TCP has 20. So max length should be
|
||||||
@@ -425,7 +425,7 @@
|
|||||||
* without problem, so it should never happen. We expect to use this constant
|
* without problem, so it should never happen. We expect to use this constant
|
||||||
* when received packets are really weird (eg. tunneled traffic, protocols we
|
* when received packets are really weird (eg. tunneled traffic, protocols we
|
||||||
* don't understand, etc. The 40 bytes are a compromise between dropping the
|
* don't understand, etc. The 40 bytes are a compromise between dropping the
|
||||||
* packet but provide total protection against data leakeage due to attacks to
|
* packet but provide total protection against data leakage due to attacks to
|
||||||
* the echo server, and providing some flexibility at the risk of leaking
|
* the echo server, and providing some flexibility at the risk of leaking
|
||||||
* a few bytes if an attacker is able to trick the echo server into echoing
|
* a few bytes if an attacker is able to trick the echo server into echoing
|
||||||
* packets that were not originated by him. */
|
* packets that were not originated by him. */
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ int nping_print(int level, const char *str, ...){
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* The following functions are provided only for compatibility with some */
|
/* The following functions are provided only for compatibility with some */
|
||||||
/* code from Nmap. They should NOT be used in any new piece of code unless */
|
/* code from Nmap. They should NOT be used in any new piece of code unless */
|
||||||
/* the code you are writting needs to be shared with nmap. */
|
/* the code you are writing needs to be shared with nmap. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/** Print fatal error messages to stderr and then exits.
|
/** Print fatal error messages to stderr and then exits.
|
||||||
* @warning This function does not return because it calls exit() */
|
* @warning This function does not return because it calls exit() */
|
||||||
|
|||||||
@@ -150,14 +150,14 @@
|
|||||||
#define MAX_ERR_STR_LEN 1024 /* Max length of an error message */
|
#define MAX_ERR_STR_LEN 1024 /* Max length of an error message */
|
||||||
#define MAX_OUTPUT_STR_LEN 2048 /* Max length of an output message */
|
#define MAX_OUTPUT_STR_LEN 2048 /* Max length of an output message */
|
||||||
|
|
||||||
/* For backwards compatibility with nmap's code */
|
/* For backwards compatibility with Nmap's code */
|
||||||
int fatal(const char *str, ...)
|
int fatal(const char *str, ...)
|
||||||
__attribute__ ((format (printf, 1, 2)));
|
__attribute__ ((format (printf, 1, 2)));
|
||||||
|
|
||||||
int error(const char *str, ...)
|
int error(const char *str, ...)
|
||||||
__attribute__ ((format (printf, 1, 2)));
|
__attribute__ ((format (printf, 1, 2)));
|
||||||
|
|
||||||
/* For backwards compatibility with nmap's code */
|
/* For backwards compatibility with Nmap's code */
|
||||||
int pfatal(const char *str, ...)
|
int pfatal(const char *str, ...)
|
||||||
__attribute__ ((format (printf, 1, 2)));
|
__attribute__ ((format (printf, 1, 2)));
|
||||||
|
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ void luis_hdump(char *cp, unsigned int length) {
|
|||||||
unsigned int i=0, hex=0, asc=0; /* Array indexes */
|
unsigned int i=0, hex=0, asc=0; /* Array indexes */
|
||||||
int line_count=0; /* For byte count at line start */
|
int line_count=0; /* For byte count at line start */
|
||||||
u8 current_char=0; /* Current character to print */
|
u8 current_char=0; /* Current character to print */
|
||||||
#define LINE_LEN 70 /* Lenght of printed line */
|
#define LINE_LEN 70 /* Length of printed line */
|
||||||
char line2print[LINE_LEN]; /* Stores current line */
|
char line2print[LINE_LEN]; /* Stores current line */
|
||||||
char printbyte[16]; /* For byte conversion */
|
char printbyte[16]; /* For byte conversion */
|
||||||
memset(line2print, ' ', LINE_LEN);
|
memset(line2print, ' ', LINE_LEN);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* utils_net.cc -- Miscellanious network-related functions that perform *
|
* utils_net.cc -- Miscellaneous network-related functions that perform *
|
||||||
* various tasks. *
|
* various tasks. *
|
||||||
* *
|
* *
|
||||||
***********************IMPORTANT NMAP LICENSE TERMS************************
|
***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||||
@@ -471,7 +471,7 @@ int getPacketStrInfo(const char *proto, const u8 *packet, u32 len, u8 *dstbuff,
|
|||||||
else
|
else
|
||||||
nping_fatal(QT_3, "getPacketStrInfo(): Unable to determinate transport layer protocol");
|
nping_fatal(QT_3, "getPacketStrInfo(): Unable to determinate transport layer protocol");
|
||||||
}else{
|
}else{
|
||||||
nping_fatal(QT_3, "getPacketStrInfo(): Unkwnown protocol");
|
nping_fatal(QT_3, "getPacketStrInfo(): Unknown protocol");
|
||||||
}
|
}
|
||||||
return OP_SUCCESS;
|
return OP_SUCCESS;
|
||||||
} /* getPacketStrInfo() */
|
} /* getPacketStrInfo() */
|
||||||
@@ -626,10 +626,10 @@ int resolveCached(char *host, struct sockaddr_storage *ss, size_t *sslen, int pf
|
|||||||
|
|
||||||
|
|
||||||
/* I run some tests to see what is the best approach when the cache
|
/* I run some tests to see what is the best approach when the cache
|
||||||
* is full. The thing is that in Nping, we are likeley to call
|
* is full. The thing is that in Nping, we are likely to call
|
||||||
* this function over and over with specifying the same hosts. Deleting
|
* this function over and over with specifying the same hosts. Deleting
|
||||||
* the oldest entry results in 100% cache misses. I also tried to start
|
* the oldest entry results in 100% cache misses. I also tried to start
|
||||||
* overwritting entries first backwards and then upwards. That showed
|
* overwriting entries first backwards and then upwards. That showed
|
||||||
* much better results. However, if we simply overwrite the last
|
* much better results. However, if we simply overwrite the last
|
||||||
* cache entry over an over we get the best results. */
|
* cache entry over an over we get the best results. */
|
||||||
if( current_index < MAX_CACHED_HOSTS-1 )
|
if( current_index < MAX_CACHED_HOSTS-1 )
|
||||||
@@ -821,7 +821,7 @@ int hostentfree(struct hostent *src){
|
|||||||
* The "txt" parameter may take the special value "rand" or "random",
|
* The "txt" parameter may take the special value "rand" or "random",
|
||||||
* in which case, 6 random bytes will be stored in "targetbuff".
|
* in which case, 6 random bytes will be stored in "targetbuff".
|
||||||
* @return OP_SUCCESS on success and OP_FAILURE in case of error.
|
* @return OP_SUCCESS on success and OP_FAILURE in case of error.
|
||||||
* Buffer targetbuff is NOT modified if "txt" does not have the propper
|
* Buffer targetbuff is NOT modified if "txt" does not have the proper
|
||||||
* format */
|
* format */
|
||||||
int parseMAC(const char *txt, u8 *targetbuff){
|
int parseMAC(const char *txt, u8 *targetbuff){
|
||||||
u8 mac_data[6];
|
u8 mac_data[6];
|
||||||
@@ -1557,7 +1557,7 @@ int getinterfaces_inet6_linux(if6_t *ifbuf, int max_ifaces){
|
|||||||
|
|
||||||
/* Check the line has the expected format ********************************/
|
/* Check the line has the expected format ********************************/
|
||||||
/* Some versions of the kernel include colons in the IPv6 address, some
|
/* Some versions of the kernel include colons in the IPv6 address, some
|
||||||
* others dont. E.g:
|
* others don't. E.g:
|
||||||
* fe80:0000:0000:0000:0333:a5ff:4444:9306 03 40 20 80 wlan0
|
* fe80:0000:0000:0000:0333:a5ff:4444:9306 03 40 20 80 wlan0
|
||||||
* fe800000000000000333a5ff44449306 03 40 20 80 wlan0
|
* fe800000000000000333a5ff44449306 03 40 20 80 wlan0
|
||||||
* So what we do is to remove the colons so we can process the line
|
* So what we do is to remove the colons so we can process the line
|
||||||
@@ -1751,7 +1751,7 @@ int getroutes_inet6_linux(route6_t *rtbuf, int max_routes){
|
|||||||
|
|
||||||
/* Check the line has the expected format ********************************/
|
/* Check the line has the expected format ********************************/
|
||||||
/* Some versions of the kernel include colons in the IPv6 address, some
|
/* Some versions of the kernel include colons in the IPv6 address, some
|
||||||
* others dont. So what we do is to remove the colons so we can process
|
* others don't. So what we do is to remove the colons so we can process
|
||||||
* the line no matter the format of the IPv6 addresses.
|
* the line no matter the format of the IPv6 addresses.
|
||||||
*
|
*
|
||||||
* TODO: Can interfaces with format eth0:1 appear on /proc/net/ipv6_route?
|
* TODO: Can interfaces with format eth0:1 appear on /proc/net/ipv6_route?
|
||||||
@@ -1761,7 +1761,7 @@ int getroutes_inet6_linux(route6_t *rtbuf, int max_routes){
|
|||||||
/* 1. Check it has the correct length. */
|
/* 1. Check it has the correct length. */
|
||||||
size_t min_len=0;
|
size_t min_len=0;
|
||||||
min_len += 3*32; /* Three IPv6 addresses in hex */
|
min_len += 3*32; /* Three IPv6 addresses in hex */
|
||||||
min_len += 2*2; /* Two 8bit hex values (prefiex lengths) */
|
min_len += 2*2; /* Two 8bit hex values (prefix lengths) */
|
||||||
min_len += 4*8; /* Four 32-bit hex values */
|
min_len += 4*8; /* Four 32-bit hex values */
|
||||||
min_len += 1; /* I guess one char is the min for a device len */
|
min_len += 1; /* I guess one char is the min for a device len */
|
||||||
min_len += 9; /* 9 spaces */
|
min_len += 9; /* 9 spaces */
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* utils_net.cc -- Miscellanious network-related functions that perform *
|
* utils_net.cc -- Miscellaneous network-related functions that perform *
|
||||||
* various tasks. *
|
* various tasks. *
|
||||||
* *
|
* *
|
||||||
***********************IMPORTANT NMAP LICENSE TERMS************************
|
***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* winclude.h -- some windows include files and *
|
* winclude.h -- some windows include files and *
|
||||||
* windows-compatabilty-related functions that are specific to Nmap. Most *
|
* windows-compatibility-related functions that are specific to Nmap. Most *
|
||||||
* of this has been moved into nbase so it can be shared. *
|
* of this has been moved into nbase so it can be shared. *
|
||||||
* *
|
* *
|
||||||
***********************IMPORTANT NMAP LICENSE TERMS************************
|
***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* winfix.cc -- A few trivial windows-compatabilty-related functions that *
|
* winfix.cc -- A few trivial windows-compatibility-related functions that *
|
||||||
* are specific to Nmap. Most of this has been moved into nbase so it can *
|
* are specific to Nmap. Most of this has been moved into nbase so it can *
|
||||||
* be shared. *
|
* be shared. *
|
||||||
* *
|
* *
|
||||||
|
|||||||
Reference in New Issue
Block a user