Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postfix decoder: Making ending doubled dot optional #245

Merged
merged 4 commits into from Dec 17, 2019
Merged

Postfix decoder: Making ending doubled dot optional #245

merged 4 commits into from Dec 17, 2019

Conversation

iasdeoupxe
Copy link
Contributor

Dec 14 22:23:34 myhost postfix/smtpd[27266]: warning: hostname other.host does not resolve to address 1.2.3.4

Copy link
Contributor

@Lopuiz Lopuiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @iasdeoupxe,
First, sorry for the late answer.
Thank you for your contribution. We are going to considerate this correction to next releases.

kind regards, Eva

@Lopuiz Lopuiz changed the base branch from master to 3.10 May 23, 2019 08:13
@iasdeoupxe
Copy link
Contributor Author

I'm not absolutely sure if this is the way to go / implement this because if the ending doubled dot is there the \S+ operator might match this in the IP?

@Lopuiz
Copy link
Contributor

Lopuiz commented Jun 5, 2019

Yes, you're right. I will study the way to match your log Dec 14 22:23:34 myhost postfix/smtpd[27266]: warning: hostname other.host does not resolve to address 1.2.3.4 with the decoder postfix-warning

Copy link
Contributor

@Lopuiz Lopuiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ending doubled dot will be added in the IP.
Thank you for your correction

@Lopuiz
Copy link
Contributor

Lopuiz commented Jun 6, 2019

Hello @iasdeoupxe,

How about this regex?
<regex>^warning: (\S+):|warning: Illegal address syntax from unknown[(\S+)]|warning: hostname \S+ does not resolve to address (\d+.\d+.\d+.\d+)</regex>

Dec 14 22:23:34 myhost postfix/smtpd[27266]: warning: hostname other.host does not resolve to address 1.2.3.4:


**Phase 1: Completed pre-decoding.
       full event: 'Dec 14 22:23:34 myhost postfix/smtpd[27266]: warning: hostname other.host does not resolve to address 1.2.3.4:'
       timestamp: 'Dec 14 22:23:34'
       hostname: 'myhost'
       program_name: 'postfix/smtpd'
       log: 'warning: hostname other.host does not resolve to address 1.2.3.4:'

**Phase 2: Completed decoding.
       decoder: 'postfix'
       srcip: '1.2.3.4'

**Phase 3: Completed filtering (rules).
       Rule id: '3398'
       Level: '6'
       Description: 'Postfix: Illegal address from unknown sender'
**Alert to be generated.

If you agree you can commit it yourself

Regards, Eva

@Lopuiz Lopuiz changed the base branch from 3.10 to 3.9 June 6, 2019 13:14
@iasdeoupxe
Copy link
Contributor Author

Mhhh, but this is then only catching IPv4 addresses and would miss the IPv6 ones. Not sure but we probably need to have regex which matches both?

@Lopuiz
Copy link
Contributor

Lopuiz commented Jun 11, 2019

@iasdeoupxe
you could create multiple decoders that match IPv4 or IPv6

@iasdeoupxe
Copy link
Contributor Author

Any suggestion for a IPv6 regex? I'm currently not even sure if such a complex regex like e.g. suggested in https://stackoverflow.com/a/17871737 is even possible with the Wazuh ruleset regex.

@Lopuiz
Copy link
Contributor

Lopuiz commented Jun 17, 2019

No, this regex doesn't work

@iasdeoupxe
Copy link
Contributor Author

iasdeoupxe commented Aug 23, 2019

So i'm currently stuck on how to proceed with this. Any suggestions on a regex which could match IPv4 AND IPv6 where the ending doubled dot could be removed?

@iasdeoupxe
Copy link
Contributor Author

Could something like this working?

<regex>^warning: (\S+):|warning: Illegal address syntax from unknown[(\S+)]|warning: hostname \S+ does not resolve to address (\S+): |warning: hostname \S+ does not resolve to address (\S+)</regex>

Description:

If there is an ending dot in the regex the second one will match and isn't extracting the double dot into the IP, if there is no ending doubled dot the third regex will kick in.

@iasdeoupxe
Copy link
Contributor Author

It looks indeed that this could work (ossec-logtest output with the suggested regex above).

Dec 14 22:23:34 myhost postfix/smtpd[27266]: warning: hostname other.host does not resolve to address 1.2.3.4


**Phase 1: Completed pre-decoding.
       full event: 'Dec 14 22:23:34 myhost postfix/smtpd[27266]: warning: hostname other.host does not resolve to address 1.2.3.4'
       timestamp: 'Dec 14 22:23:34'
       hostname: 'myhost'
       program_name: 'postfix/smtpd'
       log: 'warning: hostname other.host does not resolve to address 1.2.3.4'

**Phase 2: Completed decoding.
       decoder: 'postfix'
       srcip: '1.2.3.4'

**Phase 3: Completed filtering (rules).
       Rule id: '3398'
       Level: '6'
       Description: 'Postfix: Illegal address from unknown sender.'
**Alert to be generated.

and:

Dec 14 22:23:34 myhost postfix/smtpd[27266]: warning: hostname other.host does not resolve to address 1.2.3.4: no address associated with name

**Phase 1: Completed pre-decoding.
       full event: 'Dec 14 22:23:34 myhost postfix/smtpd[27266]: warning: hostname other.host does not resolve to address 1.2.3.4: no address associated with name'
       timestamp: 'Dec 14 22:23:34'
       hostname: 'myhost'
       program_name: 'postfix/smtpd'
       log: 'warning: hostname other.host does not resolve to address 1.2.3.4: no address associated with name'

**Phase 2: Completed decoding.
       decoder: 'postfix'
       srcip: '1.2.3.4'

**Phase 3: Completed filtering (rules).
       Rule id: '3398'
       Level: '6'
       Description: 'Postfix: Illegal address from unknown sender.'
**Alert to be generated.

@iasdeoupxe
Copy link
Contributor Author

iasdeoupxe commented Aug 23, 2019

Changed the PR in 4cb0cc7 with the suggested change from #245 (comment). Found the log entry with the ending doubled dot in https://www.linuxquestions.org/questions/linux-server-73/how-i-can-resolve-the-error-postfix-warning-hostname-does-not-resolve-to-address-4175455058/

@Lopuiz This could be reviewed again. I have also changed the base branch to 3.10 as it seems 3.9 was already released since i had created this PR 9 months ago.

@iasdeoupxe iasdeoupxe changed the base branch from 3.9 to 3.10 August 23, 2019 09:29
@chemamartinez chemamartinez added this to In progress in Wazuh 3.11.0 via automation Aug 29, 2019
@Lopuiz Lopuiz self-requested a review August 29, 2019 10:55
@Lopuiz
Copy link
Contributor

Lopuiz commented Aug 29, 2019

Hi!

I review it as soon as possible and it will merge in 3.11.
Thanks.

Regards,
Eva

@iasdeoupxe
Copy link
Contributor Author

@Lopuiz Any updates on a review? Three months+ for such a minor change is a quite long time frame 😢

@Lopuiz Lopuiz changed the base branch from 3.10 to 3.11 December 17, 2019 14:19
@bah07 bah07 merged commit 212f37a into wazuh:3.11 Dec 17, 2019
Wazuh 3.11.0 automation moved this from In progress to Done Dec 17, 2019
@iasdeoupxe iasdeoupxe deleted the patch-2 branch December 17, 2019 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Wazuh 3.11.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants