Giter VIP home page Giter VIP logo

dnsmonster's Introduction

Hi there πŸ‘‹

mosajjal's GitHub Stats

dnsmonster's People

Contributors

adulau avatar dependabot[bot] avatar dstruck avatar edevil avatar mosajjal avatar mzealey avatar pchaseh avatar srudush avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dnsmonster's Issues

PCAP to JSON workflow - Split/maximum packets per output file?

Would it be possible to be able to limit the size of the output json files by packet count?

As you'd be aware pcap to json conversion balloons the size of the files, for us it's taking a gzip compressed pcap from 1GB to a JSON file of 26GB.

Would be great if we could split that out with the following example:

Input:
example.pcap

Output:
example_001.json
example_002.json
etc etc

Also helps with downstream horizontal scaling as the files are processed off S3, so smaller but more numerous files allows more simultanteous workers to process the output.

Question regarding CNAME and Query response on Clickhouse

Hello,
First, I would like to thank you for this excellent and useful project!
Regarding Clickhouse output, I am running a local stack and while monitoring my main interface, I cannot find CNAME queries in DNS_LOG table (Types are either 1 or 28 which are mapped to A and AAAA respectively). Is this an issue with my configuration or is this by default?

Best,

dnsmonster to clickhouse data replication

First of all thank you for this amazing dnsmonster !!!
We have a cluster of three clickhouse nodes and our dns data is going through dnsmonster. But in the configuration of dnsmonster only one IP address of the clickhouse node is mentioned. The problem is that if our mentioned clickhouse node goes down, will our data replicate to the other cluster node?

ClickHouse over network

I made a small change that leverages builtin driver's support. Most likely I'll make a change to the way the Address is provided so we can have different credentials and TLS support for each address later on. Please let me know if the latest commit solves your issue. Happy to re-open if it doesn't

Originally posted by @mosajjal in #27 (comment)

Save dnstap `identity` as server name

If we have multiple servers sending data over dnstap to dnsmonster it would be good to have an option to use the dnstap identity field as the server name which gets recorded in the logs.

can dnsmonster handle 5,000,000 QPS?

Hi,,
Can dnsmonster handle 5,000,000 QPS? We have a passive server about receive DNS traffic, and we want analyze the traffic data by dnsmonster, I'm not sure if it's a best way?
bellow is my server network info:
image

Question around pcap file behaviour

Thanks for writing a really useful tool for pcap parsing into dns json!

I just have a question, I'm running the command as such below:

$ dnsmonster --pcapfile="output.pcap" --fileoutputpath=dns.json --fileoutputformat=json --fileoutputtype=1
INFO[2022-11-04T15:44:41Z] Creating the dispatch Channel
INFO[2022-11-04T15:44:41Z] Creating File Output Channel
INFO[2022-11-04T15:44:41Z] Using File: output.pcap

INFO[2022-11-04T15:44:41Z] skipping skipDomains refresh since it's not provided
INFO[2022-11-04T15:44:41Z] skipping allowDomains refresh since it's not provided
WARN[2022-11-04T15:44:41Z] BPF Filter is not supported in offline mode.
INFO[2022-11-04T15:44:41Z] Reading off Pcap file
INFO[2022-11-04T15:44:41Z] Creating handler #0
INFO[2022-11-04T15:44:41Z] Creating handler #1
2022-11-04T15:44:51Z metrics: {"fileSentToOutput":{"count":136405},"fileSkipped":{"count":0},"packetLossPercent":{"value":0},"packetsCaptured":{"value":0},"packetsDropped":{"value":0},"packetsDuplicate":{"count":0},"packetsOverRatio":{"count":0}}
2022-11-04T15:45:01Z metrics: {"fileSentToOutput":{"count":136405},"fileSkipped":{"count":0},"packetLossPercent":{"value":0},"packetsCaptured":{"value":0},"packetsDropped":{"value":0},"packetsDuplicate":{"count":0},"packetsOverRatio":{"count":0}}
...

But this never ends? According to top/iotop the process has finished writing and I can confirm the output json file seems to have stopped writing - but dnsmonster never terminates back to the shell.

Is this expected behaviour?

Clickhouse flushing algo

It seems like the default config is just batching clickhouse output and only writing when the batch is full, which is a bit confusing - changing to using 1s flush interval makes the flushes work correctly in low-quantity testing.

May I suggest that you have a flush algorithm that flushes EITHER when flush interval OR batch size is reached as that is the standard way to do things? And that flush interval is set to eg 5s as default?

dnsmonser not sending all packets from pcap to clickhouse

I noticed that the number of DNS packets stored in my local clickhouse instance were always multiples of the clickhousebatchsize:
When using dnsmonster to process pcap files and clickhousebatchsize set to non-zero, the clickhouse output will not send all results to clickhouse.

Scenario:

  • clickhousebatchsize = 100000 (default)
  • output to clickhouse
  • pcaps with number of DNS packets which is not multiple of the batch size, e.g. 1234567

Result:
dnsmonster sends info for only 1200000 packets to clickhouse, in batches of 100000.
Missing the 34567 packets as the batch size was not reached.

The code section responsible is

if int(c%chConfig.ClickhouseBatchSize) == div {
now = time.Now()
err = batch.Send()
if err != nil {
log.Warnf("Error while executing batch: %v", err)
clickhouseFailed.Inc(int64(c))
}
c = 0
batch, _ = conn.PrepareBatch(ctx, "INSERT INTO DNS_LOG")
}

I did not see anything that makes sure the remainder is being sent to clickhouse when the end of the pcap file has been reached.

Clickhouse datasource plugin showing as unsigned in grafana

First of all I would like to say a big thank you for making this.

Everything gets installed fine, even getting the logs on clickhouse container when checked clickhouse-client, So that works brilliantly. However, while looking at the datasource in grafana. The local ch datasource doesn't load, tried adding new then noticed following error at the top
Screenshot 2021-09-03 at 6 04 05 PM

Tried changing the flag "allow_loading_unsigned_plugins" too, but the error is not going away. Clickhouse is not available in the list of datasources.

Screenshot 2021-09-03 at 6 05 03 PM

Minor documentation fix

In the README.MD in the Configuration File section, the command line is listed as

sudo dnsmonster -config=dnsmonster.ini

It should be

sudo dnsmonster --config=dnsmonster.ini

Compilation failed on MacOS M1

Sorry to raise this but I'm failing to compile the main branch.

Error:

go build -o dnsmonster .
# github.com/mosajjal/dnsmonster/capture
capture/livecap_bsd.go:69:26: h.sniffer.Stats undefined (type bsdbpf.BPFSniffer has no field or method Stats)

Mac OS 12.6
Go 1.19.3 darwin/arm64

Clickhouse Cloud

I noticed that the scheme appears to have changed and I tried to apply that to the replicated example, but it is not working as expected.

Splunk Output mode >1 broken, 8.4.0

Hello,

It seems the filtering/allow logic is broken for the Splunk HEC Output as once the splunkOutputType is increased above 1, all domains get skipped, no matter what is in/not in the allow/skip files:
{"level":"info","msg":"output: {Name:splunk SentToOutput:0 Skipped:99441}","time":"2021-07-13T15:03:29+10:00"}
{"level":"info","msg":"{PacketsGot:99485 PacketsLost:0 PacketLossPercent:0}","time":"2021-07-13T15:03:29+10:00"}

Config file:
useAfpacket=true
devName=myerspan
splunkOutputType=3
skipDomainsFile=/app/dnsmonster/filterDomains.csv
splunkOutputEndpoint=:8088
splunkOutputToken=
skipTlsVerification=true
splunkOutputIndex=
splunkOutputSource=
splunkOutputSourceType=

filterDomains:
empty

Are you able to please advise if something is wrong with the config or if this bug has been fixed in commits past the 8.4.0 release?

Thanks,
Lachlan

Not logged all data from Interface Device

Hi ..
we are observing a issue in monster while logging data to click-house from monster.
we have two standalone VMs in same location and configured monster with latest version.
but in one VMs data are being logged less than second VMs.
Supoose we have 100 packets of data then one VMs loogged 80 packets and second VMs logged 30 Packets.
I suppose that both VMs should logged full 100 of packets without any loss.

pcap by stdin?

Is it possible to pipe pcap data to dnsmonster? Sometimes a network stream needs first to be decapsulated.

Something like pcap.OpenOfflineFile(os.Stdin)?

higher precision timestamps in clickhouse

It would be nice to have higher precision timestamps for the package's time in clickhouse.

The current DNS_Log table:

CREATE TABLE IF NOT EXISTS DNS_LOG (
PacketTime DateTime,
IndexTime DateTime64,

Am not sure why IndexTime is higher precision, but PacketTime is just seconds.

The PostgreSQL output uses timestamp for both

`CREATE TABLE IF NOT EXISTS DNS_LOG (PacketTime timestamp, IndexTime timestamp,

which is already higher precision, see https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME-INPUT

Maybe the PacketTime column in clickhouse's DNS_LOG could be changed to the higher-resolution https://clickhouse.com/docs/en/sql-reference/data-types/datetime64 as well?

Just changing the data type for the column seems to work.

Clickhouse schema weirdness

I've noticed that on a number of the CH tables you are including timestamp in the order by. Rather than doing this you should probably have a truncated timestamp such as by minute (or at least truncated to per-second) otherwise there's not much point in the MV's compared to just sampling from the raw table itself.

Additionally there are a number of times when you sum() a value such as DoBit which is a UInt8 in the primary table. It would be better to cast those to UInt64 and then sum that to avoid overflows.

Warning Error While logging data on DNStap socket to Click-House

Hi ,
Kindly look into this !!!
Dnsmonster Service.
Jun 22 14:12:50 two dnsmonster[19067]: time="2023-06-22T14:12:50+05:30" level=info msg="Starting DNStap capture"
Jun 22 14:12:50 two dnsmonster[19067]: time="2023-06-22T14:12:50+05:30" level=info msg="listening on DNStap socket unix:///var/cache/bind/dnstap1.sock"
Jun 22 14:12:50 two dnsmonster[19067]: time="2023-06-22T14:12:50+05:30" level=info msg="socket exists, will try to overwrite the socket"
Jun 22 14:12:50 two dnsmonster[19067]: time="2023-06-22T14:12:50+05:30" level=info msg="Creating handler #0"
Jun 22 14:12:50 two dnsmonster[19067]: time="2023-06-22T14:12:50+05:30" level=info msg="Creating handler #1"
Jun 22 14:12:50 two dnsmonster[19067]: time="2023-06-22T14:12:50+05:30" level=info msg="Creating the dispatch Channel"
Jun 22 14:12:50 two dnsmonster[19067]: time="2023-06-22T14:12:50+05:30" level=info msg="Creating Clickhouse Output Channel"
Jun 22 14:12:50 two dnsmonster[19067]: time="2023-06-22T14:12:50+05:30" level=info msg="skipping skipDomains refresh since it's not provided"
Jun 22 14:12:50 two dnsmonster[19067]: time="2023-06-22T14:12:50+05:30" level=info msg="skipping allowDomains refresh since it's not provided"
Jun 22 14:13:00 two dnsmonster[19067]: time="2023-06-22T14:13:00+05:30" level=warning msg="failed to convert metrics to JSON."
Jun 22 14:13:00 two dnsmonster[19067]: 2023-06-22T14:13:00+05:30 metrics:
Jun 22 14:13:00 two dnsmonster[19067]: time="2023-06-22T14:13:00+05:30" level=info msg="ipv4 flushed: 0, closed: 0"
Jun 22 14:13:00 two dnsmonster[19067]: time="2023-06-22T14:13:00+05:30" level=info msg="ipv6 flushed: 0, closed: 0"
Jun 22 14:13:10 two dnsmonster[19067]: time="2023-06-22T14:13:10+05:30" level=warning msg="failed to convert metrics to JSON."
Jun 22 14:13:10 two dnsmonster[19067]: 2023-06-22T14:13:10+05:30 metrics:
Jun 22 14:13:10 two dnsmonster[19067]: time="2023-06-22T14:13:10+05:30" level=info msg="ipv4 flushed: 0, closed: 0"
Jun 22 14:13:10 two dnsmonster[19067]: time="2023-06-22T14:13:10+05:30" level=info msg="ipv6 flushed: 0, closed: 0"
Jun 22 14:13:20 two dnsmonster[19067]: time="2023-06-22T14:13:20+05:30" level=warning msg="failed to convert metrics to JSON."
Jun 22 14:13:20 two dnsmonster[19067]: 2023-06-22T14:13:20+05:30 metrics:
Jun 22 14:13:20 two dnsmonster[19067]: time="2023-06-22T14:13:20+05:30" level=info msg="ipv4 flushed: 0, closed: 0"
Jun 22 14:13:20 two dnsmonster[19067]: time="2023-06-22T14:13:20+05:30" level=info msg="ipv6 flushed: 0, closed: 0"
Jun 22 14:13:30 two dnsmonster[19067]: time="2023-06-22T14:13:30+05:30" level=warning msg="failed to convert metrics to JSON."
Jun 22 14:13:30 two dnsmonster[19067]: 2023-06-22T14:13:30+05:30 metrics:
Jun 22 14:13:30 two dnsmonster[19067]: time="2023-06-22T14:13:30+05:30" level=info msg="ipv4 flushed: 0, closed: 0"
Jun 22 14:13:30 two dnsmonster[19067]: time="2023-06-22T14:13:30+05:30" level=info msg="ipv6 flushed: 0, closed: 0"

File output supporting compression

Fairly simple question, would it be possible to have gzip compression options on the file output option?

Saves me having to use a file watcher on a directory to collect files and compress them prior to AWS S3 upload.

"IPv6 Packet Destination Top 20 Prefix" -- IPv6 addresses are incorrect

In "IPv6 Packet Destination Top 20 Prefix" panel, the IPv6 addresses are incorrect.

e.g. in my panel ,it is showing random IPs.

Screenshot 2022-03-22 at 11 38 28

In csv.go page, the code for converting IPv6 address to decimal is --

SrcIP = binary.BigEndian.Uint64(d.SrcIP[:8]) //limitation of clickhouse-go doesn't let us go more than 64 bits for ipv6 at the moment DstIP = binary.BigEndian.Uint64(d.DstIP[:8])

As per my understanding from above comment, clickhouse is not allowing more than 64 bits for a variable. Is there a way to show correct data on the panel ?

Found wrong sql in grafana example panel.json

When I use grafana panel.json (https://github.com/mosajjal/dnsmonster/blob/main/grafana/panel.json), I found 2 cahrt that grafana can't draw:
image,
Then I found that two SQL statements encountered errors while executing.

SELECT 0, groupArray((IP, total)) FROM (SELECT IPv6NumToString(toFixedString(SrcIP, 16)) AS IP,sum(c) as total FROM DNS_SRCIP_MASK PREWHERE IPVersion=4 WHERE $timeFilter      GROUP BY SrcIP order by SrcIP desc limit 20);
SELECT 0, groupArray((IP, total)) FROM (SELECT IPv6NumToString(toFixedString(SrcIP, 16)) AS IP,sum(c) as total FROM DNS_SRCIP_MASK PREWHERE IPVersion=6 WHERE $timeFilter     GROUP BY SrcIP order by SrcIP desc limit 20)

After converting to regular SQL statements and executing them in ClickHouse, the following error is displayed below:

SELECT
    0,
    groupArray((IP, total))
FROM
(
    SELECT
        IPv6NumToString(toFixedString(SrcIP, 16)) AS IP,
        sum(c) AS total
    FROM DNS_SRCIP_MASK
    PREWHERE IPVersion = 4
    WHERE (DnsDate >= toDate(1697869430)) AND (DnsDate <= toDate(1697880230)) AND (timestamp >= toDateTime(1697869430)) AND (timestamp <= toDateTime(1697880230))
    GROUP BY SrcIP
    ORDER BY SrcIP DESC
    LIMIT 20

Query id: 82ad98fe-6377-4980-9325-a9ca63682f27


0 rows in set. Elapsed: 0.002 sec.

Received exception from server (version 23.3.14):
Code: 48. DB::Exception: Received from localhost:9000. DB::Exception: toFixedString is only implemented for types String and FixedString: While processing IPv6NumToString(toFixedString(SrcIP, 16)) AS IP, sum(c) AS total. (NOT_IMPLEMENTED)
)

7a3c86218e97 :) select * from DNS_SRCIP_MASK

SELECT *
FROM DNS_SRCIP_MASK

Query id: a0453307-81e5-4347-a840-e5cd9381946b

β”Œβ”€β”€β”€β”€DnsDate─┬───────────timestamp─┬─Server──┬─IPVersion─┬─SrcIP─────────────────┬───c─┐
β”‚ 2023-10-21 β”‚ 2023-10-21 06:51:18 β”‚ default β”‚         4 β”‚ ::ffff:172.23.160.1   β”‚ 136 β”‚
β”‚ 2023-10-21 β”‚ 2023-10-21 06:51:18 β”‚ default β”‚         4 β”‚ ::ffff:172.23.162.110 β”‚ 126 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”€DnsDate─┬───────────timestamp─┬─Server──┬─IPVersion─┬─SrcIP───────────────┬─c─┐
β”‚ 2023-10-21 β”‚ 2023-10-21 09:18:32 β”‚ default β”‚         4 β”‚ ::ffff:172.23.160.1 β”‚ 1 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”€DnsDate─┬───────────timestamp─┬─Server──┬─IPVersion─┬─SrcIP─────────────────┬─c─┐
β”‚ 2023-10-21 β”‚ 2023-10-21 09:18:32 β”‚ default β”‚         4 β”‚ ::ffff:172.23.162.110 β”‚ 1 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”˜

dnsmonser not sending packets from live interface to clickhouse

Hi !!

Hope You are doing Well.
I downloaded the latest dnsmonster(v0.9.5) binary from the release section . but dnsmonser not sending packets from live interface to clickhouse.
The error is given Below :--
[4515]: time="2022-10-07T18:11:53+05:30" level=warning msg="Error while executing batch: clickhouse [Append]: clickhouse: expected 18 arguments, got 17"

but in your previous version binary like (v0.9.2 & v0.9.3) is working fine ...

kindly check and do the needful ....

Thanks !!!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.