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

Add bcc and dontsend capabilities to xarf-login-attack action #2924

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

K2IE
Copy link

@K2IE K2IE commented Feb 1, 2021

This PR provides the ability to specify an optional bcc for the generated abuse emails. It also provides the ability to provide an array of abuse addresses for which no email should be generated. This solves the problem of published abuse addresses which bounce the mail back to the sender or, as in the case of lacnicnet, say that they cannot assist because the are a regional allocation registry.

The dontsend array is specified in jail.local as:

dontsend = ( 'one@address.com' 'two@address.com' 'three@address.com')

The bcc is specified in jail.local as:

bcc = someaddress@myhost.com

Then xarf-login-attack is called as usual, with either of the new optional parameters passed as desired:

action = %(action_)s
         xarf-login-attack-local[mailargs=%(mailargs)s,mailcmd=%(mailcmd)s,bcc="%(bcc)s",dontsend="%(dontsend)s"]

I also removed a redundant IFS operation on $ADDRESSES.

Resolves #2919 and #2920 .

@sebres
Copy link
Contributor

sebres commented Feb 1, 2021

Just by the way, please note an amendment to PR description:

-xarf-login-attack-local[mailargs=%(mailargs)s,mailcmd=%(mailcmd)s,bcc=%(bcc)s,dontsend=%(dontsend)s]
+xarf-login-attack-local[mailargs=%(mailargs)s,mailcmd=%(mailcmd)s,bcc="%(bcc)s",dontsend="%(dontsend)s"]

without quotes it would supply wrong (truncated) arguments to the action.

@sebres
Copy link
Contributor

sebres commented Feb 1, 2021

I also removed a redundant IFS operation on $ADDRESSES.

Why it should be redundant (now)? I don't see any code piece that could solve #2372, which could occur again if you would remove this "redundant" operation.

@K2IE
Copy link
Author

K2IE commented Feb 1, 2021

@sebres thanks for your comment. I have tested extensively without the suggested double-quotes and have no experienced truncation of the arguments, verified by dumping the received arguments to a tempfile for debugging. Can you please point me in the direction what I'm failing to understand?

@K2IE
Copy link
Author

K2IE commented Feb 1, 2021

I also removed a redundant IFS operation on $ADDRESSES.

Why it should be redundant (now)? I don't see any code piece that could solve #2372, which could occur again if you would remove this "redundant" operation.

I was unaware of #2372. I will re-add that operation.

@sebres
Copy link
Contributor

sebres commented Feb 1, 2021

Can you please point me in the direction what I'm failing to understand?

$ python -c 'from fail2ban.helpers import extractOptions; an, ao = extractOptions("""some-action[a="x, y, z", b=x, y, z]"""); print(ao)'
{'a': 'x, y, z', 'b': 'x'}

as you can see a contains whole string as enclosed in quotes x, y, z, whereas b contains only x.
As an option value (without quote) only single "word" is allowed (and it cannot contains comma, space or [] characters).

As for "not experienced truncation", it is a matter of sequence, so how (or rather when exactly) %(dontsend)s gets substituted
and I'm pretty sure this gets interpolated before it is supplied as parameter to the action in the jail, so it becomes:

- [..., dontsend=%(dontsend)s]
+ [..., dontsend=( 'one@address.com' 'two@address.com' 'three@address.com')]

But... trying this:

$ python -c 'from fail2ban.helpers import extractOptions; an, ao = extractOptions("""some-action[a=(one@address.com two@address.com three@address.com)]"""); print(ao)'
{'a': '(one@address.com two@address.com three@address.com)'}

I see it is indeed correct, so space (alone) is not a separator anymore at least in last version (I changed this extractOptions several times).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggestion: bcc parameter for xarf-login-attack
2 participants