mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Got rid of (unnecessary) spaces in blank lines in *.cc and *.h files.
sed -i 's/^\s*$//'
This commit is contained in:
@@ -183,7 +183,7 @@ void *cp_alloc(int sz) {
|
|||||||
|
|
||||||
if ((modulus = sz % ALIGN_ON))
|
if ((modulus = sz % ALIGN_ON))
|
||||||
sz += ALIGN_ON - modulus;
|
sz += ALIGN_ON - modulus;
|
||||||
|
|
||||||
if ((nextchar - charpool[currentcharpool]) + sz <= currentcharpoolsz) {
|
if ((nextchar - charpool[currentcharpool]) + sz <= currentcharpoolsz) {
|
||||||
p = nextchar;
|
p = nextchar;
|
||||||
nextchar += sz;
|
nextchar += sz;
|
||||||
@@ -193,7 +193,7 @@ void *cp_alloc(int sz) {
|
|||||||
cp_grow();
|
cp_grow();
|
||||||
|
|
||||||
return cp_alloc(sz);
|
return cp_alloc(sz);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *cp_strdup(const char *src) {
|
char *cp_strdup(const char *src) {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ struct ip
|
|||||||
/*
|
/*
|
||||||
* Non DIX types. Won't clash for 1500 types.
|
* Non DIX types. Won't clash for 1500 types.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */
|
#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */
|
||||||
#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */
|
#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */
|
||||||
#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */
|
#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */
|
||||||
@@ -292,7 +292,7 @@ struct ip_timestamp {
|
|||||||
#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */
|
#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */
|
||||||
#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */
|
#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */
|
||||||
#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */
|
#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */
|
||||||
|
|
||||||
|
|
||||||
#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
|
#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
|
||||||
#define ICMP_ROUTERADVERT 9 /* router advertisement */
|
#define ICMP_ROUTERADVERT 9 /* router advertisement */
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ static int tty_getchar()
|
|||||||
fd_set set;
|
fd_set set;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (tty_fd && tcgetpgrp(tty_fd) == getpgrp()) {
|
if (tty_fd && tcgetpgrp(tty_fd) == getpgrp()) {
|
||||||
|
|
||||||
// This is so that when the terminal has been disconnected, it will be
|
// This is so that when the terminal has been disconnected, it will be
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
|||||||
{"arp-reply", no_argument, 0, 0},
|
{"arp-reply", no_argument, 0, 0},
|
||||||
{"rarp-request", no_argument, 0, 0},
|
{"rarp-request", no_argument, 0, 0},
|
||||||
{"rarp-reply", no_argument, 0, 0},
|
{"rarp-reply", no_argument, 0, 0},
|
||||||
|
|
||||||
/* TCP/UDP */
|
/* TCP/UDP */
|
||||||
{"source-port", required_argument, 0, 'g'},
|
{"source-port", required_argument, 0, 'g'},
|
||||||
{"dest-port", required_argument, 0, 'p'},
|
{"dest-port", required_argument, 0, 'p'},
|
||||||
@@ -300,7 +300,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
|||||||
{"nsock-engine", required_argument, 0, 0},
|
{"nsock-engine", required_argument, 0, 0},
|
||||||
{"no-capture", no_argument, 0, 'N'},
|
{"no-capture", no_argument, 0, 'N'},
|
||||||
{"hide-sent", no_argument, 0, 'H'},
|
{"hide-sent", no_argument, 0, 'H'},
|
||||||
|
|
||||||
/* Output */
|
/* Output */
|
||||||
{"verbose", optional_argument, 0, 'v'},
|
{"verbose", optional_argument, 0, 'v'},
|
||||||
{"reduce-verbosity", optional_argument, 0, 'q'},
|
{"reduce-verbosity", optional_argument, 0, 'q'},
|
||||||
@@ -352,7 +352,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
|||||||
} else if (optcmp(long_options[option_index].name, "traceroute") == 0 ||
|
} else if (optcmp(long_options[option_index].name, "traceroute") == 0 ||
|
||||||
optcmp(long_options[option_index].name, "tr") == 0) {
|
optcmp(long_options[option_index].name, "tr") == 0) {
|
||||||
o.enableTraceroute();
|
o.enableTraceroute();
|
||||||
|
|
||||||
/* Now shortcuts that we support but that are not actual modes */
|
/* Now shortcuts that we support but that are not actual modes */
|
||||||
} else if (optcmp(long_options[option_index].name, "arp-request") == 0) {
|
} else if (optcmp(long_options[option_index].name, "arp-request") == 0) {
|
||||||
if( o.issetMode() && o.getMode()!=ARP)
|
if( o.issetMode() && o.getMode()!=ARP)
|
||||||
@@ -517,7 +517,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
|||||||
nping_fatal(QT_3, "Invalid TCP flag supplied (%c). If you want to specify flags using a number you must add prefix \"0x\"", optarg[f]);
|
nping_fatal(QT_3, "Invalid TCP flag supplied (%c). If you want to specify flags using a number you must add prefix \"0x\"", optarg[f]);
|
||||||
else
|
else
|
||||||
nping_fatal(QT_3, "Invalid TCP flag supplied: %c", optarg[f]);
|
nping_fatal(QT_3, "Invalid TCP flag supplied: %c", optarg[f]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -833,7 +833,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
|||||||
nping_fatal(QT_3,"IPv6 Flow Label must be a number between 0 and 1048575");
|
nping_fatal(QT_3,"IPv6 Flow Label must be a number between 0 and 1048575");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* PACKET PAYLOAD OPTIONS ***************************************************/
|
/* PACKET PAYLOAD OPTIONS ***************************************************/
|
||||||
/* Hexadecimal payload specification */
|
/* Hexadecimal payload specification */
|
||||||
} else if (optcmp(long_options[option_index].name, "data") == 0 ){
|
} else if (optcmp(long_options[option_index].name, "data") == 0 ){
|
||||||
@@ -977,7 +977,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
|||||||
case '4': /* IPv4 */
|
case '4': /* IPv4 */
|
||||||
o.setIPVersion(IP_VERSION_4);
|
o.setIPVersion(IP_VERSION_4);
|
||||||
break; /* case '4': */
|
break; /* case '4': */
|
||||||
|
|
||||||
case '6': /* IPv6 */
|
case '6': /* IPv6 */
|
||||||
o.setIPVersion(IP_VERSION_6);
|
o.setIPVersion(IP_VERSION_6);
|
||||||
break; /* case '6': */
|
break; /* case '6': */
|
||||||
@@ -1049,7 +1049,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
|||||||
printUsage();
|
printUsage();
|
||||||
exit(1);
|
exit(1);
|
||||||
break; /* case 'h': */
|
break; /* case 'h': */
|
||||||
|
|
||||||
case 'h': /* Help */
|
case 'h': /* Help */
|
||||||
printUsage();
|
printUsage();
|
||||||
exit(0);
|
exit(0);
|
||||||
@@ -1138,7 +1138,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
|||||||
o.increaseVerbosity();
|
o.increaseVerbosity();
|
||||||
}
|
}
|
||||||
break; /* case 'v': */
|
break; /* case 'v': */
|
||||||
|
|
||||||
case 'q': /* Reduce verbosity */
|
case 'q': /* Reduce verbosity */
|
||||||
if (optarg){
|
if (optarg){
|
||||||
if (isdigit(optarg[0])){
|
if (isdigit(optarg[0])){
|
||||||
@@ -1835,12 +1835,12 @@ int ArgParser::atoEtherType(char *opt, u16 *type){
|
|||||||
|
|
||||||
|
|
||||||
int ArgParser::parseICMPTimestamp(char *optarg, u32 *dst){
|
int ArgParser::parseICMPTimestamp(char *optarg, u32 *dst){
|
||||||
|
|
||||||
long diff=0;
|
long diff=0;
|
||||||
|
|
||||||
if(optarg==NULL || dst==NULL)
|
if(optarg==NULL || dst==NULL)
|
||||||
nping_fatal(QT_3, "parseICMPTimestamp(): NULL pointer supplied.");
|
nping_fatal(QT_3, "parseICMPTimestamp(): NULL pointer supplied.");
|
||||||
|
|
||||||
if( meansRandom(optarg) ){
|
if( meansRandom(optarg) ){
|
||||||
while( (*dst=get_random_u32()) == 0);
|
while( (*dst=get_random_u32()) == 0);
|
||||||
}
|
}
|
||||||
@@ -1875,6 +1875,6 @@ long diff=0;
|
|||||||
else
|
else
|
||||||
*dst=diff;
|
*dst=diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OP_SUCCESS;
|
return OP_SUCCESS;
|
||||||
} /* End of parseICMPTimestamp() */
|
} /* End of parseICMPTimestamp() */
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ u8 *Crypto::deriveKey(const u8 *from, size_t fromlen, size_t *final_len){
|
|||||||
nping_print(DBG_4, "%s()", __func__);
|
nping_print(DBG_4, "%s()", __func__);
|
||||||
if(from==NULL || fromlen==0)
|
if(from==NULL || fromlen==0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#ifdef HAVE_OPENSSL
|
#ifdef HAVE_OPENSSL
|
||||||
if( o.doCrypto() ){
|
if( o.doCrypto() ){
|
||||||
static u8 hash[MAX(SHA256_HASH_LEN, EVP_MAX_MD_SIZE)];
|
static u8 hash[MAX(SHA256_HASH_LEN, EVP_MAX_MD_SIZE)];
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ int EchoClient::nep_connect(NpingTarget *target, u16 port){
|
|||||||
struct sockaddr_in *s4=(struct sockaddr_in *)&ss;
|
struct sockaddr_in *s4=(struct sockaddr_in *)&ss;
|
||||||
struct sockaddr_in6 *s6=(struct sockaddr_in6 *)&ss;
|
struct sockaddr_in6 *s6=(struct sockaddr_in6 *)&ss;
|
||||||
enum nsock_loopstatus loopstatus;
|
enum nsock_loopstatus loopstatus;
|
||||||
|
|
||||||
if(target==NULL)
|
if(target==NULL)
|
||||||
nping_fatal(QT_3, "nep_connect(): NULL parameter supplied.");
|
nping_fatal(QT_3, "nep_connect(): NULL parameter supplied.");
|
||||||
else
|
else
|
||||||
@@ -279,7 +279,7 @@ int EchoClient::nep_handshake(){
|
|||||||
nping_print(DBG_4, "%s()", __func__);
|
nping_print(DBG_4, "%s()", __func__);
|
||||||
enum nsock_loopstatus loopstatus;
|
enum nsock_loopstatus loopstatus;
|
||||||
EchoHeader h;
|
EchoHeader h;
|
||||||
|
|
||||||
/* Receive NEP_HANDSHAKE_SERVER message */
|
/* Receive NEP_HANDSHAKE_SERVER message */
|
||||||
nsock_readbytes(this->nsp, this->nsi, recv_hs_server_handler, ECHO_READ_TIMEOUT, NULL, NEP_HANDSHAKE_SERVER_LEN);
|
nsock_readbytes(this->nsp, this->nsi, recv_hs_server_handler, ECHO_READ_TIMEOUT, NULL, NEP_HANDSHAKE_SERVER_LEN);
|
||||||
loopstatus=nsock_loop(this->nsp, ECHO_READ_TIMEOUT-1);
|
loopstatus=nsock_loop(this->nsp, ECHO_READ_TIMEOUT-1);
|
||||||
@@ -313,7 +313,7 @@ int EchoClient::nep_handshake(){
|
|||||||
loopstatus=nsock_loop(this->nsp, ECHO_READ_TIMEOUT-1);
|
loopstatus=nsock_loop(this->nsp, ECHO_READ_TIMEOUT-1);
|
||||||
if(loopstatus!=NSOCK_LOOP_QUIT)
|
if(loopstatus!=NSOCK_LOOP_QUIT)
|
||||||
return OP_FAILURE;
|
return OP_FAILURE;
|
||||||
|
|
||||||
nping_print(DBG_1, "===NEP Handshake completed successfully===");
|
nping_print(DBG_1, "===NEP Handshake completed successfully===");
|
||||||
return OP_SUCCESS;
|
return OP_SUCCESS;
|
||||||
} /* End of nep_handshake() */
|
} /* End of nep_handshake() */
|
||||||
@@ -735,7 +735,7 @@ int EchoClient::generate_packet_spec(EchoHeader *h){
|
|||||||
h->setTimestamp();
|
h->setTimestamp();
|
||||||
h->setIPVersion( o.getIPVersion()==AF_INET6 ? 0x06: 0x04 );
|
h->setIPVersion( o.getIPVersion()==AF_INET6 ? 0x06: 0x04 );
|
||||||
h->setPacketCount( (o.getPacketCount()>0xFFFF) ? 0xFFFF : o.getPacketCount() );
|
h->setPacketCount( (o.getPacketCount()>0xFFFF) ? 0xFFFF : o.getPacketCount() );
|
||||||
|
|
||||||
/** Insert packet field specifiers */
|
/** Insert packet field specifiers */
|
||||||
if(o.ipv6()){ /* AF_INET6 */
|
if(o.ipv6()){ /* AF_INET6 */
|
||||||
/* Traffic class */
|
/* Traffic class */
|
||||||
@@ -858,7 +858,7 @@ int EchoClient::nep_echoed_packet_handler(nsock_pool nsp, nsock_event nse, void
|
|||||||
}
|
}
|
||||||
return OP_FAILURE;
|
return OP_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the remaining data */
|
/* Read the remaining data */
|
||||||
if( (recvbuff=(u8 *)nse_readbuf(nse, &recvbytes))==NULL ){
|
if( (recvbuff=(u8 *)nse_readbuf(nse, &recvbytes))==NULL ){
|
||||||
nping_print(DBG_4,"nep_echoed_packet_handler(): nse_readbuf failed!\n");
|
nping_print(DBG_4,"nep_echoed_packet_handler(): nse_readbuf failed!\n");
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ class EchoClient {
|
|||||||
ProbeMode probe;
|
ProbeMode probe;
|
||||||
u8 lasthdr[MAX_NEP_PACKET_LENGTH];
|
u8 lasthdr[MAX_NEP_PACKET_LENGTH];
|
||||||
size_t readbytes;
|
size_t readbytes;
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
int nep_connect(NpingTarget *target, u16 port);
|
int nep_connect(NpingTarget *target, u16 port);
|
||||||
int nep_handshake();
|
int nep_handshake();
|
||||||
|
|||||||
@@ -476,7 +476,7 @@ int EchoHeader::setClientNonce(u8 *nonce){
|
|||||||
case TYPE_NEP_HANDSHAKE_FINAL:
|
case TYPE_NEP_HANDSHAKE_FINAL:
|
||||||
memcpy(this->data_hsfinal->client_nonce , nonce, NONCE_LEN);
|
memcpy(this->data_hsfinal->client_nonce , nonce, NONCE_LEN);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return OP_FAILURE;
|
return OP_FAILURE;
|
||||||
break;
|
break;
|
||||||
@@ -594,7 +594,7 @@ u8 EchoHeader::getIPVersion(){
|
|||||||
case TYPE_NEP_PACKET_SPEC:
|
case TYPE_NEP_PACKET_SPEC:
|
||||||
return this->data_pspec->ip_version;
|
return this->data_pspec->ip_version;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0xAB;
|
return 0xAB;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -192,7 +192,7 @@
|
|||||||
#define DLT_NODATALINKHEADERINCLUDED 0x0000
|
#define DLT_NODATALINKHEADERINCLUDED 0x0000
|
||||||
|
|
||||||
/* GENERAL FORMAT:
|
/* GENERAL FORMAT:
|
||||||
|
|
||||||
0 1 2 3
|
0 1 2 3
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
@@ -325,21 +325,21 @@ class EchoHeader : public ApplicationLayerElement {
|
|||||||
|
|
||||||
int setVersion(u8 val);
|
int setVersion(u8 val);
|
||||||
u8 getVersion();
|
u8 getVersion();
|
||||||
|
|
||||||
int setMessageType(u8 val);
|
int setMessageType(u8 val);
|
||||||
u8 getMessageType();
|
u8 getMessageType();
|
||||||
|
|
||||||
int setTotalLength(u16 val);
|
int setTotalLength(u16 val);
|
||||||
int setTotalLength();
|
int setTotalLength();
|
||||||
u16 getTotalLength();
|
u16 getTotalLength();
|
||||||
|
|
||||||
int setSequenceNumber(u32 val);
|
int setSequenceNumber(u32 val);
|
||||||
u32 getSequenceNumber();
|
u32 getSequenceNumber();
|
||||||
|
|
||||||
int setTimestamp(u32 val);
|
int setTimestamp(u32 val);
|
||||||
int setTimestamp();
|
int setTimestamp();
|
||||||
u32 getTimestamp();
|
u32 getTimestamp();
|
||||||
|
|
||||||
int setReserved(u32 val);
|
int setReserved(u32 val);
|
||||||
u32 getReserved();
|
u32 getReserved();
|
||||||
|
|
||||||
|
|||||||
@@ -134,7 +134,7 @@
|
|||||||
|
|
||||||
extern NpingOps o;
|
extern NpingOps o;
|
||||||
extern EchoServer es;
|
extern EchoServer es;
|
||||||
|
|
||||||
EchoServer::EchoServer() {
|
EchoServer::EchoServer() {
|
||||||
this->reset();
|
this->reset();
|
||||||
} /* End of EchoServer constructor */
|
} /* End of EchoServer constructor */
|
||||||
@@ -265,7 +265,7 @@ int EchoServer::nep_listen_socket(){
|
|||||||
* this port in a previous execution, not long ago. */
|
* this port in a previous execution, not long ago. */
|
||||||
if( setsockopt(master_sd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int))!=0 )
|
if( setsockopt(master_sd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int))!=0 )
|
||||||
nping_warning(QT_3, "Failed to set SO_REUSEADDR on master socket.");
|
nping_warning(QT_3, "Failed to set SO_REUSEADDR on master socket.");
|
||||||
|
|
||||||
memset(&server_addr6, 0, sizeof(struct sockaddr_in6));
|
memset(&server_addr6, 0, sizeof(struct sockaddr_in6));
|
||||||
server_addr6.sin6_addr = (o.spoofSource()) ? o.getIPv6SourceAddress() : in6addr_any;
|
server_addr6.sin6_addr = (o.spoofSource()) ? o.getIPv6SourceAddress() : in6addr_any;
|
||||||
server_addr6.sin6_family = AF_INET6;
|
server_addr6.sin6_family = AF_INET6;
|
||||||
@@ -297,7 +297,7 @@ int EchoServer::nep_listen_socket(){
|
|||||||
/* Obtain a regular TCP socket for IPv4 */
|
/* Obtain a regular TCP socket for IPv4 */
|
||||||
if( (master_sd=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))<0 )
|
if( (master_sd=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))<0 )
|
||||||
nping_fatal(QT_3, "Could not obtain AF_INET/SOCK_STREAM/IPPROTO_TCP socket");
|
nping_fatal(QT_3, "Could not obtain AF_INET/SOCK_STREAM/IPPROTO_TCP socket");
|
||||||
|
|
||||||
/* Set SO_REUSEADDR on socket so the bind does not fail if we had used
|
/* Set SO_REUSEADDR on socket so the bind does not fail if we had used
|
||||||
* this port in a previous execution, not long ago. */
|
* this port in a previous execution, not long ago. */
|
||||||
if( setsockopt(master_sd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int))!=0 )
|
if( setsockopt(master_sd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int))!=0 )
|
||||||
@@ -311,7 +311,7 @@ int EchoServer::nep_listen_socket(){
|
|||||||
#ifdef HAVE_SOCKADDR_IN_SIN_LEN
|
#ifdef HAVE_SOCKADDR_IN_SIN_LEN
|
||||||
server_addr4.sin_len = sizeof(struct sockaddr_in);
|
server_addr4.sin_len = sizeof(struct sockaddr_in);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Bind to local address and the specified port */
|
/* Bind to local address and the specified port */
|
||||||
if( bind(master_sd, (struct sockaddr *)&server_addr4, sizeof(server_addr4)) != 0 ){
|
if( bind(master_sd, (struct sockaddr *)&server_addr4, sizeof(server_addr4)) != 0 ){
|
||||||
nping_warning(QT_3, "Failed to bind to source address %s. Trying to bind to port %d...", IPtoa(server_addr4.sin_addr), port);
|
nping_warning(QT_3, "Failed to bind to source address %s. Trying to bind to port %d...", IPtoa(server_addr4.sin_addr), port);
|
||||||
@@ -584,7 +584,7 @@ clientid_t EchoServer::nep_match_headers(IPv4Header *ip4, IPv6Header *ip6, TCPHe
|
|||||||
minimum_score=MIN_ACCEPTABLE_SCORE_ICMP;
|
minimum_score=MIN_ACCEPTABLE_SCORE_ICMP;
|
||||||
else
|
else
|
||||||
minimum_score=10000;
|
minimum_score=10000;
|
||||||
|
|
||||||
/* Check if we managed to match packet and client */
|
/* Check if we managed to match packet and client */
|
||||||
if (candidate>=0 && candidate_score>=minimum_score){
|
if (candidate>=0 && candidate_score>=minimum_score){
|
||||||
nping_print(DBG_2, "%s() Packet matched successfully with client #%d", __func__, candidate);
|
nping_print(DBG_2, "%s() Packet matched successfully with client #%d", __func__, candidate);
|
||||||
@@ -733,7 +733,7 @@ clientid_t EchoServer::nep_match_packet(const u8 *pkt, size_t pktlen){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return CLIENT_NOT_FOUND;
|
return CLIENT_NOT_FOUND;
|
||||||
break;
|
break;
|
||||||
@@ -1062,7 +1062,7 @@ int EchoServer::nep_packetspec_handler(nsock_pool nsp, nsock_event nse, void *pa
|
|||||||
/* At this point, we consider the NEP session fully established and therefore
|
/* At this point, we consider the NEP session fully established and therefore
|
||||||
* we update the count of served clients */
|
* we update the count of served clients */
|
||||||
o.stats.addEchoClientServed();
|
o.stats.addEchoClientServed();
|
||||||
|
|
||||||
return OP_SUCCESS;
|
return OP_SUCCESS;
|
||||||
} /* End of nep_packetspec_handler() */
|
} /* End of nep_packetspec_handler() */
|
||||||
|
|
||||||
@@ -1165,7 +1165,7 @@ int EchoServer::parse_hs_client(u8 *pkt, size_t pktlen, NEPContext *ctx){
|
|||||||
nping_print(DBG_3,"Session Key MAC_S2C:"); print_hexdump(DBG_3,ctx->getMacKeyS2C(), MAC_KEY_LEN);
|
nping_print(DBG_3,"Session Key MAC_S2C:"); print_hexdump(DBG_3,ctx->getMacKeyS2C(), MAC_KEY_LEN);
|
||||||
nping_print(DBG_3,"Session Key CIPHER_C2S:"); print_hexdump(DBG_3,ctx->getCipherKeyC2S(), MAC_KEY_LEN);
|
nping_print(DBG_3,"Session Key CIPHER_C2S:"); print_hexdump(DBG_3,ctx->getCipherKeyC2S(), MAC_KEY_LEN);
|
||||||
nping_print(DBG_3,"Session Key CIPHER_S2C:"); print_hexdump(DBG_3,ctx->getCipherKeyS2C(), MAC_KEY_LEN);
|
nping_print(DBG_3,"Session Key CIPHER_S2C:"); print_hexdump(DBG_3,ctx->getCipherKeyS2C(), MAC_KEY_LEN);
|
||||||
|
|
||||||
|
|
||||||
/* Decrypt the encrypted part of the message before validating the MAC */
|
/* Decrypt the encrypted part of the message before validating the MAC */
|
||||||
if((next_iv=h.decrypt(ctx->getCipherKeyC2S(), CIPHER_KEY_LEN, ctx->getClientNonce(), TYPE_NEP_HANDSHAKE_CLIENT))==NULL){
|
if((next_iv=h.decrypt(ctx->getCipherKeyC2S(), CIPHER_KEY_LEN, ctx->getClientNonce(), TYPE_NEP_HANDSHAKE_CLIENT))==NULL){
|
||||||
@@ -1366,7 +1366,7 @@ int EchoServer::generate_ready(EchoHeader *h, NEPContext *ctx){
|
|||||||
if( (next_iv=h->encrypt(ctx->getCipherKeyS2C(), CIPHER_KEY_LEN, ctx->getNextEncryptionIV()))==NULL )
|
if( (next_iv=h->encrypt(ctx->getCipherKeyS2C(), CIPHER_KEY_LEN, ctx->getNextEncryptionIV()))==NULL )
|
||||||
return OP_FAILURE;
|
return OP_FAILURE;
|
||||||
ctx->setNextEncryptionIV(next_iv);
|
ctx->setNextEncryptionIV(next_iv);
|
||||||
|
|
||||||
return OP_SUCCESS;
|
return OP_SUCCESS;
|
||||||
} /* End of generate_ready() */
|
} /* End of generate_ready() */
|
||||||
|
|
||||||
@@ -1392,7 +1392,7 @@ int EchoServer::generate_echo(EchoHeader *h, const u8 *pkt, size_t pktlen, NEPCo
|
|||||||
}else{
|
}else{
|
||||||
/* Determine where the application data starts */
|
/* Determine where the application data starts */
|
||||||
int offset=PacketParser::payload_offset(pkt, pktlen, false);
|
int offset=PacketParser::payload_offset(pkt, pktlen, false);
|
||||||
|
|
||||||
/* If the packet does not have application data, don't touch it */
|
/* If the packet does not have application data, don't touch it */
|
||||||
if(offset==0){
|
if(offset==0){
|
||||||
nping_print(DBG_3, "No payload found. Echoing the whole packet\n");
|
nping_print(DBG_3, "No payload found. Echoing the whole packet\n");
|
||||||
@@ -1459,7 +1459,7 @@ int EchoServer::start() {
|
|||||||
/* Create new IOD for pcap */
|
/* Create new IOD for pcap */
|
||||||
if ((pcap_nsi = nsi_new(nsp, NULL)) == NULL)
|
if ((pcap_nsi = nsi_new(nsp, NULL)) == NULL)
|
||||||
nping_fatal(QT_3, "Failed to create new nsock_iod. QUITTING.\n");
|
nping_fatal(QT_3, "Failed to create new nsock_iod. QUITTING.\n");
|
||||||
|
|
||||||
/* Open pcap */
|
/* Open pcap */
|
||||||
nping_print(DBG_2,"Opening pcap device %s", o.getDevice());
|
nping_print(DBG_2,"Opening pcap device %s", o.getDevice());
|
||||||
Strncpy(pcapdev, o.getDevice(), sizeof(pcapdev));
|
Strncpy(pcapdev, o.getDevice(), sizeof(pcapdev));
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ class EchoServer {
|
|||||||
int generate_hs_final(EchoHeader *h, NEPContext *ctx);
|
int generate_hs_final(EchoHeader *h, NEPContext *ctx);
|
||||||
int generate_ready(EchoHeader *h, NEPContext *ctx);
|
int generate_ready(EchoHeader *h, NEPContext *ctx);
|
||||||
int generate_echo(EchoHeader *h, const u8 *pkt, size_t pktlen, NEPContext *ctx);
|
int generate_echo(EchoHeader *h, const u8 *pkt, size_t pktlen, NEPContext *ctx);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EchoServer();
|
EchoServer();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* NEPContext.cc -- *
|
* NEPContext.cc -- *
|
||||||
* *
|
* *
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* NEPContext.cc -- *
|
* NEPContext.cc -- *
|
||||||
* *
|
* *
|
||||||
@@ -202,7 +202,7 @@ class NEPContext {
|
|||||||
struct sockaddr_storage clnt_addr;
|
struct sockaddr_storage clnt_addr;
|
||||||
|
|
||||||
u8 *generateKey(int key_type, size_t *final_len);
|
u8 *generateKey(int key_type, size_t *final_len);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NEPContext();
|
NEPContext();
|
||||||
@@ -260,7 +260,7 @@ class NEPContext {
|
|||||||
u8 *getCipherKeyS2C();
|
u8 *getCipherKeyS2C();
|
||||||
u8 *getCipherKeyS2C(size_t *final_len);
|
u8 *getCipherKeyS2C(size_t *final_len);
|
||||||
int generateCipherKeyS2C();
|
int generateCipherKeyS2C();
|
||||||
|
|
||||||
int generateClientNonce();
|
int generateClientNonce();
|
||||||
int generateServerNonce();
|
int generateServerNonce();
|
||||||
int setClientNonce(u8 *buff);
|
int setClientNonce(u8 *buff);
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ NpingOps::NpingOps() {
|
|||||||
|
|
||||||
memset(echo_passphrase, 0, sizeof(echo_passphrase));
|
memset(echo_passphrase, 0, sizeof(echo_passphrase));
|
||||||
echo_passphrase_set=false;
|
echo_passphrase_set=false;
|
||||||
|
|
||||||
memset(&last_sent_pkt_time, 0, sizeof(struct timeval));
|
memset(&last_sent_pkt_time, 0, sizeof(struct timeval));
|
||||||
|
|
||||||
delayed_rcvd_str=NULL;
|
delayed_rcvd_str=NULL;
|
||||||
@@ -2357,7 +2357,7 @@ if (this->havePcap()==false){
|
|||||||
else
|
else
|
||||||
this->setPacketCount( DEFAULT_PACKET_COUNT );
|
this->setPacketCount( DEFAULT_PACKET_COUNT );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if( !this->issetDelay() )
|
if( !this->issetDelay() )
|
||||||
this->setDelay( DEFAULT_DELAY );
|
this->setDelay( DEFAULT_DELAY );
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ class NpingOps {
|
|||||||
bool mode_set;
|
bool mode_set;
|
||||||
bool traceroute; /* Is traceroute mode enabled? */
|
bool traceroute; /* Is traceroute mode enabled? */
|
||||||
bool traceroute_set;
|
bool traceroute_set;
|
||||||
|
|
||||||
/* Output */
|
/* Output */
|
||||||
int vb; /* Current Verbosity level */
|
int vb; /* Current Verbosity level */
|
||||||
bool vb_set;
|
bool vb_set;
|
||||||
@@ -220,7 +220,7 @@ class NpingOps {
|
|||||||
/* Privileges */
|
/* Privileges */
|
||||||
bool isr00t; /* True if current user has root privs */
|
bool isr00t; /* True if current user has root privs */
|
||||||
bool isr00t_set;
|
bool isr00t_set;
|
||||||
|
|
||||||
/* Payloads */
|
/* Payloads */
|
||||||
int payload_type; /* Type of payload (RAND,HEX,FILE) */
|
int payload_type; /* Type of payload (RAND,HEX,FILE) */
|
||||||
bool payload_type_set;
|
bool payload_type_set;
|
||||||
@@ -228,11 +228,11 @@ class NpingOps {
|
|||||||
bool payload_buff_set;
|
bool payload_buff_set;
|
||||||
int payload_len; /* Length of payload */
|
int payload_len; /* Length of payload */
|
||||||
bool payload_len_set;
|
bool payload_len_set;
|
||||||
|
|
||||||
/* Roles */
|
/* Roles */
|
||||||
int role; /* Nping's role: normal|client|server. */
|
int role; /* Nping's role: normal|client|server. */
|
||||||
bool role_set;
|
bool role_set;
|
||||||
|
|
||||||
/* IPv4 */
|
/* IPv4 */
|
||||||
u8 ttl; /* IPv4 TTL / IPv6 Hop limit */
|
u8 ttl; /* IPv4 TTL / IPv6 Hop limit */
|
||||||
bool ttl_set;
|
bool ttl_set;
|
||||||
@@ -254,7 +254,7 @@ class NpingOps {
|
|||||||
bool ipv4_src_address_set;
|
bool ipv4_src_address_set;
|
||||||
char *ip_options; /* IP Options */
|
char *ip_options; /* IP Options */
|
||||||
bool ip_options_set;
|
bool ip_options_set;
|
||||||
|
|
||||||
/* IPv6 */
|
/* IPv6 */
|
||||||
u8 ipv6_tclass; /* Traffic Class */
|
u8 ipv6_tclass; /* Traffic Class */
|
||||||
bool ipv6_tclass_set;
|
bool ipv6_tclass_set;
|
||||||
@@ -262,7 +262,7 @@ class NpingOps {
|
|||||||
bool ipv6_flowlabel_set;
|
bool ipv6_flowlabel_set;
|
||||||
struct in6_addr ipv6_src_address; /**< Source IPv6 address */
|
struct in6_addr ipv6_src_address; /**< Source IPv6 address */
|
||||||
bool ipv6_src_address_set;
|
bool ipv6_src_address_set;
|
||||||
|
|
||||||
/* TCP / UDP */
|
/* TCP / UDP */
|
||||||
u16 *target_ports; /* Will point to an array of ports */
|
u16 *target_ports; /* Will point to an array of ports */
|
||||||
int tportcount; /* Total number of target ports */
|
int tportcount; /* Total number of target ports */
|
||||||
@@ -279,7 +279,7 @@ class NpingOps {
|
|||||||
bool tcpwin_set;
|
bool tcpwin_set;
|
||||||
bool badsum; /* Generate invalid TCP/UDP checksums? */
|
bool badsum; /* Generate invalid TCP/UDP checksums? */
|
||||||
bool badsum_set;
|
bool badsum_set;
|
||||||
|
|
||||||
/* ICMP */
|
/* ICMP */
|
||||||
u8 icmp_type; /* ICMP Type */
|
u8 icmp_type; /* ICMP Type */
|
||||||
bool icmp_type_set;
|
bool icmp_type_set;
|
||||||
@@ -308,7 +308,7 @@ class NpingOps {
|
|||||||
u32 icmp_advert_entry_pref[MAX_ICMP_ADVERT_ENTRIES];
|
u32 icmp_advert_entry_pref[MAX_ICMP_ADVERT_ENTRIES];
|
||||||
int icmp_advert_entry_count;
|
int icmp_advert_entry_count;
|
||||||
bool icmp_advert_entry_set;
|
bool icmp_advert_entry_set;
|
||||||
|
|
||||||
/* Ethernet */
|
/* Ethernet */
|
||||||
u8 src_mac[6]; /* Source MAC address */
|
u8 src_mac[6]; /* Source MAC address */
|
||||||
bool src_mac_set;
|
bool src_mac_set;
|
||||||
@@ -316,7 +316,7 @@ class NpingOps {
|
|||||||
bool dst_mac_set;
|
bool dst_mac_set;
|
||||||
u16 eth_type; /* EtherType field of the Ethernet frame */
|
u16 eth_type; /* EtherType field of the Ethernet frame */
|
||||||
bool eth_type_set;
|
bool eth_type_set;
|
||||||
|
|
||||||
/* ARP/RARP */
|
/* ARP/RARP */
|
||||||
u16 arp_htype; /* ARP Hardware type */
|
u16 arp_htype; /* ARP Hardware type */
|
||||||
bool arp_htype_set;
|
bool arp_htype_set;
|
||||||
@@ -336,7 +336,7 @@ class NpingOps {
|
|||||||
bool arp_spa_set;
|
bool arp_spa_set;
|
||||||
struct in_addr arp_tpa; /* ARP Target protocol address */
|
struct in_addr arp_tpa; /* ARP Target protocol address */
|
||||||
bool arp_tpa_set;
|
bool arp_tpa_set;
|
||||||
|
|
||||||
/* Echo mode */
|
/* Echo mode */
|
||||||
u16 echo_port; /* Echo port to listen or connect to */
|
u16 echo_port; /* Echo port to listen or connect to */
|
||||||
bool echo_port_set;
|
bool echo_port_set;
|
||||||
@@ -407,7 +407,7 @@ class NpingOps {
|
|||||||
bool issetSendPreference();
|
bool issetSendPreference();
|
||||||
bool sendPreferenceEthernet();
|
bool sendPreferenceEthernet();
|
||||||
bool sendPreferenceIP();
|
bool sendPreferenceIP();
|
||||||
|
|
||||||
int setSendEth(bool val);
|
int setSendEth(bool val);
|
||||||
bool sendEth();
|
bool sendEth();
|
||||||
bool issetSendEth();
|
bool issetSendEth();
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ int NpingTarget::getTargetSockAddr(struct sockaddr_storage *ss, size_t *ss_len)
|
|||||||
memcpy(ss, &targetsock, targetsocklen);
|
memcpy(ss, &targetsock, targetsocklen);
|
||||||
*ss_len = targetsocklen;
|
*ss_len = targetsocklen;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
} /* End of getTargetSockAddr() */
|
} /* End of getTargetSockAddr() */
|
||||||
|
|
||||||
|
|
||||||
@@ -952,7 +952,7 @@ int NpingTarget::setProbeRecvTCP(u16 sport, u16 dport){
|
|||||||
/* Update stats info */
|
/* Update stats info */
|
||||||
diff= TIMEVAL_SUBTRACT(this->sentprobes[i].recv, this->sentprobes[i].sent);
|
diff= TIMEVAL_SUBTRACT(this->sentprobes[i].recv, this->sentprobes[i].sent);
|
||||||
this->updateRTTs(diff);
|
this->updateRTTs(diff);
|
||||||
|
|
||||||
return OP_SUCCESS;
|
return OP_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,16 +163,16 @@ class NpingTarget {
|
|||||||
|
|
||||||
struct sockaddr_storage nexthopsock; /**< Next Hop address */
|
struct sockaddr_storage nexthopsock; /**< Next Hop address */
|
||||||
size_t nexthopsocklen;
|
size_t nexthopsocklen;
|
||||||
|
|
||||||
char targetipstring[INET6_ADDRSTRLEN];
|
char targetipstring[INET6_ADDRSTRLEN];
|
||||||
bool targetipstring_set;
|
bool targetipstring_set;
|
||||||
|
|
||||||
u8 MACaddress[6]; /**< Target MAC Address */
|
u8 MACaddress[6]; /**< Target MAC Address */
|
||||||
bool MACaddress_set;
|
bool MACaddress_set;
|
||||||
|
|
||||||
u8 SrcMACaddress[6]; /**< Source MAC Address */
|
u8 SrcMACaddress[6]; /**< Source MAC Address */
|
||||||
bool SrcMACaddress_set;
|
bool SrcMACaddress_set;
|
||||||
|
|
||||||
u8 NextHopMACaddress[6]; /**< Next Hop MAC Address */
|
u8 NextHopMACaddress[6]; /**< Next Hop MAC Address */
|
||||||
bool NextHopMACaddress_set;
|
bool NextHopMACaddress_set;
|
||||||
|
|
||||||
@@ -190,13 +190,13 @@ class NpingTarget {
|
|||||||
void Initialize();
|
void Initialize();
|
||||||
void FreeInternal();
|
void FreeInternal();
|
||||||
void generateIPString();
|
void generateIPString();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NpingTarget();
|
NpingTarget();
|
||||||
~NpingTarget();
|
~NpingTarget();
|
||||||
void Recycle();
|
void Recycle();
|
||||||
|
|
||||||
/* Target IP address */
|
/* Target IP address */
|
||||||
int getTargetSockAddr(struct sockaddr_storage *ss, size_t *ss_len);
|
int getTargetSockAddr(struct sockaddr_storage *ss, size_t *ss_len);
|
||||||
int setTargetSockAddr(struct sockaddr_storage *ss, size_t ss_len);
|
int setTargetSockAddr(struct sockaddr_storage *ss, size_t ss_len);
|
||||||
@@ -205,7 +205,7 @@ class NpingTarget {
|
|||||||
struct in6_addr getIPv6Address();
|
struct in6_addr getIPv6Address();
|
||||||
const struct in6_addr *getIPv6Address_aux();
|
const struct in6_addr *getIPv6Address_aux();
|
||||||
u8 *getIPv6Address_u8();
|
u8 *getIPv6Address_u8();
|
||||||
|
|
||||||
/* Source address used to reach the target */
|
/* Source address used to reach the target */
|
||||||
int getSourceSockAddr(struct sockaddr_storage *ss, size_t *ss_len);
|
int getSourceSockAddr(struct sockaddr_storage *ss, size_t *ss_len);
|
||||||
int setSourceSockAddr(struct sockaddr_storage *ss, size_t ss_len);
|
int setSourceSockAddr(struct sockaddr_storage *ss, size_t ss_len);
|
||||||
@@ -219,7 +219,7 @@ class NpingTarget {
|
|||||||
struct in6_addr getIPv6SourceAddress();
|
struct in6_addr getIPv6SourceAddress();
|
||||||
const struct in6_addr *getIPv6SourceAddress_aux();
|
const struct in6_addr *getIPv6SourceAddress_aux();
|
||||||
u8 *getIPv6SourceAddress_u8();
|
u8 *getIPv6SourceAddress_u8();
|
||||||
|
|
||||||
/* Info about host proximity */
|
/* Info about host proximity */
|
||||||
void setDirectlyConnected(bool connected);
|
void setDirectlyConnected(bool connected);
|
||||||
bool isDirectlyConnected();
|
bool isDirectlyConnected();
|
||||||
@@ -236,7 +236,7 @@ class NpingTarget {
|
|||||||
const u8 *getMACAddress();
|
const u8 *getMACAddress();
|
||||||
bool determineNextHopMACAddress();
|
bool determineNextHopMACAddress();
|
||||||
bool determineTargetMACAddress();
|
bool determineTargetMACAddress();
|
||||||
|
|
||||||
/* Source MAC address */
|
/* Source MAC address */
|
||||||
int setSrcMACAddress(const u8 *addy);
|
int setSrcMACAddress(const u8 *addy);
|
||||||
const u8 *getSrcMACAddress();
|
const u8 *getSrcMACAddress();
|
||||||
@@ -247,7 +247,7 @@ class NpingTarget {
|
|||||||
const char *getDeviceFullName();
|
const char *getDeviceFullName();
|
||||||
int setDeviceType(devtype type);
|
int setDeviceType(devtype type);
|
||||||
devtype getDeviceType();
|
devtype getDeviceType();
|
||||||
|
|
||||||
/* Resolved Host name */
|
/* Resolved Host name */
|
||||||
const char *getResolvedHostName();
|
const char *getResolvedHostName();
|
||||||
void setResolvedHostName(char *name);
|
void setResolvedHostName(char *name);
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ int NpingTargets::processSpecs(){
|
|||||||
size_t slen=0;
|
size_t slen=0;
|
||||||
bool result=false;
|
bool result=false;
|
||||||
struct route_nfo rnfo;
|
struct route_nfo rnfo;
|
||||||
|
|
||||||
memset(&ss, 0, sizeof(struct sockaddr_storage));
|
memset(&ss, 0, sizeof(struct sockaddr_storage));
|
||||||
memset(buff, 0, MAX_NPING_HOSTNAME_LEN+1);
|
memset(buff, 0, MAX_NPING_HOSTNAME_LEN+1);
|
||||||
|
|
||||||
@@ -332,7 +332,7 @@ int NpingTargets::processSpecs(){
|
|||||||
if( o.spoofSource() ){
|
if( o.spoofSource() ){
|
||||||
mytarget->setSpoofedSourceSockAddr( o.getSourceSockAddr(), sizeof(struct sockaddr_storage));
|
mytarget->setSpoofedSourceSockAddr( o.getSourceSockAddr(), sizeof(struct sockaddr_storage));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Network interface */
|
/* Network interface */
|
||||||
mytarget->setDeviceNames( rnfo.ii.devname, rnfo.ii.devfullname );
|
mytarget->setDeviceNames( rnfo.ii.devname, rnfo.ii.devfullname );
|
||||||
mytarget->setDeviceType( rnfo.ii.device_type );
|
mytarget->setDeviceType( rnfo.ii.device_type );
|
||||||
@@ -359,7 +359,7 @@ int NpingTargets::processSpecs(){
|
|||||||
s6->sin6_family=AF_INET6;
|
s6->sin6_family=AF_INET6;
|
||||||
mytarget->setSourceSockAddr(&ss, sizeof(struct sockaddr_storage));
|
mytarget->setSourceSockAddr(&ss, sizeof(struct sockaddr_storage));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert current target into targets array */
|
/* Insert current target into targets array */
|
||||||
this->Targets.push_back(mytarget);
|
this->Targets.push_back(mytarget);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,7 @@
|
|||||||
* Nmap, and also available from https://svn.nmap.org/nmap/COPYING *
|
* Nmap, and also available from https://svn.nmap.org/nmap/COPYING *
|
||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "PacketDiff.h"
|
#include "PacketDiff.h"
|
||||||
#include "nping.h"
|
#include "nping.h"
|
||||||
|
|
||||||
|
|||||||
@@ -124,11 +124,11 @@
|
|||||||
#define __PACKETDIFF_H__ 1
|
#define __PACKETDIFF_H__ 1
|
||||||
|
|
||||||
#include "nping.h"
|
#include "nping.h"
|
||||||
|
|
||||||
class PacketDiff {
|
class PacketDiff {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/* Misc */
|
/* Misc */
|
||||||
|
|||||||
@@ -700,7 +700,7 @@ int ProbeMode::createIPv6(IPv6Header *i, PacketElement *next_element, const char
|
|||||||
i->setNextHeader(next_proto);
|
i->setNextHeader(next_proto);
|
||||||
i->setPayloadLength();
|
i->setPayloadLength();
|
||||||
i->setDestinationAddress( target->getIPv6Address_u8() );
|
i->setDestinationAddress( target->getIPv6Address_u8() );
|
||||||
|
|
||||||
/* Hop Limit */
|
/* Hop Limit */
|
||||||
if ( o.issetTraceroute() ){
|
if ( o.issetTraceroute() ){
|
||||||
i->setHopLimit( o.getCurrentRound() );
|
i->setHopLimit( o.getCurrentRound() );
|
||||||
@@ -1689,7 +1689,7 @@ void ProbeMode::probe_nping_event_handler(nsock_pool nsp, nsock_event nse, void
|
|||||||
|
|
||||||
/* Read a packet */
|
/* Read a packet */
|
||||||
nse_readpcap(nse, &link, &linklen, &packet, &packetlen, NULL, &pcaptime);
|
nse_readpcap(nse, &link, &linklen, &packet, &packetlen, NULL, &pcaptime);
|
||||||
|
|
||||||
/* If we are on a Ethernet network, extract the next packet protocol
|
/* If we are on a Ethernet network, extract the next packet protocol
|
||||||
* from the Ethernet frame. */
|
* from the Ethernet frame. */
|
||||||
if( nsi_pcap_linktype(nsi) == DLT_EN10MB ){
|
if( nsi_pcap_linktype(nsi) == DLT_EN10MB ){
|
||||||
@@ -1726,7 +1726,7 @@ void ProbeMode::probe_nping_event_handler(nsock_pool nsp, nsock_event nse, void
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Packet is IP */
|
/* Packet is IP */
|
||||||
if(ip){
|
if(ip){
|
||||||
getPacketStrInfo("IP",(const u8*)packet, packetlen, buffer, 512);
|
getPacketStrInfo("IP",(const u8*)packet, packetlen, buffer, 512);
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ class ProbeMode {
|
|||||||
|
|
||||||
nsock_pool nsp; /**< Internal Nsock pool */
|
nsock_pool nsp; /**< Internal Nsock pool */
|
||||||
bool nsock_init; /**< True if nsock pool has been initialized */
|
bool nsock_init; /**< True if nsock pool has been initialized */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ProbeMode();
|
ProbeMode();
|
||||||
@@ -172,7 +172,7 @@ class ProbeMode {
|
|||||||
int start();
|
int start();
|
||||||
int cleanup();
|
int cleanup();
|
||||||
nsock_pool getNsockPool();
|
nsock_pool getNsockPool();
|
||||||
|
|
||||||
static int createIPv4(IPv4Header *i, PacketElement *next_element, const char *next_proto, NpingTarget *target);
|
static int createIPv4(IPv4Header *i, PacketElement *next_element, const char *next_proto, NpingTarget *target);
|
||||||
static int createIPv6(IPv6Header *i, PacketElement *next_element, const char *next_proto, NpingTarget *target);
|
static int createIPv6(IPv6Header *i, PacketElement *next_element, const char *next_proto, NpingTarget *target);
|
||||||
static int doIPv6ThroughSocket(int rawfd);
|
static int doIPv6ThroughSocket(int rawfd);
|
||||||
|
|||||||
@@ -833,7 +833,7 @@ if( !addr || !dev )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
} /* End of devname2ipaddr() */
|
} /* End of devname2ipaddr() */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ int main(int argc, char *argv[] ){
|
|||||||
o.displayNpingDoneMsg();
|
o.displayNpingDoneMsg();
|
||||||
o.cleanup();
|
o.cleanup();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
} /* End of main() */
|
} /* End of main() */
|
||||||
|
|
||||||
|
|||||||
@@ -432,7 +432,7 @@
|
|||||||
#define PAYLOAD_ECHO_BYTES_IN_DOUBT 40
|
#define PAYLOAD_ECHO_BYTES_IN_DOUBT 40
|
||||||
|
|
||||||
#define NSOCK_INFINITE -1
|
#define NSOCK_INFINITE -1
|
||||||
|
|
||||||
/* Prototypes for nping.cc shared functions */
|
/* Prototypes for nping.cc shared functions */
|
||||||
char *getBPFFilterString();
|
char *getBPFFilterString();
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ int nping_fatal(int level, const char *str, ...) {
|
|||||||
return OP_SUCCESS;
|
return OP_SUCCESS;
|
||||||
if( level>=DBG_0 && level<=DBG_9 && level>current_dbg_level )
|
if( level>=DBG_0 && level<=DBG_9 && level>current_dbg_level )
|
||||||
return OP_SUCCESS;
|
return OP_SUCCESS;
|
||||||
|
|
||||||
|
|
||||||
if ( (level>=QT_3 && level<=VB_4) || (level>=DBG_1 && level<=DBG_9) ){
|
if ( (level>=QT_3 && level<=VB_4) || (level>=DBG_1 && level<=DBG_9) ){
|
||||||
vfprintf(stderr, str, list);
|
vfprintf(stderr, str, list);
|
||||||
@@ -189,7 +189,7 @@ int nping_warning(int level, const char *str, ...) {
|
|||||||
|
|
||||||
int current_vb_level= o.getVerbosity();
|
int current_vb_level= o.getVerbosity();
|
||||||
int current_dbg_level= o.getDebugging();
|
int current_dbg_level= o.getDebugging();
|
||||||
|
|
||||||
/* Determine if caller requested that we don't print a newline character */
|
/* Determine if caller requested that we don't print a newline character */
|
||||||
if ( level & NO_NEWLINE ){
|
if ( level & NO_NEWLINE ){
|
||||||
level ^= NO_NEWLINE; /* Unset the flag restoring the original level */
|
level ^= NO_NEWLINE; /* Unset the flag restoring the original level */
|
||||||
@@ -201,7 +201,7 @@ int nping_warning(int level, const char *str, ...) {
|
|||||||
return OP_SUCCESS;
|
return OP_SUCCESS;
|
||||||
if( level>=DBG_0 && level<=DBG_9 && level>current_dbg_level )
|
if( level>=DBG_0 && level<=DBG_9 && level>current_dbg_level )
|
||||||
return OP_SUCCESS;
|
return OP_SUCCESS;
|
||||||
|
|
||||||
/* Otherwise, print the info to stderr*/
|
/* Otherwise, print the info to stderr*/
|
||||||
if ( (level>=QT_3 && level<=VB_4) || (level>=DBG_1 && level<=DBG_9) ){
|
if ( (level>=QT_3 && level<=VB_4) || (level>=DBG_1 && level<=DBG_9) ){
|
||||||
vfprintf(stderr, str, list); /* Print to stderr */
|
vfprintf(stderr, str, list); /* Print to stderr */
|
||||||
@@ -230,7 +230,7 @@ int nping_print(int level, const char *str, ...){
|
|||||||
|
|
||||||
int current_vb_level= o.getVerbosity();
|
int current_vb_level= o.getVerbosity();
|
||||||
int current_dbg_level= o.getDebugging();
|
int current_dbg_level= o.getDebugging();
|
||||||
|
|
||||||
/* Determine if caller requested that we don't print a newline character */
|
/* Determine if caller requested that we don't print a newline character */
|
||||||
if ( level & NO_NEWLINE ){
|
if ( level & NO_NEWLINE ){
|
||||||
level ^= NO_NEWLINE; /* Unset the flag restoring the original level */
|
level ^= NO_NEWLINE; /* Unset the flag restoring the original level */
|
||||||
@@ -242,7 +242,7 @@ int nping_print(int level, const char *str, ...){
|
|||||||
return OP_SUCCESS;
|
return OP_SUCCESS;
|
||||||
if( level>=DBG_0 && level<=DBG_9 && level>current_dbg_level )
|
if( level>=DBG_0 && level<=DBG_9 && level>current_dbg_level )
|
||||||
return OP_SUCCESS;
|
return OP_SUCCESS;
|
||||||
|
|
||||||
/* Otherwise, print the info to stderr*/
|
/* Otherwise, print the info to stderr*/
|
||||||
if ( (level>=QT_3 && level<=VB_4) || (level>=DBG_1 && level<=DBG_9) ){
|
if ( (level>=QT_3 && level<=VB_4) || (level>=DBG_1 && level<=DBG_9) ){
|
||||||
vfprintf(stdout, str, list); /* Print to stderr */
|
vfprintf(stdout, str, list); /* Print to stderr */
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ class NpingTimer {
|
|||||||
double elapsed(struct timeval *now=NULL);
|
double elapsed(struct timeval *now=NULL);
|
||||||
bool is_started();
|
bool is_started();
|
||||||
bool is_stopped();
|
bool is_stopped();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool timeval_set(const struct timeval *tv);
|
bool timeval_set(const struct timeval *tv);
|
||||||
@@ -236,7 +236,7 @@ class NpingStats {
|
|||||||
|
|
||||||
int startRxClock();
|
int startRxClock();
|
||||||
int stopRxClock();
|
int stopRxClock();
|
||||||
|
|
||||||
int startRuntime();
|
int startRuntime();
|
||||||
int stopRuntime();
|
int stopRuntime();
|
||||||
|
|
||||||
|
|||||||
@@ -596,7 +596,7 @@ int resolveCached(char *host, struct sockaddr_storage *ss, size_t *sslen, int pf
|
|||||||
|
|
||||||
if( ss==NULL || sslen==NULL || host==NULL)
|
if( ss==NULL || sslen==NULL || host==NULL)
|
||||||
nping_fatal(QT_3, "resolveCached(): NULL values supplied");
|
nping_fatal(QT_3, "resolveCached(): NULL values supplied");
|
||||||
|
|
||||||
/* First we check if we have the host already cached */
|
/* First we check if we have the host already cached */
|
||||||
for(int i=0; i<MAX_CACHED_HOSTS && i<cached_count; i++){
|
for(int i=0; i<MAX_CACHED_HOSTS && i<cached_count; i++){
|
||||||
if( !strcasecmp( archive[i].hostname , host ) ){ /* Cache hit */
|
if( !strcasecmp( archive[i].hostname , host ) ){ /* Cache hit */
|
||||||
@@ -613,18 +613,18 @@ int resolveCached(char *host, struct sockaddr_storage *ss, size_t *sslen, int pf
|
|||||||
nping_print(DBG_4, "resolveCached(): Cache miss %d for %s\n", misses, host);
|
nping_print(DBG_4, "resolveCached(): Cache miss %d for %s\n", misses, host);
|
||||||
|
|
||||||
if( (result=resolve(host, 0, ss, sslen, pf)) == 0 ){
|
if( (result=resolve(host, 0, ss, sslen, pf)) == 0 ){
|
||||||
|
|
||||||
/* Increment count */
|
/* Increment count */
|
||||||
if( cached_count < MAX_CACHED_HOSTS )
|
if( cached_count < MAX_CACHED_HOSTS )
|
||||||
cached_count++;
|
cached_count++;
|
||||||
|
|
||||||
/* Store info */
|
/* Store info */
|
||||||
memset(&(archive[current_index]), 0, sizeof(cached_host_t) );
|
memset(&(archive[current_index]), 0, sizeof(cached_host_t) );
|
||||||
strncpy(archive[current_index].hostname, host, MAX_CACHED_HOSTNAME_LEN);
|
strncpy(archive[current_index].hostname, host, MAX_CACHED_HOSTNAME_LEN);
|
||||||
archive[current_index].sslen = *sslen;
|
archive[current_index].sslen = *sslen;
|
||||||
memcpy(&(archive[current_index].ss), ss, *sslen);
|
memcpy(&(archive[current_index].ss), ss, *sslen);
|
||||||
|
|
||||||
|
|
||||||
/* 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 likely 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
|
||||||
@@ -635,9 +635,9 @@ int resolveCached(char *host, struct sockaddr_storage *ss, size_t *sslen, int pf
|
|||||||
if( current_index < MAX_CACHED_HOSTS-1 )
|
if( current_index < MAX_CACHED_HOSTS-1 )
|
||||||
current_index++;
|
current_index++;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///* Watch out for the overflow. If cache is full, */
|
///* Watch out for the overflow. If cache is full, */
|
||||||
//if( cached_count == MAX_CACHED_HOSTS ){
|
//if( cached_count == MAX_CACHED_HOSTS ){
|
||||||
//if( way%2==1 ){
|
//if( way%2==1 ){
|
||||||
@@ -660,7 +660,7 @@ int resolveCached(char *host, struct sockaddr_storage *ss, size_t *sslen, int pf
|
|||||||
//else
|
//else
|
||||||
//current_index++;
|
//current_index++;
|
||||||
//return OP_SUCCESS;
|
//return OP_SUCCESS;
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
nping_warning(QT_2, "Error resolving %s\n",host);
|
nping_warning(QT_2, "Error resolving %s\n",host);
|
||||||
return OP_FAILURE;
|
return OP_FAILURE;
|
||||||
@@ -699,7 +699,7 @@ struct hostent *gethostbynameCached(char *host){
|
|||||||
nping_print(DBG_4, "gethostbynameCached(): Cache miss %d for %s", misses, host);
|
nping_print(DBG_4, "gethostbynameCached(): Cache miss %d for %s", misses, host);
|
||||||
|
|
||||||
if( (result=gethostbyname(host) ) != NULL ){
|
if( (result=gethostbyname(host) ) != NULL ){
|
||||||
|
|
||||||
/* Increment cache entry count */
|
/* Increment cache entry count */
|
||||||
if( cached_count < MAX_CACHED_HOSTS )
|
if( cached_count < MAX_CACHED_HOSTS )
|
||||||
cached_count++;
|
cached_count++;
|
||||||
@@ -709,7 +709,7 @@ struct hostent *gethostbynameCached(char *host){
|
|||||||
* one in its place */
|
* one in its place */
|
||||||
if ( current_index==MAX_CACHED_HOSTS-1 && archive[current_index].h != NULL )
|
if ( current_index==MAX_CACHED_HOSTS-1 && archive[current_index].h != NULL )
|
||||||
hostentfree( archive[current_index].h );
|
hostentfree( archive[current_index].h );
|
||||||
|
|
||||||
/* Store the hostent entry in the cache */
|
/* Store the hostent entry in the cache */
|
||||||
memset(&(archive[current_index]), 0, sizeof(gethostbynamecached_t) );
|
memset(&(archive[current_index]), 0, sizeof(gethostbynamecached_t) );
|
||||||
strncpy(archive[current_index].hostname, host, MAX_CACHED_HOSTNAME_LEN);
|
strncpy(archive[current_index].hostname, host, MAX_CACHED_HOSTNAME_LEN);
|
||||||
@@ -723,7 +723,7 @@ struct hostent *gethostbynameCached(char *host){
|
|||||||
else{
|
else{
|
||||||
return archive[current_index].h;
|
return archive[current_index].h;
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -961,7 +961,7 @@ int tcppackethdrinfo(const u8 *packet, size_t len, u8 *dstbuff, size_t dstlen,
|
|||||||
struct sockaddr_in6 *d6=(struct sockaddr_in6 *)dst;
|
struct sockaddr_in6 *d6=(struct sockaddr_in6 *)dst;
|
||||||
char srcipstring[128];
|
char srcipstring[128];
|
||||||
char dstipstring[128];
|
char dstipstring[128];
|
||||||
|
|
||||||
assert(packet);
|
assert(packet);
|
||||||
assert(dstbuff);
|
assert(dstbuff);
|
||||||
assert(len>=20);
|
assert(len>=20);
|
||||||
@@ -972,7 +972,7 @@ int tcppackethdrinfo(const u8 *packet, size_t len, u8 *dstbuff, size_t dstlen,
|
|||||||
if( detail!=LOW_DETAIL && detail!=MEDIUM_DETAIL && detail!=HIGH_DETAIL)
|
if( detail!=LOW_DETAIL && detail!=MEDIUM_DETAIL && detail!=HIGH_DETAIL)
|
||||||
detail=LOW_DETAIL;
|
detail=LOW_DETAIL;
|
||||||
|
|
||||||
|
|
||||||
/* Determine target IP address */
|
/* Determine target IP address */
|
||||||
if(src!=NULL){
|
if(src!=NULL){
|
||||||
if( s4->sin_family==AF_INET ){
|
if( s4->sin_family==AF_INET ){
|
||||||
@@ -1059,7 +1059,7 @@ int tcppackethdrinfo(const u8 *packet, size_t len, u8 *dstbuff, size_t dstlen,
|
|||||||
strncpy((char*)dstbuff, protoinfo, dstlen);
|
strncpy((char*)dstbuff, protoinfo, dstlen);
|
||||||
|
|
||||||
return OP_SUCCESS;
|
return OP_SUCCESS;
|
||||||
|
|
||||||
} /* End of tcppackethdrinfo() */
|
} /* End of tcppackethdrinfo() */
|
||||||
|
|
||||||
|
|
||||||
@@ -1076,7 +1076,7 @@ int udppackethdrinfo(const u8 *packet, size_t len, u8 *dstbuff, size_t dstlen,
|
|||||||
struct sockaddr_in6 *d6=(struct sockaddr_in6 *)dst;
|
struct sockaddr_in6 *d6=(struct sockaddr_in6 *)dst;
|
||||||
char srcipstring[128];
|
char srcipstring[128];
|
||||||
char dstipstring[128];
|
char dstipstring[128];
|
||||||
|
|
||||||
assert(packet);
|
assert(packet);
|
||||||
assert(dstbuff);
|
assert(dstbuff);
|
||||||
assert(len>=8);
|
assert(len>=8);
|
||||||
@@ -1087,7 +1087,7 @@ int udppackethdrinfo(const u8 *packet, size_t len, u8 *dstbuff, size_t dstlen,
|
|||||||
if( detail!=LOW_DETAIL && detail!=MEDIUM_DETAIL && detail!=HIGH_DETAIL)
|
if( detail!=LOW_DETAIL && detail!=MEDIUM_DETAIL && detail!=HIGH_DETAIL)
|
||||||
detail=LOW_DETAIL;
|
detail=LOW_DETAIL;
|
||||||
|
|
||||||
|
|
||||||
/* Determine target IP address */
|
/* Determine target IP address */
|
||||||
if(src!=NULL){
|
if(src!=NULL){
|
||||||
if( s4->sin_family==AF_INET ){
|
if( s4->sin_family==AF_INET ){
|
||||||
@@ -1131,7 +1131,7 @@ int udppackethdrinfo(const u8 *packet, size_t len, u8 *dstbuff, size_t dstlen,
|
|||||||
strncpy((char*)dstbuff, protoinfo, dstlen);
|
strncpy((char*)dstbuff, protoinfo, dstlen);
|
||||||
|
|
||||||
return OP_SUCCESS;
|
return OP_SUCCESS;
|
||||||
|
|
||||||
} /* End of udppackethdrinfo() */
|
} /* End of udppackethdrinfo() */
|
||||||
|
|
||||||
|
|
||||||
@@ -1352,7 +1352,7 @@ u8 *getTCPheaderLocation(u8 *pkt, size_t pktLen){
|
|||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
} /* End of getTCPHeaderLocation() */
|
} /* End of getTCPHeaderLocation() */
|
||||||
|
|
||||||
|
|
||||||
@@ -1395,7 +1395,7 @@ u16 *getSrcPortFromIPPacket(u8 *pkt, size_t pktLen){
|
|||||||
if((header=getTCPheaderLocation(pkt, pktLen))==NULL){
|
if((header=getTCPheaderLocation(pkt, pktLen))==NULL){
|
||||||
if ((header=getUDPheaderLocation(pkt, pktLen))==NULL)
|
if ((header=getUDPheaderLocation(pkt, pktLen))==NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
pnt=(u16*)&(header[0]);
|
pnt=(u16*)&(header[0]);
|
||||||
port= ntohs(*pnt);
|
port= ntohs(*pnt);
|
||||||
@@ -1458,24 +1458,24 @@ int obtainRawSocket(){
|
|||||||
|
|
||||||
if( o.ipv6() ){
|
if( o.ipv6() ){
|
||||||
switch( o.getMode() ){
|
switch( o.getMode() ){
|
||||||
|
|
||||||
case TCP:
|
case TCP:
|
||||||
protocol = IPPROTO_TCP;
|
protocol = IPPROTO_TCP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UDP:
|
case UDP:
|
||||||
protocol = IPPROTO_UDP;
|
protocol = IPPROTO_UDP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ICMP:
|
case ICMP:
|
||||||
protocol = IPPROTO_ICMPV6;
|
protocol = IPPROTO_ICMPV6;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARP:
|
case ARP:
|
||||||
nping_warning(QT_2,"Warning: createRawSocket() should not be called in ARP mode.");
|
nping_warning(QT_2,"Warning: createRawSocket() should not be called in ARP mode.");
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
nping_fatal(QT_3, "createRawSocket(): NpingOps::getMode() does not return a valid mode. Please report this bug.");
|
nping_fatal(QT_3, "createRawSocket(): NpingOps::getMode() does not return a valid mode. Please report this bug.");
|
||||||
break;
|
break;
|
||||||
@@ -1541,7 +1541,7 @@ int getinterfaces_inet6_linux(if6_t *ifbuf, int max_ifaces){
|
|||||||
|
|
||||||
if(ifbuf==NULL || max_ifaces<=0)
|
if(ifbuf==NULL || max_ifaces<=0)
|
||||||
nping_fatal(QT_3,"getinterfaces_inet6_linux() NULL values supplied");
|
nping_fatal(QT_3,"getinterfaces_inet6_linux() NULL values supplied");
|
||||||
|
|
||||||
/* TODO: Do we fatal() or should we just error and return OP_FAILURE? */
|
/* TODO: Do we fatal() or should we just error and return OP_FAILURE? */
|
||||||
if ( !file_is_readable(PATH_PROC_IFINET6) )
|
if ( !file_is_readable(PATH_PROC_IFINET6) )
|
||||||
nping_fatal(QT_3, "Couldn't get IPv6 interface information. File %s does not exist or you don't have read permissions.", PATH_PROC_IFINET6);
|
nping_fatal(QT_3, "Couldn't get IPv6 interface information. File %s does not exist or you don't have read permissions.", PATH_PROC_IFINET6);
|
||||||
@@ -1677,7 +1677,7 @@ int getinterfaces_inet6_linux(if6_t *ifbuf, int max_ifaces){
|
|||||||
printf(" %02x", dev_flags);
|
printf(" %02x", dev_flags);
|
||||||
printf(" %8s\n", devname);
|
printf(" %8s\n", devname);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
} /* End of loop */
|
} /* End of loop */
|
||||||
|
|
||||||
/* Cleanup */
|
/* Cleanup */
|
||||||
@@ -1735,7 +1735,7 @@ int getroutes_inet6_linux(route6_t *rtbuf, int max_routes){
|
|||||||
|
|
||||||
if(rtbuf==NULL || max_routes<=0)
|
if(rtbuf==NULL || max_routes<=0)
|
||||||
nping_fatal(QT_3,"getroutes_inet6_linux() NULL values supplied");
|
nping_fatal(QT_3,"getroutes_inet6_linux() NULL values supplied");
|
||||||
|
|
||||||
/* TODO: Do we fatal() or should we just error and return OP_FAILURE? */
|
/* TODO: Do we fatal() or should we just error and return OP_FAILURE? */
|
||||||
if ( !file_is_readable(PATH_PROC_IPV6ROUTE) )
|
if ( !file_is_readable(PATH_PROC_IPV6ROUTE) )
|
||||||
nping_fatal(QT_3, "Couldn't get IPv6 route information. File %s does not exist or you don't have read permissions.", PATH_PROC_IPV6ROUTE);
|
nping_fatal(QT_3, "Couldn't get IPv6 route information. File %s does not exist or you don't have read permissions.", PATH_PROC_IPV6ROUTE);
|
||||||
@@ -1757,7 +1757,7 @@ int getroutes_inet6_linux(route6_t *rtbuf, int max_routes){
|
|||||||
* 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?
|
||||||
* If they can, then we need to change the code to skip the last : */
|
* If they can, then we need to change the code to skip the last : */
|
||||||
removecolon(buffer);
|
removecolon(buffer);
|
||||||
|
|
||||||
/* 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 */
|
||||||
@@ -1908,12 +1908,12 @@ int getroutes_inet6_linux(route6_t *rtbuf, int max_routes){
|
|||||||
*
|
*
|
||||||
for(i=0; i<16; i++)
|
for(i=0; i<16; i++)
|
||||||
printf("%02x", rtbuf[parsed_routes].dst_net.s6_addr[i]);
|
printf("%02x", rtbuf[parsed_routes].dst_net.s6_addr[i]);
|
||||||
|
|
||||||
printf(" %02x ", rtbuf[parsed_routes].dst_prefix);
|
printf(" %02x ", rtbuf[parsed_routes].dst_prefix);
|
||||||
|
|
||||||
for(i=0; i<16; i++)
|
for(i=0; i<16; i++)
|
||||||
printf("%02x", rtbuf[parsed_routes].src_net.s6_addr[i]);
|
printf("%02x", rtbuf[parsed_routes].src_net.s6_addr[i]);
|
||||||
|
|
||||||
printf(" %02x ", rtbuf[parsed_routes].src_prefix);
|
printf(" %02x ", rtbuf[parsed_routes].src_prefix);
|
||||||
|
|
||||||
for(i=0; i<16; i++)
|
for(i=0; i<16; i++)
|
||||||
@@ -1926,7 +1926,7 @@ int getroutes_inet6_linux(route6_t *rtbuf, int max_routes){
|
|||||||
printf(" %8s\n", rtbuf[parsed_routes].devname);
|
printf(" %8s\n", rtbuf[parsed_routes].devname);
|
||||||
*/
|
*/
|
||||||
parsed_routes++;
|
parsed_routes++;
|
||||||
|
|
||||||
} /* End of loop */
|
} /* End of loop */
|
||||||
|
|
||||||
/* Cleanup */
|
/* Cleanup */
|
||||||
@@ -1958,7 +1958,7 @@ route6_t *route_dst_ipv6_linux(const struct sockaddr_storage *const dst){
|
|||||||
u8 zero_addr[16]; /* Just to compare route to addr "::" */
|
u8 zero_addr[16]; /* Just to compare route to addr "::" */
|
||||||
memset(zero_addr, 0, 16);
|
memset(zero_addr, 0, 16);
|
||||||
dstsin6=(struct sockaddr_in6 *)dst;
|
dstsin6=(struct sockaddr_in6 *)dst;
|
||||||
|
|
||||||
if(dst==NULL) return NULL;
|
if(dst==NULL) return NULL;
|
||||||
if(dstsin6->sin6_family!=AF_INET6) return NULL;
|
if(dstsin6->sin6_family!=AF_INET6) return NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -399,6 +399,6 @@ LUALIB_API int luaopen_pcrelib(lua_State *L)
|
|||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
luaL_newlib(L, pcrelib);
|
luaL_newlib(L, pcrelib);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -491,7 +491,7 @@ int l_get_ssl_certificate(lua_State *L)
|
|||||||
static int l_ssl_cert_index(lua_State *L)
|
static int l_ssl_cert_index(lua_State *L)
|
||||||
{
|
{
|
||||||
struct cert_userdata *udata;
|
struct cert_userdata *udata;
|
||||||
|
|
||||||
udata = (struct cert_userdata *) luaL_checkudata(L, 1, "SSL_CERT");
|
udata = (struct cert_userdata *) luaL_checkudata(L, 1, "SSL_CERT");
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, udata->attributes_table);
|
lua_rawgeti(L, LUA_REGISTRYINDEX, udata->attributes_table);
|
||||||
/* The key. */
|
/* The key. */
|
||||||
@@ -505,7 +505,7 @@ static int l_ssl_cert_index(lua_State *L)
|
|||||||
static int l_ssl_cert_gc(lua_State *L)
|
static int l_ssl_cert_gc(lua_State *L)
|
||||||
{
|
{
|
||||||
struct cert_userdata *udata;
|
struct cert_userdata *udata;
|
||||||
|
|
||||||
udata = (struct cert_userdata *) luaL_checkudata(L, 1, "SSL_CERT");
|
udata = (struct cert_userdata *) luaL_checkudata(L, 1, "SSL_CERT");
|
||||||
X509_free(udata->cert);
|
X509_free(udata->cert);
|
||||||
luaL_unref(L, LUA_REGISTRYINDEX, udata->attributes_table);
|
luaL_unref(L, LUA_REGISTRYINDEX, udata->attributes_table);
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ class OFProbe {
|
|||||||
class HostOsScanStats {
|
class HostOsScanStats {
|
||||||
|
|
||||||
friend class HostOsScan;
|
friend class HostOsScan;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HostOsScanStats(Target *t);
|
HostOsScanStats(Target *t);
|
||||||
~HostOsScanStats();
|
~HostOsScanStats();
|
||||||
@@ -528,7 +528,7 @@ class OSScan {
|
|||||||
int chunk_and_do_scan(std::vector<Target *> &Targets, int family);
|
int chunk_and_do_scan(std::vector<Target *> &Targets, int family);
|
||||||
int os_scan_ipv4(std::vector<Target *> &Targets);
|
int os_scan_ipv4(std::vector<Target *> &Targets);
|
||||||
int os_scan_ipv6(std::vector<Target *> &Targets);
|
int os_scan_ipv6(std::vector<Target *> &Targets);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OSScan();
|
OSScan();
|
||||||
~OSScan();
|
~OSScan();
|
||||||
|
|||||||
@@ -500,7 +500,7 @@ void print_state_summary(PortList *Ports, unsigned short type) {
|
|||||||
|
|
||||||
states = state_summary_size(reason_head);
|
states = state_summary_size(reason_head);
|
||||||
currentr = reason_head;
|
currentr = reason_head;
|
||||||
|
|
||||||
while(currentr != NULL) {
|
while(currentr != NULL) {
|
||||||
if(states == 1 && (!first_time))
|
if(states == 1 && (!first_time))
|
||||||
separator = " and ";
|
separator = " and ";
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ static int nmap_protocols_init() {
|
|||||||
o.loaded_data_files["nmap-protocols"] = filename;
|
o.loaded_data_files["nmap-protocols"] = filename;
|
||||||
|
|
||||||
memset(protocol_table, 0, sizeof(protocol_table));
|
memset(protocol_table, 0, sizeof(protocol_table));
|
||||||
|
|
||||||
while(fgets(line, sizeof(line), fp)) {
|
while(fgets(line, sizeof(line), fp)) {
|
||||||
lineno++;
|
lineno++;
|
||||||
p = line;
|
p = line;
|
||||||
|
|||||||
12
services.cc
12
services.cc
@@ -234,7 +234,7 @@ static int nmap_services_init() {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
res = sscanf(line, "%127s %hu/%15s %31s", servicename, &portno, proto, ratio_str);
|
res = sscanf(line, "%127s %hu/%15s %31s", servicename, &portno, proto, ratio_str);
|
||||||
|
|
||||||
if (res == 3) {
|
if (res == 3) {
|
||||||
ratio = 0;
|
ratio = 0;
|
||||||
} else if (res == 4) {
|
} else if (res == 4) {
|
||||||
@@ -245,13 +245,13 @@ static int nmap_services_init() {
|
|||||||
|
|
||||||
if (ratio_n < 0 || ratio_d < 0)
|
if (ratio_n < 0 || ratio_d < 0)
|
||||||
fatal("%s:%d contains an invalid negative value", filename, lineno);
|
fatal("%s:%d contains an invalid negative value", filename, lineno);
|
||||||
|
|
||||||
if (ratio_n > ratio_d)
|
if (ratio_n > ratio_d)
|
||||||
fatal("%s:%d has a ratio %g. All ratios must be < 1", filename, lineno, (double)ratio_n/ratio_d);
|
fatal("%s:%d has a ratio %g. All ratios must be < 1", filename, lineno, (double)ratio_n/ratio_d);
|
||||||
|
|
||||||
if (ratio_d == 0)
|
if (ratio_d == 0)
|
||||||
fatal("%s:%d has a ratio denominator of 0 causing a division by 0 error", filename, lineno);
|
fatal("%s:%d has a ratio denominator of 0 causing a division by 0 error", filename, lineno);
|
||||||
|
|
||||||
ratio = (double)ratio_n / ratio_d;
|
ratio = (double)ratio_n / ratio_d;
|
||||||
ratio_format = 1;
|
ratio_format = 1;
|
||||||
} else if (strncmp(ratio_str, "0.", 2) == 0) {
|
} else if (strncmp(ratio_str, "0.", 2) == 0) {
|
||||||
@@ -325,7 +325,7 @@ void free_services() {
|
|||||||
services_initialized = 0;
|
services_initialized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Adds ports whose names match mask and one or more protocols
|
/* Adds ports whose names match mask and one or more protocols
|
||||||
* specified by range_type to porttbl. Increases the respective
|
* specified by range_type to porttbl. Increases the respective
|
||||||
* protocol counts in ports.
|
* protocol counts in ports.
|
||||||
@@ -338,7 +338,7 @@ int addportsfromservmask(char *mask, u8 *porttbl, int range_type) {
|
|||||||
|
|
||||||
if (!services_initialized && nmap_services_init() == -1)
|
if (!services_initialized && nmap_services_init() == -1)
|
||||||
fatal("%s: Couldn't get port numbers", __func__);
|
fatal("%s: Couldn't get port numbers", __func__);
|
||||||
|
|
||||||
for (i = service_table.begin(); i != service_table.end(); i++) {
|
for (i = service_table.begin(); i != service_table.end(); i++) {
|
||||||
service_node& current = i->second;
|
service_node& current = i->second;
|
||||||
if (wildtest(mask, current.s_name)) {
|
if (wildtest(mask, current.s_name)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user