Raised This Month: $ Target: $400
 0% 

[Problem] Anti-Spam Lite (Edited version) BUG


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MeinHerzBrennt
Junior Member
Join Date: Oct 2014
Location: Split, Croatia
Old 05-07-2015 , 07:52   [Problem] Anti-Spam Lite (Edited version) BUG
Reply With Quote #1

Hi guys&girls,

I wanted to find the simplest and smallest anti-spam plugin for my server.
That search led me to this plugin -> https://forums.alliedmods.net/showthread.php?t=137697
And as you can see that plugin is now old and the author has "abandoned" it.
So i read those few codes he wrote in that 4 different versions of the plugin,
and in the end i basically rearranged the lines/paragraphs so I would get what i needed.
Below in the spoiler is what i wanted and have edited:
Spoiler


So I combined it and edited few lines to get a plugin which would restrict access
to those who connect to my server with any IP address in their nickname and
it would also restrict to the players to send IP addresses of any other servers
into my server's chat. Tested it a few times, and i was satisfied until i found a
small problem. The plugin restricts connection to the server to those who have
word "depres" in their nickname. I don't understand how that happens or why
that word or combination of letters is exactly the problem, so if there is anyone
who would read this novel of mine and help me out a bit i would be very grateful!

Thanx in advance and sorry if I've done anything that breaks the rules of this board
'cause I'm relatively new here and this is my first topic, be gentle to the new guy!

Greet's!

Last edited by MeinHerzBrennt; 05-07-2015 at 10:24.
MeinHerzBrennt is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 05-09-2015 , 16:20   Re: [Problem] Anti-Spam Lite (Edited version) BUG
Reply With Quote #2

Quote:
The plugin restricts connection to the server to those who have word "depres" in their nickname.
seriously?

Last edited by Depresie; 05-09-2015 at 16:21.
Depresie is offline
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 05-09-2015 , 17:01   Re: [Problem] Anti-Spam Lite (Edited version) BUG
Reply With Quote #3

Man , i see that the regex in useless here because its check numbers & point & If there is 3 num in the last address of the ip . Anyway my point is if its checking the ip like this it should match at least it should detect space in IP etc .. Why doing it like this if you can do something like this

Ps : im right now phone but i will do my best

add stock bool for _IpCheck[] ( as string )

for (new i = 0; _IpCheck[i]; i++)
if (’0’ <= _IpCheck[i] <= ’9')

Or just loop { 9 , 8 , ... } and do contains ( its like a countdown ( 9 8 7 .. 0 ) it will check all num

And retrun it true and then return the final statement ( return false )

And add a check if ~contains( bitwise . Flip num ) string with "." .


Anyway for your problem regex will be the better way if i remember as well . I have done it before in a 8 ( len ) with regex of course just check the digit \d all add a + and check the space \s and so one . So just search for regular expressions and create yours . And then try to match result in a online regex compiler .
then just hook say & say_team and check if ( _IpCheck(argHERE) ) and then the same think in Infochanged event . Hope i help you ( im really aorry if i didnt make it clear for you , as i said im phone ) ... Any Q just post .
Freezo Begin is offline
MeinHerzBrennt
Junior Member
Join Date: Oct 2014
Location: Split, Croatia
Old 05-09-2015 , 19:28   Re: [Problem] Anti-Spam Lite (Edited version) BUG
Reply With Quote #4

@Depresie
Unfortunately yes, the plugin hates you :'D

@Freezo Begin
First of all thanks for the response and your time. As I said I'm not the original author of the plugin.
So why the code was written like that or which method the author used I really don't know :/
I liked that one among many others because it's really light for the server, almost invisible..
No errors also and it really does exactly what I need except for that small bug where it
kicks players who have "depres" in that order in their nickname, that's why I turned it off..

Amxx compiling isn't my domain really, i have learnt a bit of c++ and c# but have no experience with amxx+C
So if this was a request for a plugin i would have requested a fix for that word bug and i guess a safety
switch, like those who have immunity (a flag), that plugin ignores them if it's possible. But then again I
guess I'm asking too much, anyway i understood what you're saying but I'm unexperienced to apply that

Last edited by MeinHerzBrennt; 05-09-2015 at 19:34.
MeinHerzBrennt is offline
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 05-10-2015 , 06:58   Re: [Problem] Anti-Spam Lite (Edited version) BUG
Reply With Quote #5

This is my fast edit :

Code:
#include <amxmodx> #include <amxmisc> #define skipOthers(%0)   ( is_user_bot(%0) || is_user_hltv(%0) || is_user_admin(%0) ) /*  Equal is the same as cotain so it could be like this also     ( contain( string , %0 )  != 0x01) ... */ #define isEqual(%0)   contain(  string , %0 ) // remember that its declare by the name of string public plugin_init() {     register_plugin( "Anti ..." , "0.1" , "Freezo" )         register_clcmd( "say" , "hookSay")     register_clcmd( "say_team" , "hookSay")     } public client_infochanged( id ) {         if ( skipOthers(id) ) return 1         if (_IsValid( getUsername(id) ) )   server_cmd ("kick #%d Disallowed nickname!" , get_user_userid(id) )         return 0     } public client_putinserver( id ){         if( skipOthers(id) ) return 1         if (_IsValid( getUsername(id) ) ) server_cmd ("kick #%d Disallowed nickname!" , get_user_userid(id) )         set_task ( 20.0 , "showWarnings" , id )     return 0 } public hookSay( id ){     new args[ 168 ]     read_args(  args , charsmax(args) )         if( _IsValid( args ) ) return 1     return 0 } public showWarnings( id ) client_print ( id , print_chat , "Advertising other servers or websites is strictly prohibited!") stock bool:_IsValid( const string[] ) {         for (new i = 0; string[i] ; i++ ){         if ( ('0' <= string[i] <= '9') && ( spaceCheck( string ) || ~isEqual(".") || ~isEqual(",") || ~isEqual("-") ) ){             return true         }     }     return false } stock bool:spaceCheck ( const string[] ){     new a     while (  a < strlen ( string ) ){         if (string[a++] == ' ') return true     }       return false } stock getUsername( index ){     new szName[32]     get_user_name ( index , szName , charsmax ( szName ))         return szName }
Freezo Begin is offline
MeinHerzBrennt
Junior Member
Join Date: Oct 2014
Location: Split, Croatia
Old 05-10-2015 , 12:24   Re: [Problem] Anti-Spam Lite (Edited version) BUG
Reply With Quote #6

Again thank you for this, tested it on my private server, gotta say it works nice with no errors.
Also does what i needed but has a few flaws. For example any 2+ digit numbers written like 12 13
won't be displayed or if someone has nickname "Player.92" he will also be kicked, while in the last
plugin that wasn't the case and those small things impressed me in a good way. I don't know if
it's because of the regex or as you said it's just a fast edit, but anyway it's also very good and
thanks once again. Those flaws are maybe minor but for a public server and 30 players it makes
a difference unfortunately, I really don't want to harrass you with this but that's my honest review

Best regards!

Last edited by MeinHerzBrennt; 05-10-2015 at 12:24.
MeinHerzBrennt is offline
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 05-10-2015 , 16:43   Re: [Problem] Anti-Spam Lite (Edited version) BUG
Reply With Quote #7

Alright !

I made this simple one replace it in the regex_match

Code:
\b(?:\d{1,3}(\,|\<|\>|\~|\«|\»|\=|\.|\s|\*|\')){3}\d{1,3}\b
Detect :
Player.127.0.0.1

Player.127.13=12-13
127 0 0 1

Undetect more than 4 regrp {4}
127.0.0.0.1 = invalid
Freezo Begin is offline
MeinHerzBrennt
Junior Member
Join Date: Oct 2014
Location: Split, Croatia
Old 05-10-2015 , 18:54   Re: [Problem] Anti-Spam Lite (Edited version) BUG
Reply With Quote #8

PHP Code:
new Regex:regex regex_match (text"\b(?:\d{1,3}(\,|\<|\>|\~|\«|\»|\=|\.|\s|\*|\')){3}\d{1,3}\b"numerror49"i"
Like this?

Last edited by MeinHerzBrennt; 05-10-2015 at 19:11.
MeinHerzBrennt is offline
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 05-10-2015 , 19:38   Re: [Problem] Anti-Spam Lite (Edited version) BUG
Reply With Quote #9

Code:
#include <amxmodx> #include <amxmisc> #include <regex> // Preprocessor macros (Config) #define KICK_NICK_REASON "Spam in nick!" #define IN_GAME_WARNING_MSG    "Advertising other servers or web sites is strictly prohibited!" #define KICK_MSG_REASON "Spam message!" #define MSG_BLOCK_INFO "Advertising on your behalf, please do not advertise other sites/servers" public plugin_init() {     register_plugin("Anti-Spam Lite", "1.0.4", "NullWarez")     register_clcmd("say","check_player_msg")     register_clcmd("say_team","check_player_msg") } // Check the nick when connecting public client_connect(id) {     if(is_user_admin(id))         return PLUGIN_CONTINUE     new g_name[32]     get_user_name(id, g_name,31)     if(is_invalid(g_name))     {         server_cmd("kick #%d Disallowed nickname!", get_user_userid(id))         return PLUGIN_CONTINUE     }     set_task(20.0, "showWarning", id)     return PLUGIN_CONTINUE } // Checks the message for spam bool:is_invalid(const text[]) {     new error[168], num     new Regex:regex = regex_match (text, "\b(?:\d{1,3}(\,|\<|\>|\~|||\=|\.|\s|\*|\')){3}\d{1,3}\b", num, error, charsmax(error))     if(regex >= REGEX_OK)     {         regex_free(regex)         return true     }     return false } // Displays a warning ban for spam public showWarning(id) {     if(is_user_connected(id))         client_print(id, print_chat, "Advertising other servers or web sites is strictly prohibited!") } // Check say or say_team message public check_player_msg(id) {     if(is_user_admin(id))         return PLUGIN_CONTINUE     new text[128]     read_args(text,127)     if(is_invalid(text))     {         client_print(id, print_chat, "Advertising other servers or web sites is strictly prohibited!")         return PLUGIN_HANDLED     }     return PLUGIN_CONTINUE } // Called when set name public client_infochanged(id) {     if(is_user_admin(id))         return PLUGIN_CONTINUE     if(!is_user_alive(id)) // loop fix         return PLUGIN_CONTINUE     new g_name[32]     get_user_name(id, g_name,31)     if(is_invalid(g_name))     {         server_cmd("kick #%d Disallowed nickname!", get_user_userid(id))         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE }

Edit : Or just use this

Code:
\d+(\.|\s|\+|_|\:|,)\d(\.|\s|\+|_|\:|,)\d(\.|\s|\+|_|\:|,)\d(\.|\s|\+|_|\:|,)\d+

Last edited by Freezo Begin; 05-11-2015 at 06:44.
Freezo Begin is offline
MeinHerzBrennt
Junior Member
Join Date: Oct 2014
Location: Split, Croatia
Old 05-11-2015 , 07:04   Re: [Problem] Anti-Spam Lite (Edited version) BUG
Reply With Quote #10

Works fine when I edit it like this
Spoiler


But when i try out your last edit it doesn't work, I can send IP addresses to chat in any way.
I see that you deleted the second part of regex, so I'm guessing the problem is in that part :/
But anyway it works edited like in the code above, I can't stress enough how thankful I am..!
Appreciate it!
MeinHerzBrennt is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:05.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode