LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Postfix block email with asian characters (https://www.linuxquestions.org/questions/linux-server-73/postfix-block-email-with-asian-characters-4175712786/)

AsgAnquietas 05-30-2022 05:20 AM

Postfix block email with asian characters
 
Hello,

We have an email server running Dovecot and Postfix.

I recieve a lot of spam email containing wierd chinese/japanese or other asian characters.

We don't need these emails in our organization and we do not communicate with people using asian characters.

How can we instruct Postfix to block out all emails containing asian characters ?

We already use "body_checks" to discard email containing some regex strings... but how can we do it for asian characters ?

Code:

Server [/etc/postfix] # cat body_checks
/free mortgage quote/    DISCARD
/repair your credit/      DISCARD
/From:.*<>/        DISCARD
Server [/etc/postfix] # cat main.cf |grep body
body_checks = pcre:/etc/postfix/body_checks
Server [/etc/postfix] #


TB0ne 05-30-2022 09:27 AM

Quote:

Originally Posted by AsgAnquietas (Post 6357496)
Hello,
We have an email server running Dovecot and Postfix. I recieve a lot of spam email containing wierd chinese/japanese or other asian characters. We don't need these emails in our organization and we do not communicate with people using asian characters. How can we instruct Postfix to block out all emails containing asian characters ?

We already use "body_checks" to discard email containing some regex strings... but how can we do it for asian characters ?

Code:

Server [/etc/postfix] # cat body_checks
/free mortgage quote/    DISCARD
/repair your credit/      DISCARD
/From:.*<>/        DISCARD
Server [/etc/postfix] # cat main.cf |grep body
body_checks = pcre:/etc/postfix/body_checks
Server [/etc/postfix] #


Put a content check in place to scan for the desired character sets, either in the header/subject/content-type. And which asian characters? More than one set, since that encompasses Japanese, Chinese, and Korean. You've already got rules in place, so adding one more shouldn't be a problem, especially since you've been working with postfix for a while now.

AsgAnquietas 07-28-2022 12:16 PM

ok, how can I do this ?

This seems so nice in theory, but what must I physically do ? :-))

TB0ne 07-28-2022 12:27 PM

Quote:

Originally Posted by AsgAnquietas (Post 6370478)
ok, how can I do this ? This seems so nice in theory, but what must I physically do ? :-))

Did you try reading the Postfix documentation on content checking???
https://www.postfix.org/CONTENT_INSPECTION_README.html

May want to check your thread on the Ubuntu forums (which came up from a Google search for your question), where you were provided a filter.
https://askubuntu.com/questions/1411...ian-characters

AsgAnquietas 07-28-2022 12:27 PM

Also, I have discovered that some emails are encoded in Base64. This, effectively, bypasses the checks. How can I check for base64 encoded strings of asian characters ?

TB0ne 07-28-2022 12:53 PM

Quote:

Originally Posted by AsgAnquietas (Post 6370482)
Also, I have discovered that some emails are encoded in Base64. This, effectively, bypasses the checks. How can I check for base64 encoded strings of asian characters ?

...which is the same thing you asked in your other thread, and don't acknowledge. Again, read the postfix docs..you can use body_check for such things, or use amavis/spamassassin.

AsgAnquietas 07-29-2022 07:59 AM

In esence, I'm back to square one...

1. The Postfix documentation is so hard to understand, I need a practical solution - I thought there is a quick fix since I believe I'm not the only one experiencing problems with asian characters... OK, i'll read the docs... I was hoping for a quick fix...
2. If you look closely to my reply on Ubuntu Forums, I have specifically written the fact that a specific line from the given solution does not work...
3. Regarding decoding of base64, I didn't find anything...

TB0ne 07-29-2022 08:53 AM

Quote:

Originally Posted by AsgAnquietas (Post 6370597)
In esence, I'm back to square one...

1. The Postfix documentation is so hard to understand, I need a practical solution - I thought there is a quick fix since I believe I'm not the only one experiencing problems with asian characters... OK, i'll read the docs... I was hoping for a quick fix...
2. If you look closely to my reply on Ubuntu Forums, I have specifically written the fact that a specific line from the given solution does not work...
3. Regarding decoding of base64, I didn't find anything...

So:
  1. You're essentially asking others to read the docs and only pull out the pieces you need, rather than you doing it. If you use the search terms given you to, you'll find examples; start there.
  2. If you look closely, saying "does not work" isn't much of a problem description. Further, if you put MORE character sets in, as opposed to just the ones in the example, then it'll filter more, wouldn't it??
  3. You were handed a search term, and a link to the docs specifically related to content inspection. You were given names of programs that DO THIS.

AsgAnquietas 07-29-2022 12:29 PM

With all due respect, it seems that the Forum is not much help for "read read read".
I came to the forums seeking a proven solution, in case anyone already dealt with this issue.
I do not ask others to read for me ! This is called misjudging. I learned to read when I was 4 :-)
The ideea was to obtain a quick fix IF someone else already encountered the problem - I assume that is also the role of a Forum - to ask quick help, if available :-)
I assume anyone can read :-)
OK, back to reading manuals. Thank you.

TB0ne 07-29-2022 12:41 PM

Quote:

Originally Posted by AsgAnquietas (Post 6370646)
With all due respect, it seems that the Forum is not much help for "read read read". I came to the forums seeking a proven solution, in case anyone already dealt with this issue. I do not ask others to read for me ! This is called misjudging. I learned to read when I was 4 :-) The ideea was to obtain a quick fix IF someone else already encountered the problem - I assume that is also the role of a Forum - to ask quick help, if available :-) I assume anyone can read :-)
OK, back to reading manuals. Thank you.

And with all due respect, the forum is here if you're needing HELP...not wanting to read the instructions/claim they're 'hard to understand', etc., and wanting someone else to read them for you doesn't fall within that realm.

You were given a filter on your other thread, in another forum...all you've said is it "doesn't work". Nothing about WHAT isn't working/how/why, or what you've actually tried to MAKE IT WORK. Again, if it's not filtering everything, then expand the character sets. This is all information you can look up for yourself, and (since you don't actually give us details about what's not working), that's all we can tell you isn't it??? Should we guess as to what it's not doing??

You asked about content filtering; again, that's covered in the postfix docs...can you show us what YOU have done to try to accomplish this?? Have you looked at the things you were given/had looked up for you regarding amavis/spamassassin, to do exactly what you're after???

Forums are here to help people help themselves. This is like asking someone to help you paint your house, only for you to sit in a chair and watch them...that's not help...that's having it done for you.

AsgAnquietas 07-29-2022 12:53 PM

I have tried - with no result. I always try to solve my problems before posting in the forums. Usually, the forums are the last place to try to ask help, and after all other attempts failed.

The problem is simple: I want to filter asian characters.

Here is my header_checks file:
Code:

/free mortgage quote/    DISCARD
/repair your credit/      DISCARD

Here is my body_checks file:
https://pastebin.com/mF0VLCzY

The filtering works great if I test any asian character from the list in the body_checks file.

The problem is that I receive emails which ENCODE with Base64 (the Email client displays the asian character but the Message Source is Encoded in Base64).
For example: 連 in Base64 is "6YCj"
And my message source is full of Base64 encoded text.

I have also tried these:
Code:

/^Subject:.*=\?(?:GB2312|big5)\?/  DISCARD
/^Content-Type:.*\bcharset="?(?:GB2312|big5)\b/  DISCARD
/(?:[a-z0-9]?[\200-\377]){8,}/  DISCARD

It gives me the following problem:
Code:

postmap: warning: header_checks, line 5: unbalanced '"' in '/^Content-Type:.*\bcharset="?(?:GB2312|big5)\b/  DISCARD' -- ignoring this line
Also, if I leave these in header_checks, it still doesn't filter the base64-encoded characters...

TB0ne 07-29-2022 01:09 PM

Quote:

Originally Posted by AsgAnquietas (Post 6370650)
I have tried - with no result. I always try to solve my problems before posting in the forums. Usually, the forums are the last place to try to ask help, and after all other attempts failed.

...and if you don't actually show us what you've done/tried, how exactly do you expect us to know???
Quote:

The problem is simple: I want to filter asian characters. Here is my header_checks file:
Code:

/free mortgage quote/    DISCARD
/repair your credit/      DISCARD

Here is my body_checks file:
https://pastebin.com/mF0VLCzY

The filtering works great if I test any asian character from the list in the body_checks file.
Great...so the asian character filtering DOES work, which isn't what you indicated previously.
Quote:

The problem is that I receive emails which ENCODE with Base64 (the Email client displays the asian character but the Message Source is Encoded in Base64). For example: 連 in Base64 is "6YCj" And my message source is full of Base64 encoded text. I have also tried these:
Code:

/^Subject:.*=\?(?:GB2312|big5)\?/  DISCARD
/^Content-Type:.*\bcharset="?(?:GB2312|big5)\b/  DISCARD
/(?:[a-z0-9]?[\200-\377]){8,}/  DISCARD

It gives me the following problem:
Code:

postmap: warning: header_checks, line 5: unbalanced '"' in '/^Content-Type:.*\bcharset="?(?:GB2312|big5)\b/  DISCARD' -- ignoring this line

...meaning that you have a syntax/mismatch in that file...meaning you need to go fix it. It's not only telling you what the problem is, but what line it's on. Hard to be more clear than that...have you actually LOOKED at the file? The error is very clear in what you posted.
Quote:

Also, if I leave these in header_checks, it still doesn't filter the base64-encoded characters...
Right, which takes us back to "use one of the tools that were given to you before". AGAIN: amavis/spamassassin do these things, and you've been using spamassassin for a while now. Implement the content filter there, or AGAIN, read the documentation on content inspection.

AsgAnquietas 08-11-2022 09:27 AM

I've corrected that syntax problem, however, it still doesn't filters asian chars.
I will try with SpamAssassin.

TB0ne 08-11-2022 09:39 AM

Quote:

Originally Posted by AsgAnquietas (Post 6373182)
I've corrected that syntax problem, however, it still doesn't filters asian chars. I will try with SpamAssassin.

Great how you followed up after having it pointed out to you. Also, you said before it *DID* filter asian characters (post #11, where you said it did), and that you were needed ADDITIONAL filtering, which postfix doesn't do.

Again: you have been using spamassassin for years, which does attachment filtering/inspection...you were given a link to another program as well.

AsgAnquietas 08-11-2022 09:41 AM

Thank you for pointing it out.
I mean it filters asian chars if the email is plain email.
If the content is Base64 encoded and the email client decodes the Base64 content, then the filtering has no effect.


All times are GMT -5. The time now is 05:00 PM.