-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add scan subnet functionality #4
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,9 +42,17 @@ defmodule Hades.NMAP do | |
Process.flag(:trap_exit, true) | ||
|
||
path = Helpers.hades_path() | ||
|
||
target_vector = String.splitter("#{target}", ["/"]) |> Enum.take(2) | ||
command = if (length(target_vector) == 2) do | ||
subnet = Enum.at(target_vector, 1) | ||
"nmap #{option} -oX #{path} #{target} / #{subnet}" | ||
else | ||
"nmap #{option} -oX #{path} #{target}" | ||
end | ||
|
||
port = | ||
Port.open({:spawn, "nmap #{option} -oX #{path} #{target}"}, [ | ||
Port.open({:spawn, command}, [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the code would look cleaner if you continue to use the old "structure" Another option that just came in my mind would be to build the target string in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree on making the code cleaner. Will work on this. |
||
:binary, | ||
:exit_status | ||
]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure why you first split the target and then stitch it back together without any checking.
It would be nice if you could include some test here to see if the subnet mask one specified is valid.