1
0
mirror of https://github.com/nmap/nmap.git synced 2026-02-10 15:36:33 +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:
sean
2012-08-04 01:08:31 +00:00
parent 256bffba9c
commit ce2f251cd5
3 changed files with 9 additions and 2 deletions

View File

@@ -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

View File

@@ -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();

View File

@@ -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