Skip to content
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

More nmap features #3

Open
vesche opened this issue Aug 16, 2018 · 5 comments
Open

More nmap features #3

vesche opened this issue Aug 16, 2018 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@vesche
Copy link
Contributor

vesche commented Aug 16, 2018

  • UDP scanning
  • Service scan
  • Top 1000 ports
  • Scanning multiple IP's / subnet
@vesche vesche added the enhancement New feature or request label Aug 16, 2018
@vesche vesche self-assigned this Aug 16, 2018
@vesche
Copy link
Contributor Author

vesche commented Sep 19, 2018

Emulating UDP scanning is more difficult than I thought. Because of its connection-less nature, you need to send something over UDP and then wait for a response... The problem is if you don't send something valid it typically won't respond. This means that UDP would need to send service-specific requests. That's not something I want to support.

Anyways for documentation purposes, this is the general idea:

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
socket.setdefaulttimeout(0.5)
s.sendto(b'DATA', (ip, port))
recv, svr = s.recv(4096)
print(recv, svr)

The problem is that sending something like DATA won't get a response. If this was a DNS server, sending a DNS request would work however.

Also, a balanced timeout with select would need to implemented in the above approach. Something like this: https://stackoverflow.com/a/2721734 The problem again is that if the right service request is not sent, nothing will come back.

My way forward on this is to first look at how nmap does this, and then if there is not a good solution to document the infeasibility of supporting UDP port scanning in a project this size- and only support TCP port scanning.

@vesche
Copy link
Contributor Author

vesche commented Sep 19, 2018

Also, calling this module nmap is probably a rip... I'll rename this portscanner or something generic in the next release.

@deadPix3l
Copy link
Contributor

deadPix3l commented Sep 19, 2018

Definitely not a solution for all the ports you have listed in ports.py, but if we cut that down to maybe 10 or so common UDP ports, we can turn it into a dict that holds a valid input for the suspected service. DNS specifically is a simple protocol.

udp_ports = { 53: "AA\x01\0\0\x01\0\0\0\0\0\0\x07example\x03com\0\0\x01\0\x01" }

@vesche
Copy link
Contributor Author

vesche commented Sep 20, 2018

This means that UDP would need to send service-specific requests. That's not something I want to support.

That's exactly what I don't want to do. A DNS server can easily not run on 53/udp, and are we really going to craft payloads for every UDP service? Is this actually how nmap does it...? If so, sounds like it's time to make custom UDP socket listeners for c2 callback that are impenetrable to port scanners lol.

@deadPix3l
Copy link
Contributor

yea I know. Just wanted to put out a maybe semi solution

UDP scan works by sending a UDP packet to every targeted port. For some common ports such as 53 and 161, a protocol-specific payload is sent to increase response rate, but for most ports the packet is empty unless the --data, --data-string, or --data-length options are specified. If an ICMP port unreachable error (type 3, code 3) is returned, the port is closed. Other ICMP unreachable errors (type 3, codes 0, 1, 2, 9, 10, or 13) mark the port as filtered. Occasionally, a service will respond with a UDP packet, proving that it is open. If no response is received after retransmissions, the port is classified as open|filtered. This means that the port could be open, or perhaps packet filters are blocking the communication. Version detection (-sV) can be used to help differentiate the truly open ports from the filtered ones.

Unless you want to write a complicated ICMP listener I think we're cooked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants