fklement / hades

A wrapper for NMAP written in Elixir.
https://hexdocs.pm/hades/
MIT License
26 stars 3 forks source link

Add scan subnet functionality #4

Open AlexJuca opened 4 years ago

AlexJuca commented 4 years ago

This feature contains the following changes:

1) Adds the capability to scan a given subnet 2) Updates README.md and added a section describing how to perform a subnet scan.

iex> Hades.new_command()
...> |> Hades.add_argument(Hades.Arguments.ScanTechniques.arg_sP())
...> |> Hades.add_target("192.168.120.42/24")
...> |> Hades.scan()
02:28:50.664 [info]  NMAP Output: "Starting Nmap 7.80 ( https://nmap.org ) at 2020-03-02 02:28 W. Central Africa Standard Time\r\n"

02:29:09.001 [info]  NMAP Output: "Nmap scan report for 192.168.100.1\r\n"

02:29:09.001 [info]  NMAP Output: "Host is up (0.00s latency).\r\nMAC Address: F8:75:88:9D:F9:B5 (Huawei Technologies)\r\n"

02:29:09.001 [info]  NMAP Output: "Nmap scan report for 192.168.100.2\r\n"

02:29:09.001 [info]  NMAP Output: "Host is up (0.047s latency).\r\nMAC Address: 78:31:C1:D0:87:8E (Apple)\r\n"

02:29:24.300 [info]  NMAP Output: "Nmap scan report for 192.168.100.3\r\n"

02:29:24.300 [info]  NMAP Output: "Host is up.\r\n"

02:29:26.568 [info]  NMAP Output: "Nmap done: 256 IP addresses (3 hosts up) scanned in 36.03 seconds\r\n"

02:29:26.584 [info]  Port exit: :exit_status: 0

02:29:26.584 [info]  DOWN message from port: #Port<0.83>
%{
  hosts: [
    %{hostname: "", ip: "192.168.100.1F8:75:88:9D:F9:B5", ports: []},
    %{hostname: "", ip: "192.168.100.278:31:C1:D0:87:8E", ports: []},
    %{hostname: "", ip: "192.168.100.3", ports: []}
  ],
  time: %{
    elapsed: 36.03,
    endstr: "Mon Mar 02 02:29:26 2020",
    unix: 1583112566
}
AlexJuca commented 4 years ago

@fklement I chose to use the same add_target/1 function to do the subnet scan. It would be intuitive for most nmap users to just add the "/24", "16" subnet at the end eg (add_target("192.168.100.1/24") instead of having add_target(ip, "/24").

matteing commented 3 years ago

Hey, any merge timeline on this?

AlexJuca commented 3 years ago

Hey, any merge timeline on this?

I have not had the time to work on the suggestions requested by @fklement but my fork does have a working implementation.