Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
masscan
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
masscan
Commits
6e664453
Commit
6e664453
authored
7 years ago
by
Robert David Graham
Browse files
Options
Downloads
Patches
Plain Diff
--top-ports
parent
51ccbd2a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main-conf.c
+48
-1
48 additions, 1 deletion
src/main-conf.c
src/masscan.h
+6
-0
6 additions, 0 deletions
src/masscan.h
with
54 additions
and
1 deletion
src/main-conf.c
+
48
−
1
View file @
6e664453
...
...
@@ -986,6 +986,20 @@ config_top_ports(struct Masscan *masscan, unsigned n)
}
}
int
isInteger
(
const
char
*
value
)
{
size_t
i
;
if
(
value
==
NULL
)
return
0
;
for
(
i
=
0
;
value
[
i
];
i
++
)
if
(
!
isdigit
(
value
[
i
]
&
0xFF
))
return
0
;
return
1
;
}
/***************************************************************************
* Called either from the "command-line" parser when it sees a --parm,
* or from the "config-file" parser for normal options.
...
...
@@ -1798,7 +1812,10 @@ masscan_set_parameter(struct Masscan *masscan,
exit
(
1
);
}
else
if
(
EQUALS
(
"top-ports"
,
name
))
{
unsigned
n
=
(
unsigned
)
parseInt
(
value
);
config_top_ports
(
masscan
,
n
);
if
(
!
isInteger
(
value
))
n
=
100
;
LOG
(
2
,
"top-ports = %u
\n
"
,
n
);
masscan
->
top_ports
=
n
;
}
else
if
(
EQUALS
(
"traceroute"
,
name
))
{
fprintf
(
stderr
,
"nmap(%s): unsupported
\n
"
,
name
);
exit
(
1
);
...
...
@@ -1934,6 +1951,21 @@ masscan_command_line(struct Masscan *masscan, int argc, char *argv[])
if
(
argv
[
i
][
0
]
==
'-'
&&
argv
[
i
][
1
]
==
'-'
)
{
if
(
strcmp
(
argv
[
i
],
"--help"
)
==
0
)
{
masscan_help
();
}
else
if
(
EQUALS
(
"top-ports"
,
argv
[
i
]
+
2
))
{
/* special handling here since the following parameter
* is optional */
const
char
*
value
=
"1000"
;
unsigned
n
;
/* Only consume the next parameter if it's a number,
* otherwise default to 10000 */
if
(
i
+
1
<
argc
&&
isInteger
(
argv
[
i
+
1
]))
{
value
=
argv
[
++
i
];
}
n
=
(
unsigned
)
parseInt
(
value
);
LOG
(
2
,
"top-ports = %u
\n
"
,
n
);
masscan
->
top_ports
=
n
;
}
else
if
(
EQUALS
(
"readscan"
,
argv
[
i
]
+
2
))
{
/* Read in a binary file instead of scanning the network*/
masscan
->
op
=
Operation_ReadScan
;
...
...
@@ -2269,6 +2301,21 @@ masscan_command_line(struct Masscan *masscan, int argc, char *argv[])
*/
masscan_set_parameter
(
masscan
,
"range"
,
argv
[
i
]);
}
/*
* If no other "scan type" found, then default to TCP
*/
if
(
masscan
->
scan_type
.
udp
==
0
&&
masscan
->
scan_type
.
sctp
==
0
&&
masscan
->
scan_type
.
ping
==
0
&&
masscan
->
scan_type
.
arp
==
0
)
masscan
->
scan_type
.
tcp
=
1
;
/*
* If "top-ports" specified, then add all those ports. This may be in
* addition to any other ports
*/
if
(
masscan
->
top_ports
)
{
config_top_ports
(
masscan
,
masscan
->
top_ports
);
}
}
/***************************************************************************
...
...
This diff is collapsed.
Click to expand it.
src/masscan.h
+
6
−
0
View file @
6e664453
...
...
@@ -101,8 +101,14 @@ struct Masscan
unsigned
udp
:
1
;
unsigned
sctp
:
1
;
unsigned
ping
:
1
;
unsigned
arp
:
1
;
/*TODO*/
}
scan_type
;
/**
* After scan type has been configured, add these ports
*/
unsigned
top_ports
;
/**
* One or more network adapters that we'll use for scanning. Each adapter
* should have a separate set of IP source addresses, except in the case
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment