
Masscanned (Name natürlich von Masscan inspiriert) ist ein Netzwerk-Responder. Sein Zweck besteht darin, generische Antworten auf möglichst viele Protokolle und mit möglichst wenigen Annahmen über die Absichten des Kunden bereitzustellen.
Lass sie zuerst reden.
Genau wie Masscan implementiert Masscanned seinen eigenen Userland-Netzwerk-Stack, ähnlich wie Honeyd. Es ist darauf ausgelegt, so weit wie möglich mit Scannern und opportunistischen Bots zu interagieren und möglichst viele Protokolle zu unterstützen.
Wenn es beispielsweise Netzwerkpakete empfängt:
ARP who is-at mit ARP is-at (für seine IP-Adressen),ICMP Echo Request mit ICMP Echo Reply ,TCP SYN (beliebiger Port) mit TCP SYN/ACK auf jedem Port,HTTP Anfragen (beliebiges Verb) über TCP/UDP (beliebiger Port) mit einer HTTP 401 -Webseite. 
Massscanned unterstützt derzeit die gängigsten Protokolle auf den Schichten 2-3-4 sowie einige Anwendungsprotokolle.
$ cargo build
# ip netns add masscanned
# ip link add vethmasscanned type veth peer veth netns masscanned
# ip link set vethmasscanned up
# ip -n masscanned link set veth up
# ip addr add dev vethmasscanned 192.168.0.0/31
# ip netns exec masscanned ./target/debug/masscanned --iface veth -v[vv]
# arping 192.168.0.1
# ping 192.168.0.1
# nc -n -v 192.168.0.1 80
# nc -n -v -u 192.168.0.1 80
...
# apt install docker.io
$ cd masscanned/docker && docker build -t masscanned:test .
$ docker run --cap-add=NET_ADMIN masscanned:test
# arping 172.17.0.2
# ping 172.17.0.2
# nc -n -v 172.17.0.2 80
# nc -n -v -u 172.17.0.2 80
...
Eine gute Verwendung von Masscanned besteht darin, es auf einem VPS mit einer oder mehreren öffentlichen IP-Adressen bereitzustellen.
Um die Ergebnisse zu nutzen, ist es am besten, den gesamten Netzwerkverkehr auf der Schnittstelle zu erfassen , die masscanned abhört/reagiert. Die pcaps können dann mit zeek analysiert werden und die Ausgabedateien können typischerweise in einer Instanz von IVRE gepusht werden.
Eine Dokumentation zum Bereitstellen einer Masscanned -Instanz auf einem VPS ist in Kürze verfügbar (siehe Problem Nr. 2).
Network answering machine for various network protocols (L2-L3-L4 + applications)
Usage: masscanned [OPTIONS] --iface <iface>
Options:
-i, --iface <iface>
the interface to use for receiving/sending packets
-m, --mac-addr <mac>
MAC address to use in the response packets
--self-ip-file <selfipfile>
File with the list of IP addresses handled by masscanned
--self-ip-list <selfiplist>
Inline list of IP addresses handled by masscanned, comma-separated
--remote-ip-deny-file <remoteipdenyfile>
File with the list of IP addresses from which masscanned will ignore packets
--remote-ip-deny-list <remoteipdenylist>
Inline list of IP addresses from which masscanned will ignore packets
-v...
Increase message verbosity
-q, --quiet
Quiet mode: do not output anything on stdout
--format <format>
Format in which to output logs [default: console] [possible values: console, logfmt]
-h, --help
Print help information
-V, --version
Print version information
masscanned antwortet auf ARP Anfragen für Anfragen, die auf eine IPv4 -Adresse abzielen, die von masscanned verarbeitet wird ( d. h . eine Adresse, die in der mit der Option -f angegebenen IP-Adressdatei enthalten ist).
Die Antwort enthält die erste der folgenden möglichen MAC -Adressen:
-a in der Befehlszeile angegebene MAC -Adresse, falls vorhanden,MAC Adresse der mit -i in der Befehlszeile angegebenen Schnittstelle, falls vorhanden,masscanned Standard MAC Adresse, z . B. c0:ff:ee:c0:ff:ee . masscanned Antworten auf Ethernet Frames, genau dann, wenn die folgenden Anforderungen erfüllt sind:
Die Zieladresse des Frames sollte von masscanned verarbeitet werden, was bedeutet:
masscanned eigene MAC Adresse eingelesen,MAC ff:ff:ff:ff:ff:ffMAC -Adresse, die einer der von masscanned (RFC 1112) verarbeiteten IPv4 -Adressen entspricht,MAC -Adresse, die einer der von masscanned verarbeiteten IPv6 -Adressen entspricht; EtherType Feld ist eines von ARP , IPv4 oder IPv6 .
Hinweis: Auch bei einer Nicht-Multicast-IP-Adresse antwortet masscanned auf L2-Frames, die an die entsprechende Multicast MAC -Adresse adressiert sind. Wenn masscanned beispielsweise 10.11.12.13 verarbeitet, antwortet es auf Frames, die an 01:00:5e:0b:0c:0d adressiert sind.
masscanned Antworten auf IPv4 und IPv6 Pakete, nur wenn:
IP -Adresse angegeben ( d. h . es ist keine Option -f angegeben oder die Datei ist leer).oder
masscanned verarbeitet werden.Eine zusätzliche Voraussetzung ist, dass das Next-Layer-Protokoll unterstützt wird – siehe unten.
Die folgenden L3+/4-Protokolle werden für ein IPv4 Paket unterstützt:
ICMPv4UDPTCPWenn das Protokoll der nächsten Schicht nicht dazu gehört, wird das Paket verworfen.
Die folgenden L3+/4-Protokolle werden für ein IPv6 Paket unterstützt:
ICMPv6UDPTCPWenn das Protokoll der nächsten Schicht nicht dazu gehört, wird das Paket verworfen.
masscanned Antworten auf ICMPv4 Pakete genau dann, wenn:
ICMP Typ des eingehenden Pakets ist EchoRequest ( 8 ),ICMP Code des eingehenden Pakets ist 0 . Wenn diese Bedingungen erfüllt sind, werden masscanned Antworten mit einem ICMP Paket vom Typ EchoReply ( 0 ), Code 0 und derselben Nutzlast wie das eingehende Paket gemäß RFC 792 gesendet.
masscanned Antworten auf ICMPv6 Pakete genau dann, wenn:
ICMP Typ ist NeighborSol ( 135 ) und :masscanned wurde keine IP (v4 oder v6) angegebenmasscanned In diesem Fall ist die Antwort ein Neighbor Advertisement ( 136 )-Paket mit masscanned MAC -Adresse
oder
ICMP Typ ist EchoRequest ( 128 ) In diesem Fall ist die Antwort ein EchoReply Paket ( 129 ).
masscanned Antworten auf die folgenden TCP Pakete:
PSH und ACK hat, prüft masscanned das SYNACK-Cookie und antwortet, wenn gültig, mindestens mit einem ACK oder einem PSH-ACK , wenn ein unterstütztes Protokoll (Schicht 5/6/7) erkannt wurde.ACK hat, wird es ignoriert.RST oder FIN-ACK hat, wird es ignoriert.SYN hat, versucht masscanned das Verhalten eines Standard-Linux-Stacks zu imitieren – nämlich:PSH , URG , CWR oder ECE gehören, wird SYN ignoriert.CWR und ECE gleichzeitig gesetzt sind, wird SYN ignoriert.SYN-ACK Paket masscanned und ein SYNACK-Cookie in der Sequenznummer gesetzt. masscanned Antworten auf ein UDP -Paket genau dann, wenn das Protokoll der oberen Schicht verarbeitet wird und eine Antwort liefert.
masscanned Antworten auf jede HTTP Anfrage (jedes gültige Verb) mit einer 401 Authorization Required . Beachten Sie, dass HTTP Anfragen mit einem ungültigen Verb nicht beantwortet werden.
Beispiel:
$ curl -X GET 10.11.10.129
<html>
<head><title>401 Authorization Required</title></head>
<body bgcolor="white">
<center><h1>401 Authorization Required</h1></center>
<hr><center>nginx/1.14.2</center>
</body>
</html>
$ curl -X OPTIONS 10.11.10.129
<html>
<head><title>401 Authorization Required</title></head>
<body bgcolor="white">
<center><h1>401 Authorization Required</h1></center>
<hr><center>nginx/1.14.2</center>
</body>
</html>
$ curl -X HEAD 10.11.10.129
Warning: Setting custom HTTP method to HEAD with -X/--request may not work the
Warning: way you want. Consider using -I/--head instead.
<html>
<head><title>401 Authorization Required</title></head>
<body bgcolor="white">
<center><h1>401 Authorization Required</h1></center>
<hr><center>nginx/1.14.2</center>
</body>
</html>
$ curl -X XXX 10.11.10.129
[timeout]
Beispiel:
$ stun 10.11.10.129
STUN client version 0.97
Primary: Open
Return value is 0x000001
masscanned Antworten auf SSH Client: Protocol Protokollnachrichten mit dem folgenden Server: Protocol :
SSH-2.0-1rn
masscanned Antworten auf Negotiate Protocol Request -Pakete, damit der Client ein NTLMSSP_NEGOTIATE senden kann, auf das masscanned mit einer Challenge antwortet.
Beispiel:
##$ smbclient -U user \\10.11.10.129\shared
Enter WORKGROUPuser's password:
masscanned Antworten auf DNS Anfragen der Klasse IN und Typ A (vorerst). Die Antwort enthält immer die IP-Adresse, an die die Anfrage gesendet wurde.
Beispiel:
$ host -t A masscan.ned 10.11.10.129
Using domain server:
Name: 10.11.10.129
Address: 10.11.10.129#53
Aliases:
masscan.ned has address 10.11.10.129
$ host -t A masscan.ned 10.11.10.130
Using domain server:
Name: 10.11.10.130
Address: 10.11.10.130#53
Aliases:
masscan.ned has address 10.11.10.130
$ host -t A masscan.ned 10.11.10.131
Using domain server:
Name: 10.11.10.131
Address: 10.11.10.131#53
Aliases:
masscan.ned has address 10.11.10.131
$ host -t A masscan.ned 10.11.10.132
Using domain server:
Name: 10.11.10.132
Address: 10.11.10.132#53
Aliases:
masscan.ned has address 10.11.10.132
$ cargo test
Compiling masscanned v0.2.0 (/zdata/workdir/masscanned)
Finished test [unoptimized + debuginfo] target(s) in 3.83s
Running unittests (target/debug/deps/masscanned-f9292f8600038978)
running 92 tests
test client::client_info::tests::test_client_info_eq ... ok
test layer_2::arp::tests::test_arp_reply ... ok
test layer_2::tests::test_eth_empty ... ok
test layer_2::tests::test_eth_reply ... ok
test layer_3::ipv4::tests::test_ipv4_reply ... ok
test layer_3::ipv4::tests::test_ipv4_empty ... ok
test layer_3::ipv6::tests::test_ipv6_empty ... ok
test layer_3::ipv6::tests::test_ipv6_reply ... ok
test layer_4::icmpv4::tests::test_icmpv4_reply ... ok
test layer_4::icmpv6::tests::test_icmpv6_reply ... ok
test layer_4::icmpv6::tests::test_nd_na_reply ... ok
test layer_4::tcp::tests::test_synack_cookie_ipv6 ... ok
test layer_4::tcp::tests::test_tcp_fin_ack_wrap ... ok
test proto::dns::cst::tests::class_parse ... ok
test layer_4::tcp::tests::test_tcp_fin_ack ... ok
test layer_4::tcp::tests::test_synack_cookie_ipv4 ... ok
test proto::dns::cst::tests::type_parse ... ok
test proto::dns::header::tests::parse_byte_by_byte ... ok
test proto::dns::header::tests::repl_id ... ok
test proto::dns::header::tests::repl_opcode ... ok
test proto::dns::header::tests::repl_ancount ... ok
test proto::dns::header::tests::repl_rd ... ok
test proto::dns::query::tests::parse_in_a_all ... ok
test proto::dns::header::tests::parse_all ... ok
test proto::dns::query::tests::repl ... ok
test proto::dns::query::tests::reply_in_a ... ok
test proto::dns::rr::tests::parse_all ... ok
test proto::dns::rr::tests::parse_byte_by_byte ... ok
test proto::dns::query::tests::parse_in_a_byte_by_byte ... ok
test proto::dns::tests::parse_qd_all ... ok
test proto::dns::tests::parse_qd_byte_by_byte ... ok
test proto::dns::rr::tests::build ... ok
test proto::dns::tests::parse_qd_rr_all ... ok
test proto::dns::tests::parse_qr_rr_byte_by_byte ... ok
test proto::dns::tests::parse_rr_byte_by_byte ... ok
test proto::dns::tests::parse_rr_all ... ok
test proto::dns::tests::reply_in_a ... ok
test proto::http::tests::test_http_request_line ... ok
test proto::http::tests::test_http_request_no_field ... ok
test proto::http::tests::test_http_request_field ... ok
test proto::http::tests::test_http_verb ... ok
test proto::rpc::tests::test_probe_nmap ... ok
test proto::rpc::tests::test_probe_nmap_split1 ... ok
test proto::rpc::tests::test_probe_portmap_v4_dump ... ok
test proto::rpc::tests::test_probe_nmap_split2 ... ok
test proto::rpc::tests::test_probe_nmap_udp ... ok
test proto::smb::tests::test_smb1_session_setup_request_parse ... ok
test proto::smb::tests::test_smb1_protocol_nego_parsing ... ok
test proto::smb::tests::test_smb1_protocol_nego_reply ... ok
test proto::smb::tests::test_smb1_session_setup_request_reply ... ok
test proto::smb::tests::test_smb2_protocol_nego_parsing ... ok
test proto::smb::tests::test_smb2_protocol_nego_reply ... ok
test proto::smb::tests::test_smb2_session_setup_request_reply ... ok
test proto::smb::tests::test_smb2_session_setup_request_parse ... ok
test proto::ssh::tests::ssh_1_banner_cr ... ok
test proto::ssh::tests::ssh_1_banner_crlf ... ok
test proto::ssh::tests::ssh_1_banner_lf ... ok
test proto::ssh::tests::ssh_1_banner_space ... ok
test proto::ssh::tests::ssh_2_banner_cr ... ok
test proto::ssh::tests::ssh_1_banner_parse ... ok
test proto::ssh::tests::ssh_2_banner_parse ... ok
test proto::ssh::tests::ssh_2_banner_lf ... ok
test proto::ssh::tests::ssh_2_banner_crlf ... ok
test proto::stun::tests::test_change_request_port_overflow ... ok
test proto::stun::tests::test_proto_stun_ipv4 ... ok
test proto::stun::tests::test_change_request_port ... ok
test proto::ssh::tests::ssh_2_banner_space ... ok
test proto::stun::tests::test_proto_stun_ipv6 ... ok
test proto::tcb::tests::test_proto_tcb_proto_state_http ... ok
test proto::tests::dispatch_dns ... ok
test proto::tcb::tests::test_proto_tcb_proto_state_rpc ... ok
test proto::tcb::tests::test_proto_tcb_proto_id ... ok
test proto::tests::test_proto_dispatch_http ... ok
test proto::tests::test_proto_dispatch_ssh ... ok
test proto::tests::test_proto_dispatch_ghost ... ok
test proto::tests::test_proto_dispatch_stun ... ok
test smack::smack::tests::test_anchor_end ... ok
test smack::smack::tests::test_multiple_matches_wildcard ... ok
test smack::smack::tests::test_multiple_matches ... ok
test smack::smack::tests::test_anchor_begin ... ok
test smack::smack::tests::test_http_banner ... ok
test synackcookie::tests::test_clientinfo ... ok
test synackcookie::tests::test_ip4 ... ok
test synackcookie::tests::test_ip4_dst ... ok
test synackcookie::tests::test_ip4_src ... ok
test synackcookie::tests::test_ip6 ... ok
test synackcookie::tests::test_key ... ok
test synackcookie::tests::test_tcp_dst ... ok
test synackcookie::tests::test_tcp_src ... ok
test smack::smack::tests::test_wildcard ... ok
test smack::smack::tests::test_proto ... ok
test smack::smack::tests::test_pattern ... ok
test result: ok. 92 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.41s
# ./test/test_masscanned.py
INFO test_arp_req......................................OK
INFO test_arp_req_other_ip.............................OK
INFO test_ipv4_udp_dns_in_a............................OK
INFO test_ipv4_udp_dns_in_a_multiple_queries...........OK
INFO test_ipv4_tcp_ghost...............................OK
INFO test_ipv4_tcp_http................................OK
INFO test_ipv4_tcp_http_segmented......................OK
INFO test_ipv4_tcp_http_incomplete.....................OK
INFO test_ipv6_tcp_http................................OK
INFO test_ipv4_udp_http................................OK
INFO test_ipv6_udp_http................................OK
INFO test_ipv4_tcp_http_ko.............................OK
INFO test_ipv4_udp_http_ko.............................OK
INFO test_ipv6_tcp_http_ko.............................OK
INFO test_ipv6_udp_http_ko.............................OK
INFO test_icmpv4_echo_req..............................OK
INFO test_icmpv6_neighbor_solicitation.................OK
INFO test_icmpv6_neighbor_solicitation_other_ip........OK
INFO test_icmpv6_echo_req..............................OK
INFO test_ipv4_req.....................................OK
INFO test_eth_req_other_mac............................OK
INFO test_ipv4_req_other_ip............................OK
INFO test_rpc_nmap.....................................OK
INFO test_rpcinfo......................................OK
INFO test_smb1_network_req.............................OK
INFO test_smb2_network_req.............................OK
INFO test_ipv4_tcp_ssh.................................OK
INFO test_ipv4_udp_ssh.................................OK
INFO test_ipv6_tcp_ssh.................................OK
INFO test_ipv6_udp_ssh.................................OK
INFO test_ipv4_udp_stun................................OK
INFO test_ipv6_udp_stun................................OK
INFO test_ipv4_udp_stun_change_port....................OK
INFO test_ipv6_udp_stun_change_port....................OK
INFO test_ipv4_tcp_empty...............................OK
INFO test_ipv6_tcp_empty...............................OK
INFO test_tcp_syn......................................OK
INFO test_ipv4_tcp_psh_ack.............................OK
INFO test_ipv6_tcp_psh_ack.............................OK
INFO test_ipv4_udp_empty...............................OK
INFO test_ipv6_udp_empty...............................OK
INFO Ran 41 tests with 0 errors
Sie können auch mithilfe der Umgebungsvariablen TESTS auswählen, welche Tests ausgeführt werden sollen
TESTS=smb ./test/test_masscanned.py
INFO test_smb1_network_req.............................OK
INFO test_smb2_network_req.............................OK
INFO Ran 2 tests with 0 errors
Verben :
initrecvsenddrop $ts arp $verb $operation $client_mac $client_ip $masscanned_mac $masscanned_ip
$ts eth $verb $ethertype $client_mac $masscanned_mac