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 uniq IP restrictions #11

Merged
merged 1 commit into from
Dec 27, 2017
Merged

Conversation

kollyma
Copy link
Contributor

@kollyma kollyma commented Dec 27, 2017

We have blocked several SPAM botnets with this plugin. In addition to the client_uniq_country_login_count we added the client_uniq_ip_login_count filter. This makes this plugin more efficient to protect against smaller/single country bots.

postfwd configuration:

id=ban_botnet_max_uniq_ip
  sasl_username=~^(.+)$
  client_uniq_ip_login_count > 20
  action=rate(sasl_username/1/10800/421 4.7.1: $$sasl_username: too many messages from different IP addresses, try later.)

@Lirt Lirt merged commit 980ba0b into Vnet-as:master Dec 27, 2017
@Lirt
Copy link
Collaborator

Lirt commented Dec 27, 2017

Hello @kollyma,

thank you for contribution. Code looks good from your side. I should do some refactoring and extract functions to keep code more clear later.

Are 20 unique addresses good for production use? What is your experience?

@kollyma
Copy link
Contributor Author

kollyma commented Dec 28, 2017

Thanks @Lirt !
We have had SPAM attacks in every taste :-). The smaller they are, the more difficult to detect. Therefore 20 unique IPs is OK in our case. We started with higher values and decreased in time to avoid false positives.

@Lirt
Copy link
Collaborator

Lirt commented Jan 7, 2019

Hello again @kollyma,

I cannot find your email address, so maybe you will see this here.

I would like to include example postfwd configuration for unique IP address restrictions, that you implemented here.

As you can see, this is current example - https://github.com/Vnet-as/postfwd-anti-geoip-spam-plugin#postfwd-configuration.

Do you also combine country and IP address restrictions? I guess code below could be good?

# Anti spam botnet rule:
#     This example shows how to limit e-mail address defined by `sasl_username`
#     to be able to login from max. 5 different countries AND max. 20 unique
#     IP addresses (both must match!), otherwise it will be blocked from sending messages.
# How items work:
#     Multiple items of the same type in a rule = OR
#     Items of different types in a rule = AND

&&PRIVATE_RANGES { \
   client_address=!!(10.0.0.0/8) ; \
   client_address=!!(172.16.0.0/12) ; \
   client_address=!!(192.168.0.0/16) ; \
};
&&LOOPBACK_RANGE { \
   client_address=!!(127.0.0.0/8) ; \
};

id=CLIENT_LOGIN_COUNT ; \
    sasl_username=~^(.+)$ ; \
    &&PRIVATE_RANGES ; \
    &&LOOPBACK_RANGE ; \
    incr_client_country_login_count != 0 ; \
    action=jump(BAN_BOTNET)

id=BAN_BOTNET ; \
    sasl_username=~^(.+)$ ; \
    &&PRIVATE_RANGES ; \
    &&LOOPBACK_RANGE ; \
    client_uniq_country_login_count > 5 ; \
    client_uniq_ip_login_count > 20 ; \
    action=rate(sasl_username/1/3600/554 Your mail account ($$sasl_username) was compromised. Please change your password immediately.);

@kollyma
Copy link
Contributor Author

kollyma commented Jan 21, 2019

Hello @Lirt

Yes we use it the same way. However we have different messages if account is compromised:

id=ban_botnet_country
  sasl_username=~^(.+)$
  client_uniq_country_login_count > 10
  action=rate(sasl_username/1/10800/554 554: $$sasl_username: too many messages from different countries.)

id=ban_botnet_ip
  sasl_username=~^(.+)$
  client_uniq_ip_login_count > 20
  action=rate(sasl_username/1/10800/554 554: $$sasl_username: too many messages from different hosts)

@kollyma kollyma deleted the uniq_ip_restriction branch January 30, 2019 10:33
Lirt added a commit that referenced this pull request Mar 11, 2019
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.

None yet

2 participants