Hades v0.0.1 Hades.Helpers View Source
Provides some usefull functions for internal handling NMAP
outputs.
Link to this section Summary
Functions
With this function it is possible to validate given IP Adresses.
Reads hades output_path
from the config.
If there is nothing specified in the config then the default path will be returned.
Read hades timeout
from the config.
If unspecified, return the default timeout
which is currently 300_000
(corresponds to 5 minutes).
This timeout
is propagated to the function Task.await()
.
If the specified timeout
period is exceeded, it is assumed that the process running the NMAP command has timed out.
The timeout
is specified in ms
.
Macro used to generate the argument functions that are described inside
the Hades.Arguments
modules.
This functions parses the given file that is located at filepath
and
returns a map/0
filled with the hosts
and time
content that was saved
from NMAP
into the XML
file.
Prepares the command to be executed, by converting the %Command{}
into
proper parameters to be feeded to NMAP.
Checks if the given context is in the required ones.
Link to this section Functions
With this function it is possible to validate given IP Adresses.
Returns {:ok, ip_address}
if the given ip_address
was validated successfully.
Example
iex> Hades.Helpers.check_ip_address("192.168.120.1")
{:ok, "192.168.120.1"}
Reads hades output_path
from the config.
If there is nothing specified in the config then the default path will be returned.
Returns binary/0
.
Example
iex> Hades.Helpers.hades_path()
"/var/folders/c1/f0tm33sd3tgg_ds8kyhykyw80000gn/T/briefly-1581/hades-73279-791202-3hades/8b09d31e1a1142869ce8b15faf27ed45.xml"
Read hades timeout
from the config.
If unspecified, return the default timeout
which is currently 300_000
(corresponds to 5 minutes).
This timeout
is propagated to the function Task.await()
.
If the specified timeout
period is exceeded, it is assumed that the process running the NMAP command has timed out.
The timeout
is specified in ms
.
Returns integer/0
.
Example
iex> Hades.Helpers.hades_timeout()
300000
Macro used to generate the argument functions that are described inside
the Hades.Arguments
modules.
This functions parses the given file that is located at filepath
and
returns a map/0
filled with the hosts
and time
content that was saved
from NMAP
into the XML
file.
Returns map/0
.
Example
iex> Hades.Helpers.parse_xml("test/mocs/test.xml")
%{
hosts: [
%{hostname: "FelixsMACNCHEESEPRO.root.box", ip: "192.168.120.42", ports: []}
],
time: %{
elapsed: 0.03,
endstr: "Fri Feb 7 09:55:09 2020",
startstr: "Fri Feb 7 09:55:09 2020",
unix: 1581065709
}
}
Prepares the command to be executed, by converting the %Command{}
into
proper parameters to be feeded to NMAP.
Under normal circumstances Hades.scan/1
should be used, use prepare
only when converted args are needed.
Returns {nmap_args_string, the_aimed_target}
.
Example
iex> command = Hades.new_command()
...> |> Hades.add_argument(Hades.Arguments.ServiceVersionDetection.arg_sV())
...> |> Hades.add_argument(Hades.Arguments.ServiceVersionDetection.arg_version_all())
...> |> Hades.add_argument(Hades.Arguments.ScriptScan.arg_script("vulners"))
...> |> Hades.add_target("192.168.0.1")
iex> Hades.Helpers.prepare(command)
{"--script vulners --version-all -sV", "192.168.0.1"}
Checks if the given context is in the required ones.
Raises raise(ArgumentError)
if the given context is not in the required ones.
Examples
iex> Hades.Helpers.validate_contexts!(:option, [:scan_type, :option])
nil
iex> Hades.Helpers.validate_contexts!(:undefined, [:scan_type, :option])
** (ArgumentError) argument error