2017-09-11 2 views
0

나는 localhost에있는 웹 사이트에서 일하고 있으며 무료 웹 서버에 업로드하려고 시도했기 때문에 어떤 테스터를 만날 수 있습니다. 웬일인지 제 코드가 악성 코드로보고되어지고 있습니다. 내 바이러스 백신에 의해 차단되었으므로 ERR_CONNECTION_RESET과 별도로 사이트를 방문 할 때 아무 것도 볼 수 없습니다. 이 코드가 맬웨어로 탐지되는 이유에 대해 의견이 있으십니까?PHP 코드가 악성 코드로 신고되었습니다

LOGIN.php

<?php 
include('classes/db.php'); 

if (db::maintenance()) { 
    die('This site is currently going under maintenance, please check back again shortly.'); 
} 

if (isset($_POST['submit'])) { 
    $username = $_POST['username']; 
    $password = $_POST['password']; 

    if (db::query('SELECT username FROM users WHERE username=:username', array(':username'=>$username))) { 
    if (password_verify($password, db::query('SELECT password FROM users WHERE username=:username', array(':username'=>$username))[0]['password'])) { 
     echo "Logged in!"; 
     $cstrong = True; 
     $token = bin2hex(openssl_random_pseudo_bytes(64, $cstrong)); 
     $user_id = db::query('SELECT id FROM users WHERE username=:username', array(':username'=>$username))[0]['id']; 
     db::query('INSERT INTO login_tokens VALUES (NULL, :token, :user_id)', array(':token'=>sha1($token), ':user_id'=>$user_id)); 
     setcookie("SNID", $token, time() + 60 * 60 * 24 * 7, '/', NULL, NULL, TRUE); 
     setcookie('SNID_', '1', time() + 60 + 60 * 24 * 3, '/', NULL, NULL, TRUE); 
     header('Location: index.php'); 
    } else { 
     echo "Incorrect password"; 
    } 
    } else { 
    echo "User not registered!"; 
    } 
} 

?> 

<h1>Login to your account</h1> 

<form action="login.php" method="post"> 
    <input type="text" name="username" value="" placeholder="Username"><p /> 
    <input type="password" name="password" value="" placeholder="Password"><p /> 
    <input type="submit" name="submit" placeholder="Login"><p /> 
</form> 

db.php를 (호스트로 업로드 할 때 I 거짓 데이터의 접속을 변경하고, 올바른 데이터로 변경).

<?php 
class db { 
    private static function connect() { 
    $conn = new PDO('mysql:host=localhost;dbname=users;,charset=utf8', 'root', ''); 
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
    return $conn; 
    } 

    public static function query ($sql, $params = array()) { 
    $statement = self::connect()->prepare($sql); 
    $statement->execute($params); 

    if (explode(' ', $sql)[0] == 'SELECT') { 
    $result = $statement->fetchAll(); 
    return $result; 
    } 
    } 

    public static function notify ($userid) { 
    $notifications = db::query('SELECT forum_members.forum_id, notifications.user_id, notifications.post_id, notifications.forum_id, notifications.post_body, notifications.creation, notifications.type FROM forum_members, notifications WHERE (notifications.forum_id=forum_members.forum_id OR notifications.forum_id=0) AND notifications.user_id=forum_members.user_id ORDER BY notifications.post_id DESC'); 
    return $notifications; 
    } 

    public static function maintenance() { 
    return false; 
    } 
} 
?> 
+0

사용자 정보를 한 번 선택하여 3 번 선택하고 줄에서 얻은 변수를 사용하는 이유는 무엇입니까? – cmorrissey

+0

이것은 첫 번째 마크 업 일뿐입니다. 나중에 다시 살펴볼 때 개선 할 부분이 있습니다. 코드. – morgan

+0

db.php에 무엇이 있습니까? –

답변

1

웹 사이트에 들어가기 위해 어떤 유형의 주소를 사용합니까? PHP 소스는 브라우저에 표시되지 않으므로 PHP는 문제가 아닙니다. 호스트 이름 (예 : 2cc.brad .... net)을 입력하면 localhost/127.0에서 액세스하는 경우 자동으로 초보자 안전을위한 "맬웨어"로 탐지됩니다. 0.1 괜찮을 거에요. 그렇지만, 악성 코드로 표시된 호스트에서 액세스하는 경우, 예기치 않습니다.

+0

그게 문제 인 것 같습니다. 고마워요. – morgan

관련 문제