my server side PHP still got hacked after reCaptcha (hundreds-spam-emails)

♀尐吖头ヾ 提交于 2019-12-02 08:16:42
ViDiVe
  1. You've to sanitizing user input as said @kevin Cai
  2. You've an error in line: if($response.success==false)

    $response=file_get_contents("......");
    
    $result = json_decode($response);
    
    if($result->success==false){
    
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=(SECRETKEY)&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
if($response.success==false)

This fragment of code is an unfortunate bit of nonsense that has found its way into a lot of (terrible) tutorials. It provides no protection whatsoever -- the condition is always false, because $response.success is interpreted as concatenating the constant success to the API response returned by the reCaptcha API. This will cause the CAPTCHA to be always treated as valid, regardless of the user's input.

Use the Google reCaptcha library to verify responses from the reCaptcha API. It is available at: https://github.com/google/recaptcha

You're not sanitizing user input, for one. You should fix that right away as it's a security flaw.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!