-2

I have laravel application which having some forms that end user can fill, the forms also protected by google invisible captcha.

but after some time i am getting some malicious records to be inserted via forms, some dirty words.unrelated content just like,

Viagra Extra Dose Amoxicillin Bronchitis Dosage Cephalexin And Side Effects In Children buy generic cialis Prix Viagra 25 Milligrams Achat Viagra Paris Cialis Prezzo Controindicazioni

How can i prevent this, how can i avoid user to insert those dirty words. please suggest.

Ritesh Khatri
  • 1,253
  • 13
  • 29
  • Look at adding a honeypot field: https://dev.to/felipperegazio/how-to-create-a-simple-honeypot-to-protect-your-web-forms-from-spammers--25n8 – Brett Gregson Aug 16 '19 at 12:40
  • Use some sort of CAPTCHA. – user3783243 Aug 16 '19 at 12:43
  • 2
    Possible duplicate of [How to prevent robots from automatically filling up a form?](https://stackoverflow.com/questions/2387496/how-to-prevent-robots-from-automatically-filling-up-a-form) – user3783243 Aug 16 '19 at 12:45
  • hi @user3783243 thanks for reply. please try to understand what my question is, then after mark it as duplicate. its not duplicate bro.. please check i have mentioned that i am already using google's invisible captcha, and i know it prevents bot attach, but my question is i am receiving some disgusting contents from end user. how can i restrict user to insert that type of content. – Ritesh Khatri Aug 16 '19 at 12:55
  • That is a bot, I suspect your CAPTCHA is not configured correctly. If you are just asking how to implement a black list there are tens of thousands of tutorials that demonstrate that. https://stackoverflow.com/questions/6549197/php-form-curse-word-input-filter-solution https://stackoverflow.com/questions/11523742/php-filter-bad-words https://stackoverflow.com/questions/273516/how-do-you-implement-a-good-profanity-filter – user3783243 Aug 16 '19 at 13:11

1 Answers1

0

Pretty much the only thing you can do is to blacklist specific words. You can use this https://www.freewebheaders.com/full-list-of-bad-words-banned-by-google/ blacklist for example and foreach over it and

if(str_pos($user_input, $current_blacklist_word)){ //show Error }

mapawa
  • 179
  • 1
  • 4
  • 16
  • `strpos` usage is incorrect and this is wrong. There is more that can be done. Also you should read about https://en.wikipedia.org/wiki/Scunthorpe_problem – user3783243 Aug 16 '19 at 12:44