Masscanned (名字的灵感当然是来自masscan)是一个网络响应器。其目的是为尽可能多的协议提供通用答案,并尽可能少地假设客户的意图。
让他们先说吧。
就像 Masscan 一样, masscanned实现了自己的用户层网络堆栈,与 honeyd 类似。它旨在尽可能与扫描仪和机会主义机器人进行交互,并支持尽可能多的协议。
例如,当它收到网络数据包时:
ARP who is-at
和ARP is-at
(针对其 IP 地址)的大量扫描答案,ICMP Echo Reply
ICMP Echo Request
进行批量扫描答复,TCP SYN/ACK
批量扫描TCP SYN
(任何端口)的应答,HTTP 401
网页对通过TCP/UDP
(任何端口)的HTTP
请求(任何动词)进行批量扫描。 Masscanned目前支持最常见的 2-3-4 层协议以及一些应用协议。
$ 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
...
Masscanned的一个很好的用途是将其部署在具有一个或多个公共 IP 地址的 VPS 上。
要使用结果,最好的方法是捕获Masscanned正在侦听/响应的接口上的所有网络流量。然后可以使用 zeek 分析 pcap,并且通常可以将输出文件推送到IVRE实例中。
有关如何在 VPS 上部署Masscanned实例的文档即将发布(请参阅问题 #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
对ARP
请求的应答,针对以masscanned
处理的IPv4
地址为目标的请求(即,使用选项-f
给出的 IP 地址文件中的地址)。
答案包含以下可能的MAC
地址中的第一个:
-a
指定的MAC
地址(如果有),-i
指定的接口的MAC
地址(如果有),masscanned
默认MAC
地址,即c0:ff:ee:c0:ff:ee
。 当且仅当满足以下要求时,才会对Ethernet
帧进行masscanned
:
帧的目标地址应由masscanned
处理,这意味着:
masscanned
自己的MAC
地址,MAC
地址ff:ff:ff:ff:ff:ff
masscanned
(RFC 1112) 处理的IPv4
地址之一相对应的多播MAC
地址,masscanned
处理的IPv6
地址之一相对应的多播MAC
地址; EtherType
字段是ARP
、 IPv4
或IPv6
之一。
注意:即使对于非多播 IP 地址, masscanned
也会响应寻址到相应多播MAC
地址的 L2 帧。例如,如果masscanned
处理10.11.12.13
,它将响应寻址到01:00:5e:0b:0c:0d
的帧。
仅当满足以下条件时,才会对IPv4
和IPv6
数据包进行masscanned
答案:
IP
地址(即未指定-f
选项或文件为空),或者
masscanned
处理的 IP 地址之一。另一个要求是支持下一层协议 - 见下文。
IPv4
数据包支持以下 L3+/4 协议:
ICMPv4
UDP
TCP
如果下一层协议不是其中之一,则数据包将被丢弃。
IPv6
数据包支持以下 L3+/4 协议:
ICMPv6
UDP
TCP
如果下一层协议不是其中之一,则数据包将被丢弃。
当且仅当满足以下条件时,才会对ICMPv4
数据包进行masscanned
应答:
ICMP
类型是EchoRequest
( 8
),ICMP
代码为0
。如果满足这些条件,则会使用EchoReply
( 0
) 类型、代码0
和与传入数据包相同的负载的ICMP
数据包进行masscanned
应答,如 RFC 792 所指定。
当且仅当满足以下条件时,才会对ICMPv6
数据包进行masscanned
应答:
ICMP
类型为NeighborSol
( 135
)并且:masscanned
IP(v4 或 v6)masscanned
之一在这种情况下,答案是带有masscanned
MAC
地址的Neighbor Advertisement
( 136
) 数据包
或者
ICMP
类型是EchoRequest
( 128
)在这种情况下,答案是EchoReply
( 129
) 数据包。
对以下TCP
数据包进行masscanned
答案:
PSH
和ACK
, masscanned
检查SYNACK-cookie ,如果有效答案至少有一个ACK
,或者如果检测到支持的协议(第 5/6/7 层),则为PSH-ACK
,ACK
,则忽略它,RST
或FIN-ACK
,则忽略它,SYN
,则masscanned
会尝试模仿标准 Linux 堆栈的行为 - 即:PSH
、 URG
、 CWR
、 ECE
之外的其他标志,则忽略SYN
,CWR
和ECE
同时设置,则SYN
被忽略,SYN-ACK
数据包masscanned
,并在序列号中设置SYNACK-cookie 。 当且仅当上层协议得到处理并提供答案时,才会对UDP
数据包进行masscanned
答案。
对带有401 Authorization Required
任何HTTP
请求(任何有效动词)进行masscanned
答案。请注意,带有无效动词的HTTP
请求将不会得到响应。
例子:
$ 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]
例子:
$ stun 10.11.10.129
STUN client version 0.97
Primary: Open
Return value is 0x000001
对SSH
Client: Protocol
消息masscanned
,其中包含以下Server: Protocol
消息:
SSH-2.0-1rn
masscanned
对Negotiate Protocol Request
数据包的应答,以便客户端发送NTLMSSP_NEGOTIATE
, masscanned
会通过质询进行应答。
例子:
##$ smbclient -U user \\10.11.10.129\shared
Enter WORKGROUPuser's password:
对IN
类和A
类DNS
查询的masscanned
答案(目前)。它提供的答案始终包含查询发送到的 IP 地址。
例子:
$ 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
您还可以使用TESTS
环境变量选择要运行的测试
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
动词:
init
recv
send
drop
$ts arp $verb $operation $client_mac $client_ip $masscanned_mac $masscanned_ip
$ts eth $verb $ethertype $client_mac $masscanned_mac