mirror of
https://github.com/ivre/masscanned.git
synced 2025-10-02 06:38:21 +00:00
Change log format (add timestamp)
This commit is contained in:
parent
27f1c4ba65
commit
26f74ad6a5
3 changed files with 69 additions and 39 deletions
25
README.md
25
README.md
|
@ -290,12 +290,27 @@ tcpdump: pcap_loop: The interface disappeared
|
||||||
0 packets dropped by kernel
|
0 packets dropped by kernel
|
||||||
```
|
```
|
||||||
|
|
||||||
### Logging Policy
|
## Logging
|
||||||
|
|
||||||
* `ERR`: any error - will always be displayed.
|
### Console Logger
|
||||||
* `WARN`, `-v`: responses sent by `masscanned`.
|
|
||||||
* `INFO`, `-vv`: packets not handled, packets ignored.
|
**Verbs**:
|
||||||
* `DEBUG`, `-vvv`: all packets received and sent by `masscanned`.
|
* `init`
|
||||||
|
* `recv`
|
||||||
|
* `send`
|
||||||
|
* `drop`
|
||||||
|
|
||||||
|
#### ARP
|
||||||
|
|
||||||
|
```
|
||||||
|
$ts arp $verb $operation $client_mac $client_ip $masscanned_mac $masscanned_ip
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Ethernet
|
||||||
|
|
||||||
|
```
|
||||||
|
$ts eth $verb $ethertype $client_mac $masscanned_mac
|
||||||
|
```
|
||||||
|
|
||||||
## To Do
|
## To Do
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ pub fn repl<'a, 'b>(
|
||||||
/* Build ARP answer depending of the type of request */
|
/* Build ARP answer depending of the type of request */
|
||||||
match arp_req.get_operation() {
|
match arp_req.get_operation() {
|
||||||
ArpOperations::Request => {
|
ArpOperations::Request => {
|
||||||
masscanned.log.arp_recv_whohas(arp_req);
|
masscanned.log.arp_recv(arp_req);
|
||||||
let ip = IpAddr::V4(arp_req.get_target_proto_addr());
|
let ip = IpAddr::V4(arp_req.get_target_proto_addr());
|
||||||
/* Ignore ARP requests for IP addresses not handled by masscanned */
|
/* Ignore ARP requests for IP addresses not handled by masscanned */
|
||||||
if let Some(ip_addr_list) = masscanned.ip_addresses {
|
if let Some(ip_addr_list) = masscanned.ip_addresses {
|
||||||
|
@ -51,7 +51,7 @@ pub fn repl<'a, 'b>(
|
||||||
arp_repl.set_target_hw_addr(arp_req.get_sender_hw_addr().to_owned());
|
arp_repl.set_target_hw_addr(arp_req.get_sender_hw_addr().to_owned());
|
||||||
arp_repl.set_target_proto_addr(arp_req.get_sender_proto_addr().to_owned());
|
arp_repl.set_target_proto_addr(arp_req.get_sender_proto_addr().to_owned());
|
||||||
arp_repl.set_sender_proto_addr(arp_req.get_target_proto_addr().to_owned());
|
arp_repl.set_sender_proto_addr(arp_req.get_target_proto_addr().to_owned());
|
||||||
masscanned.log.arp_send_isat(&arp_repl);
|
masscanned.log.arp_send(&arp_repl);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
info!("ARP Operation not handled: {:?}", arp_repl.get_operation());
|
info!("ARP Operation not handled: {:?}", arp_repl.get_operation());
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Masscanned. If not, see <http://www.gnu.org/licenses/>.
|
// along with Masscanned. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use std::time::SystemTime;
|
||||||
|
|
||||||
use pnet::packet::{
|
use pnet::packet::{
|
||||||
arp::{ArpPacket, MutableArpPacket},
|
arp::{ArpPacket, MutableArpPacket},
|
||||||
ethernet::{EthernetPacket, MutableEthernetPacket},
|
ethernet::{EthernetPacket, MutableEthernetPacket},
|
||||||
|
@ -29,10 +31,8 @@ pub trait Logger {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
fn arp_recv(&self, _p: &ArpPacket) {}
|
fn arp_recv(&self, _p: &ArpPacket) {}
|
||||||
fn arp_recv_whohas(&self, _p: &ArpPacket) {}
|
|
||||||
fn arp_drop(&self, _p: &ArpPacket) {}
|
fn arp_drop(&self, _p: &ArpPacket) {}
|
||||||
fn arp_send(&self, _p: &MutableArpPacket) {}
|
fn arp_send(&self, _p: &MutableArpPacket) {}
|
||||||
fn arp_send_isat(&self, _p: &MutableArpPacket) {}
|
|
||||||
/* Ethernet */
|
/* Ethernet */
|
||||||
fn eth_enabled(&self) -> bool {
|
fn eth_enabled(&self) -> bool {
|
||||||
true
|
true
|
||||||
|
@ -54,12 +54,22 @@ impl ConsoleLogger {
|
||||||
eth: true,
|
eth: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn prolog(&self, proto: &str, verb: &str, crlf: bool) {
|
||||||
|
let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap();
|
||||||
|
print!("{}.{}\t{}\t{}{}",
|
||||||
|
now.as_secs(),
|
||||||
|
now.subsec_millis(),
|
||||||
|
proto,
|
||||||
|
verb,
|
||||||
|
if crlf { "\n" } else { "\t" },
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Logger for ConsoleLogger {
|
impl Logger for ConsoleLogger {
|
||||||
fn init(&self) {
|
fn init(&self) {
|
||||||
println!("arp::init");
|
self.prolog("arp", "init", true);
|
||||||
println!("eth::init");
|
self.prolog("eth", "init", true);
|
||||||
}
|
}
|
||||||
fn arp_enabled(&self) -> bool {
|
fn arp_enabled(&self) -> bool {
|
||||||
self.arp
|
self.arp
|
||||||
|
@ -67,42 +77,61 @@ impl Logger for ConsoleLogger {
|
||||||
fn eth_enabled(&self) -> bool {
|
fn eth_enabled(&self) -> bool {
|
||||||
self.eth
|
self.eth
|
||||||
}
|
}
|
||||||
fn arp_recv_whohas(&self, p: &ArpPacket) {
|
fn arp_recv(&self, p: &ArpPacket) {
|
||||||
|
self.prolog("arp", "recv", false);
|
||||||
println!(
|
println!(
|
||||||
"arp::recv\twho-has\t{:}\t{:}\t{:}",
|
"{:?}\t{:}\t{:}\t{:}\t{:}",
|
||||||
p.get_sender_hw_addr(),
|
p.get_operation(),
|
||||||
p.get_target_hw_addr(),
|
|
||||||
p.get_target_proto_addr()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
fn arp_send_isat(&self, p: &MutableArpPacket) {
|
|
||||||
println!(
|
|
||||||
"arp::send\tis-at\t{:}\t{:}\t{:}\t{:}",
|
|
||||||
p.get_sender_hw_addr(),
|
p.get_sender_hw_addr(),
|
||||||
p.get_sender_proto_addr(),
|
p.get_sender_proto_addr(),
|
||||||
p.get_target_hw_addr(),
|
p.get_target_hw_addr(),
|
||||||
p.get_target_proto_addr()
|
p.get_target_proto_addr(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
fn arp_send(&self, p: &MutableArpPacket) {
|
||||||
|
self.prolog("arp", "send", false);
|
||||||
|
println!(
|
||||||
|
"{:?}\t{:}\t{:}\t{:}\t{:}",
|
||||||
|
p.get_operation(),
|
||||||
|
p.get_target_hw_addr(),
|
||||||
|
p.get_target_proto_addr(),
|
||||||
|
p.get_sender_hw_addr(),
|
||||||
|
p.get_sender_proto_addr(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
fn arp_drop(&self, p: &ArpPacket) {
|
||||||
|
self.prolog("arp", "drop", false);
|
||||||
|
println!(
|
||||||
|
"{:?}\t{:}\t{:}\t{:}\t{:}",
|
||||||
|
p.get_operation(),
|
||||||
|
p.get_target_hw_addr(),
|
||||||
|
p.get_target_proto_addr(),
|
||||||
|
p.get_sender_hw_addr(),
|
||||||
|
p.get_sender_proto_addr(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
fn eth_recv(&self, p: &EthernetPacket, _c: &ClientInfo) {
|
fn eth_recv(&self, p: &EthernetPacket, _c: &ClientInfo) {
|
||||||
|
self.prolog("eth", "recv", false);
|
||||||
println!(
|
println!(
|
||||||
"eth::recv\t{:}\t{:}\t{:}",
|
"{:}\t{:}\t{:}",
|
||||||
p.get_ethertype(),
|
p.get_ethertype(),
|
||||||
p.get_source(),
|
p.get_source(),
|
||||||
p.get_destination(),
|
p.get_destination(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
fn eth_drop(&self, p: &EthernetPacket, _c: &ClientInfo) {
|
fn eth_drop(&self, p: &EthernetPacket, _c: &ClientInfo) {
|
||||||
|
self.prolog("eth", "drop", false);
|
||||||
println!(
|
println!(
|
||||||
"eth::drop\t{:}\t{:}\t{:}",
|
"{:}\t{:}\t{:}",
|
||||||
p.get_ethertype(),
|
p.get_ethertype(),
|
||||||
p.get_source(),
|
p.get_source(),
|
||||||
p.get_destination(),
|
p.get_destination(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
fn eth_send(&self, p: &MutableEthernetPacket, _c: &ClientInfo) {
|
fn eth_send(&self, p: &MutableEthernetPacket, _c: &ClientInfo) {
|
||||||
|
self.prolog("eth", "send", false);
|
||||||
println!(
|
println!(
|
||||||
"eth::send\t{:}\t{:}\t{:}",
|
"{:}\t{:}\t{:}",
|
||||||
p.get_ethertype(),
|
p.get_ethertype(),
|
||||||
p.get_destination(),
|
p.get_destination(),
|
||||||
p.get_source(),
|
p.get_source(),
|
||||||
|
@ -135,13 +164,6 @@ impl MetaLogger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn arp_recv_whohas(&self, p: &ArpPacket) {
|
|
||||||
for l in &self.loggers {
|
|
||||||
if l.arp_enabled() {
|
|
||||||
l.arp_recv_whohas(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn arp_drop(&self, p: &ArpPacket) {
|
pub fn arp_drop(&self, p: &ArpPacket) {
|
||||||
for l in &self.loggers {
|
for l in &self.loggers {
|
||||||
if l.arp_enabled() {
|
if l.arp_enabled() {
|
||||||
|
@ -156,13 +178,6 @@ impl MetaLogger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn arp_send_isat(&self, p: &MutableArpPacket) {
|
|
||||||
for l in &self.loggers {
|
|
||||||
if l.arp_enabled() {
|
|
||||||
l.arp_send_isat(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn eth_recv(&self, p: &EthernetPacket, c: &ClientInfo) {
|
pub fn eth_recv(&self, p: &EthernetPacket, c: &ClientInfo) {
|
||||||
for l in &self.loggers {
|
for l in &self.loggers {
|
||||||
if l.eth_enabled() {
|
if l.eth_enabled() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue