Skip to content

Implement more extractors #141

Open
Open

Description

@0xB10C

With NATS (#56, #76), we can have multiple extractors pushing events into the message queue. Here are some ideas for future extractors that could be good to implement:

Activity

  1. 0xB10C commented on Apr 10, 2025

    @0xB10C
    CollaboratorAuthor

    For the RPC extractor, it probably makes sense to use https://crates.io/crates/jsonrpc-core - however it does not provide a proper transport. Maybe the "for non-production use only" transport is enough for us.

  2. edilmedeiros commented on Jun 18, 2025

    @edilmedeiros
    Contributor

    For the RPC extractor, it probably makes sense to use https://crates.io/crates/jsonrpc-core - however it does not provide a proper transport. Maybe the "for non-production use only" transport is enough for us.

    Looks like it was superseded by https://github.com/paritytech/jsonrpsee.

    Also, rust-bitcoin includes an active project to provide types for the RPC interface here https://crates.io/crates/corepc-types (pretty new library, not sure if it covers the whole RPC right now, but is probably a good starting point).

  3. 0xB10C commented on Jul 8, 2025

    @0xB10C
    CollaboratorAuthor

    In preparation for multiple extractors, I've moved the ebpf extractor into the extractors sub directory in #181

  4. added a commit that references this issue on Jul 9, 2025
  5. 0xB10C commented on Jul 10, 2025

    @0xB10C
    CollaboratorAuthor

    An IPC/multiprocess extractor is becoming more and more interesting IMO. See bitcoin-core/libmultiprocess#185 and bitcoin/bitcoin#32898. However, still very early.

    The RPC extractor is probably the thing to work on next.

  6. 0xB10C commented on Jul 30, 2025

    @0xB10C
    CollaboratorAuthor

    Implementing an RPC extractor in #191

  7. 0xB10C commented on Aug 15, 2025

    @0xB10C
    CollaboratorAuthor

    Added a P2P exporter to OP:

  8. 0xB10C commented on Sep 16, 2025

    @0xB10C
    CollaboratorAuthor

    Started working on a (wip) P2P-extractor in #256

  9. m4ycon commented on Sep 23, 2025

    @m4ycon
    Collaborator

    Just to inform, I'll start working on a log extractor, me and @edilmedeiros talked about it being a "unix pipe" consumed by this extractor, if this doesn't work well I'll go to a more straight solution that is pooling the btc core log file. I think that initially we can publish all logs to nats and tools could filter these logs for specific messages. If you have any suggestions, please let me know.

  10. 0xB10C commented on Sep 23, 2025

    @0xB10C
    CollaboratorAuthor

    If you have any suggestions, please let me know.

    Cool! A few thoughts:

    I'm somewhat leaning towards only having to parse the log messages in one place. Otherwise multiple tools try to parse the same message at the same time. So ideally a log-extractor would do this for all messages it knows and can parse. These would then be put into a protobuf event and send via NATS to the tools. For all unknown and not yet implemented log messages, it could forward the full log message in a UnknownLogMessage protobuf (or similar).

  11. 2 remaining items

  12. RazorBest commented on Mar 24, 2026

    @RazorBest
    Contributor

    Hi! Would you be open for a TCP layer extractor in peer-observer?

    I've recently been working with TCP level inspection, and I see two ways of doing it:

    • Passive listening with libpcap
    • Active listening with libnetfilter_queue (Linux only). Harder to do it correctly because the extractor would need to make a decision for every received packet.
  13. 0xB10C commented on Mar 24, 2026

    @0xB10C
    CollaboratorAuthor

    Interesting idea! What events, metrics, or data (that we don't yet have) would we get from a tcp-extractor?

  14. RazorBest commented on Mar 24, 2026

    @RazorBest
    Contributor

    Interesting idea! What events, metrics, or data (that we don't yet have) would we get from a tcp-extractor?

    I'm not seeing a lot of value from it, but I'll still list what you could do with it.

    You would get similar data that you get from net:inbound_message and net:outbound_message ebpf traces. However, when those traces are triggered, the received data is already parsed/decrypted and split into messages. From a tcp-extractor you'd get the unparsed and encrypted data. You can use it for nodes other than bitcoin-core.

    You can also observe behaviors that are outside of the P2P protocol. But I'm not too sure how valuable this would be. One such behavior that I observed are the ping health checks from https://www.dsn.kastel.kit.edu/bitcoin/, which are not malicious.

    The kind of data you would get from this extractor could look like this:

    <timestamp> connection_open <src_ip> <src_port> <dst_ip> <dst_port>
    <timestamp> connection_close <src_ip> <src_port> <dst_ip> <dst_port>
    <timestamp> connection_timeout <src_ip> <src_port> <dst_ip> <dst_port>
    <timestamp> payload <src_ip> <src_port> <dst_ip> <dst_port> <size>
    

    Concretely:

    2026-03-24T10:15:32.481Z connection_open 192.168.1.42 48291 45.63.117.2 8333
    2026-03-24T10:15:33.012Z payload 192.168.1.42 48291 45.63.117.2 8333 126
    2026-03-24T10:15:33.847Z payload 45.63.117.2 8333 192.168.1.42 48291 254
    2026-03-24T10:15:34.103Z payload 192.168.1.42 48291 45.63.117.2 8333 89
    2026-03-24T10:15:36.220Z connection_open 192.168.1.42 48307 91.210.44.18 8333
    2026-03-24T10:15:37.551Z payload 192.168.1.42 48307 91.210.44.18 8333 126
    2026-03-24T10:17:37.554Z connection_timeout 192.168.1.42 48307 91.210.44.18 8333
    2026-03-24T10:15:41.899Z payload 45.63.117.2 8333 192.168.1.42 48291 1048576
    
  15. 0xB10C commented on Mar 25, 2026

    @0xB10C
    CollaboratorAuthor

    Thanks for sharing, I think these events are not uninteresting, but as you said, we get similar ones via the ebpf message/connection tracepoints. I don't think a tcp extractor should attempt to parse/decrypt the packets. Reporting on the connections being opened/closed and packages send/received would probably be the main focus.

    Do we need special permissions (e.g. root) for running this? Can libpcap give us stuff in real time?

    I like that this works for non Bitcoin Core nodes and possibly on non-linux systems(?).

    Added it to the OP, but I don't think it's very high priority at the moment (unless we find something unique we don't yet have insights into). It might still be a fun exercise for you.

    edit: can we track e.g. TCP ping times with this to connections? Also SYN/ACK times?

  16. RazorBest commented on Mar 25, 2026

    @RazorBest
    Contributor

    Do we need special permissions (e.g. root) for running this?

    libpcap is BPF (probably eBPF) based, so you'll need root privileges, or the CAP_BPF capability. I don't know if eBPF has more granular permissions. However there is ss which is based on the sock_diag subsystem, and doesn't need privileges. For example, with ss -ti you can list the active connections and the amount of bytes transferred. From, my understanding, sock_diag doesn't have notifications (referencing this presentation: https://events.static.linuxfound.org/sites/events/files/slides/Exploration%20of%20Linux%20Container%20Network%20Monitoring%20and%20Visualization.pdf), so you need to do some polling.

    If you don't have root permissions, you might also use strace, but that comes with its own problems.

    and possibly on non-linux systems(?)

    For windows, there's https://npcap.com/, which from my understanding, it's driver + a library that interfaces with libpcap.

    TCP ping times with this to connections? Also SYN/ACK times?

    With tcpdump/libpcap, definetly. But I only found out now that it's based on eBPF. So, there might be more simple tools to track that. A quick way to verify that is to look through bcc-tools - the ones prefixed by tcp*. For example, tcplife listens to tcp sessions, and logs them when they end.

    For non-root, I saw that ss also outputs lastack, which is the last value of the ACK field. To get the times, you can query it continuously. So, we still have to confirm if it has notifications. If it doesn't, I don't see how it can be used. This is just a snapshot:

    users:(("bitcoind",pid=17304,fd=15))
    cubic wscale:7,7 rto:232 rtt:29.975/13.99 ato:88 mss:1444 pmtu:1500 rcvmss:1444 advmss:1448 cwnd:10 bytes_sent:81881 bytes_acked:81882 bytes_received:2662701231 segs_out:286075 segs_in:1844567 data_segs_out:1357 data_segs_in:1844116 send 3.73Mbps lastsnd:23748 lastrcv:20836 lastack:20836 pacing_rate 7.46Mbps delivery_rate 2.51Mbps delivered:1358 app_limited busy:41524ms rcv_rtt:13.18 rcv_space:4702748 rcv_ssthresh:4571136 minrtt:13.332 rcv_ooopack:44487 snd_wnd:64128
    

    Another thing I didn't go into are retransmissions or other TCP-internal stuff. I don't even know if that is traced by the kernel.

  17. RazorBest commented on Mar 25, 2026

    @RazorBest
    Contributor

    Apart from that, there's also the conntrack tool (root needed), which is an interface over the nf_conntrack subsystem, which holds the state table for the TCP connections. This is also behind the NAT functionality used by iptables. You can easily see it with cat /proc/net/nf_conntrack.

    This doesn't show each packet. Only state table updates. But this one allows notifications.

    Reference: https://www.netfilter.org/projects/libnetfilter_conntrack/index.html

  18. 0xB10C commented on Mar 25, 2026

    @0xB10C
    CollaboratorAuthor

    We have some extractors that are polling based (e.g. RPC extractor and the IPC extractor). So I don't think it's a hard requirement.

    I think we can use procfs::net::tcp to get some information about TCP sockets from /proc/net/tcp.

    Note that there is also #258, which goes into a similar direction.

  19. 0xB10C commented on Mar 26, 2026

    @0xB10C
    CollaboratorAuthor

    Unrelated to the TCP extractor, I had an idea for a call-stack extractor. I've written down a few raw thoughts on it here: #391 - we are not reinventing the wheel with it, but I think it's a considerable enginnering effort to get it working well.

  20. ViniciusCestarii commented on Jul 3, 2026

    @ViniciusCestarii
    Contributor

    Interesting idea! What events, metrics, or data (that we don't yet have) would we get from a tcp-extractor?

    Initial TTL, window size/scaling, MSS, TCP options ordering.

    These could be used for stack/OS fingerprinting on ipv4/ipv6. connections. One nice output is an aggregate OS distribution of peers (% Linux/macOS/Windows/BSD).

    Caveats: it only covers ipv4/ipv6 peers and it's biased by NAT/VPS/middlebox stacks so it partly reflects hosting rather than operator OS. Also, even with a fingerprint in hand, the OS match is probabilistic, so it should be treated as a best-guess label rather than ground truth.

    Do you think this would be an interesting metric for peer-observer?

  21. 0xB10C commented on Jul 3, 2026

    @0xB10C
    CollaboratorAuthor

    These could be used for stack/OS fingerprinting on ipv4/ipv6.

    If we can do this with a high accuracy, then I think something like this, especially as a library so it can be re-used, is very interesting.

    I had been looking into something related for a different project (https://github.com/0xB10C/p2p-observer/blob/master/observer/src/tcp.rs) and my impression was fingerprinting OS is quite hard. Happy to be convinced otherwise.

    Next to OS fingerprinting, some of the other metrics are certainly interesting, even if we don't know how to best use them.

  22. ViniciusCestarii commented on Jul 4, 2026

    @ViniciusCestarii
    Contributor

    my impression was fingerprinting OS is quite hard. Happy to be convinced otherwise.

    Yes, it's not a simple task. Based on the article Passive operating system fingerprinting revisited: Evaluation and current challenges, building a good OS passive fingerprinting tool for the Bitcoin network would require a labeled dataset that maps OS labels to the TCP Options, TCP Window Size, IP TTL, and IP Flags collected from the actual network, and then using this data to train a decision tree. The article fingerprints the client's SYN, but the same fields are present in a responder's SYN-ACK, and passive fingerprinting from SYN-ACKs works too. oopir/os_fingerprinting did it on ~1M web servers.

    One way to build that dataset: for every reachable node, connect and send a minimal P2P version message while tracing the TCP messages, capturing the TCP/IP fields from the SYN-ACK packet, and obtain the OS label via nmap -O (an active fingerprinter, so generally more accurate than passive fingerprinting).

    The quality ceiling for this approach is set by the accuracy of nmap's guesses, since they're the labels the model learns from.

    The cool thing is that the dataset is already useful on its own, since it would contain a mapping of every reachable node in the network to its OS guess at the time of collection.

  23. ViniciusCestarii commented on Jul 7, 2026

    @ViniciusCestarii
    Contributor

    obtain the OS label via nmap -O

    I have done it: https://github.com/ViniciusCestarii/bitcoin-node-os-fingerprint. In aggregate, the results seem reliable.

  24. 0xB10C commented on Jul 7, 2026

    @0xB10C
    CollaboratorAuthor

    pretty cool! maybe worth a short bnoc.xyz post? doing this monthly is probably interesting to report on changes. For quality control, you could check if any IPs switch between OS from time to time. Additionally, it might be interesting to find out the hoster/AS (maybe see #470 for inspiration) of the Windows machines. I wouldn't be surprised if it's Azure.

  25. 0xB10C commented on Jul 7, 2026

    @0xB10C
    CollaboratorAuthor

    Actually, see this which I extracted from your scan with awk -F, '$3=="Windows" {print $1}' scan-2026-07-06.csv. Mostly ISPs and not hosters. Didn't see any Azure.

  26. ViniciusCestarii commented on Jul 7, 2026

    @ViniciusCestarii
    Contributor

    maybe worth a short bnoc.xyz post?

    I'd love to! I will cook a post.

    doing this monthly is probably interesting to report on changes.

    For sure, I will add a cronjob in a VPS that I have for running it each month and push the result to the repo.

    For quality control, you could check if any IPs switch between OS from time to time.

    Just documented on the README: Measured across the two published scans (scan-2026-07-06.csv and scan-2026-07-07.csv): of the 10,302 targets reachable on both days, 256 (~2.5%) had their os_class flip between runs, mostly Linux ↔ Unknown and Linux ↔ Other/Device. (I looked into it and it seems that it is most nmap confusing Android and Linux, which makes sense since Android is based on Linux)

    ~2.5% flip seems reasonable because the real values is the aggregate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions