php form abuse

Discussion in 'PHP' started by amelen, Oct 26, 2007.

  1. #1
    We've been having some abuse on our submit forum and I was looking for suggestions. We put up a CAPTCHA script, but its on the html/java script level. I am guessing the automated scripts can submit directly to the php script and skip the html page all together. So is there a way to make the php script only accept posts from a certain url?

    Thanks!
     
    amelen, Oct 26, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Yes, but this is not reliable either, as the referrer can be faked easily. (in fact, all bots will probably do this by default)


    What I've been working successfully with (until now), are dummy input fields, which are hidden with CSS. The field has no value and is not visible to the user. But the bot will most likely not parse your CSS and check for its visibility, and therefore put a value in it.

    Then in your PHP script you just accept the form submission if the field is really empty. (maybe you don't even show an error, just say the form was submitted successfully)
     
    nico_swd, Oct 26, 2007 IP
  3. Synchronium

    Synchronium Active Member

    Messages:
    463
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Image verification should be PHP only.


    I have a form that used to be abused that sent me email. What happened is the spammers would include their own headers (SMTP injection), so I scanned any input against an array of things like "Mime-type" and "bcc:".

    I also use captcha, referer checking and post the number of spammers that're automatically banned under the form itself - kind of like the heads of your enemies on a spike.
     
    Synchronium, Oct 26, 2007 IP
  4. wisdomtool

    wisdomtool Moderator Staff

    Messages:
    15,826
    Likes Received:
    1,367
    Best Answers:
    1
    Trophy Points:
    455
    #4
    I use some kind of CAPTCHA or use a word verification for eg spell a word the otherway round.....
     
    wisdomtool, Oct 26, 2007 IP
  5. amelen

    amelen Active Member

    Messages:
    686
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    85
    #5
    So that wouldn't help at all? How do the bots know what referral to use?
     
    amelen, Oct 26, 2007 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    I assume you want to submit your own form to your own domain, right?

    Bots usually use the domain which they're currently "working" on as referrer.
     
    nico_swd, Oct 26, 2007 IP
  7. amelen

    amelen Active Member

    Messages:
    686
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    85
    #7
    Yeah. Is there any way to limit the referring as a specific url? So that you can only submit the form from a specific page?
     
    amelen, Oct 26, 2007 IP
  8. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #8
    Theoretically, yes. Practically, no.

    First, because I would assume that the bot uses the URL where the form is on, as referrer.

    And besides that, the referrer (if the user is a normal visitor) is sent by the browser, and some browsers don't send it, and it can be disabled. Therefore it can't be trusted.

    Forget this method, it's not a good way to prevent spam.
     
    nico_swd, Oct 26, 2007 IP
  9. amelen

    amelen Active Member

    Messages:
    686
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    85
    #9
    Makes sense. Thank you for the info!
     
    amelen, Oct 26, 2007 IP
  10. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #10
    How many fields are there?

    Set a timeout, for example if the form is submitted in less than 2 seconds after viewing, then it is a bot.

    Peace,
     
    Barti1987, Oct 26, 2007 IP
  11. baumann93

    baumann93 Peon

    Messages:
    2,268
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #11
    I use the following and it works quite well for me is this.

    When the form is requested, get a session id and a) store it in the session variable and b) send it to be stored in the hidden field on the form. When the form is submitted, compare the value received from the form with the value stored in the session and process the form only if the values are the same.

    my 2c.
     
    baumann93, Oct 26, 2007 IP
  12. bLuefrogx

    bLuefrogx Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Use an image captcha using sessions and compare the two values.
     
    bLuefrogx, Oct 28, 2007 IP