mirror of
https://github.com/nmap/nmap.git
synced 2026-02-10 23:46:34 +00:00
Added a function to check if port specification will do anything. Changed over my logic to use this new functioni. (scan_mode_uses_target_ports)
This commit is contained in:
@@ -1537,6 +1537,10 @@ bool NpingOps::issetTargetPorts(){
|
||||
return this->target_ports_set;
|
||||
} /* End of issetTargetPorts() */
|
||||
|
||||
/*Returns true if the scan type can use the -p option*/
|
||||
bool NpingOps::scan_mode_uses_target_ports(int mode){
|
||||
return (mode==TCP_CONNECT || mode==TCP || mode == UDP || mode == UDP_UNPRIV);
|
||||
} /*End of scan_mode_uses_target_ports*/
|
||||
|
||||
/** Sets TCP/UPD source port. Supplied parameter must be an integer >=0 &&
|
||||
* <=65535
|
||||
|
||||
@@ -327,6 +327,9 @@ class NpingOps {
|
||||
u16 *getTargetPorts( int *len );
|
||||
int setTargetPorts( u16 *pnt, int n );
|
||||
bool issetTargetPorts();
|
||||
bool scan_mode_uses_target_ports(int mode);
|
||||
|
||||
|
||||
|
||||
int setSourcePort(u16 val);
|
||||
u16 getSourcePort();
|
||||
|
||||
@@ -167,7 +167,7 @@ int main(int argc, char *argv[] ){
|
||||
* we should alert the user that their port command is going to be ignored
|
||||
* I choose to print out a Fatal error since the scan doesn't make sense.
|
||||
*/
|
||||
if(o.issetTargetPorts() && (o.getMode() != TCP || o.getMode() != UDP || o.getMode !=UDP_PRIV))
|
||||
if(o.issetTargetPorts() && !o.scan_mode_uses_target_ports(o.getMode()))
|
||||
outFatal(QT_3, "You cannot use -p (explicit port selection) in your current scan mode.\n(Perhaps you meant to use --tcp or --udp");
|
||||
|
||||
|
||||
@@ -228,7 +228,7 @@ int do_safe_checks(){
|
||||
test_stuff(); /* Little function that is called quite early to test some misc stuff. */
|
||||
return OP_SUCCESS;
|
||||
} /* End of do_safe_checks() */
|
||||
|
||||
//
|
||||
|
||||
|
||||
/** Use this function whenever you have some code that you want to test, but
|
||||
|
||||
Reference in New Issue
Block a user