PyInstaller создает исполняемый файл, помеченный как троянский - PullRequest
0 голосов
/ 20 сентября 2019

как всегда при изучении нового языка программирования, я делаю глупую игру и наполняю ее множеством ненужных вещей.Просто чтобы узнать, что возможно и как работает синтаксис.После этого я искал способ скомпилировать его в файл .exe.Сделано с PyInstaller..Exe работает отлично, как и ожидалось.

Я отправляю его другу, чтобы проверить, является ли этот .exe независимым и работает без Установленного интерпретатора Python.Он прислал мне фотографию своего Windows 10, который сводит с ума, потому что он обнаруживает троян в моем файле.

Я проверил свою Систему.Никакой инфекции на моей стороне.Затем я загрузил .exe в Virustotal.Вот результат: https://www.virustotal.com/gui/file/3fa6cbe0c5cb154d70d3db1ca3029a9010853a87241a3b52cb30b4c23f55d729/detection

Обычно меня не волнует файл, который поднимается на 9 из 67 обращений, большинство из которых - только догадки.Но в этом случае .exe только для одной цели.И это Windows.

Вот код:

from random import randint as rInt
import time
import logging

game = {"winNumber": rInt(1, 100), "guessedNumber": 0, "lastGuess": 0, "tries": 8, "triesLeft": 8, "state": "None", "won": 0, "lost": 0, "round": 1, "debugMode": False}

def checkInput(uInput):
    """Checks user Inputs if they are valid numbers. Then a second check if the number is in between 1 and 100. Returns TRUE if successfull"""
    try:
        uInput = int(uInput)
    except ValueError:
        logger.info(f"User has tried to enter: {uInput} and failed.")
        print("This is not a number!")
    else:
        if uInput not in range(1, 101):
            print("With this number you will definitely loose the game, because it is not between 1 and 100")
            logger.info(f"User has entered the Number {uInput}")
        else:
            game["guessedNumber"] = uInput
            return True


def restartGame():
    answer = input ("Do you want to play again? (y/n)")
    if answer.lower() == "y":
        print ("Leeeeet's get ready tooooo guess some numbers!")
        game["triesLeft"] = 8
        game["lastGuess"] = 0
        game["state"] = "begin"
        game["winNumber"] = rInt(1, 100)
        game["guessedNumber"] = 0
        game["round"] += 1
        time.sleep(2)
        theGameItself()
    else:
        logger.info(f'User exits the Game after: Rounds: {game["round"]} Wins: {game["won"]} Losts: {game["lost"]}')
        print ("Have a nice day!")
        time.sleep(2)
        exit()


def turnLogic():
    """ Checks if the next Turn, made by the Player is a legit turn in logical terms"""
    if game["winNumber"] < game["lastGuess"] and game["guessedNumber"] < game["lastGuess"]:
        game["state"] = "Legit Turn"
    elif game["winNumber"] > game["lastGuess"] and game["guessedNumber"] > game["lastGuess"]:
        game["state"] = "Legit Turn"
    elif game["winNumber"] < game["lastGuess"] and game["guessedNumber"] > game["lastGuess"] and game["lastGuess"] != 0:
        game["state"] = "Bad Turn"
        logger.info("User has triggered up 0")
        checkIdiot(0)
    elif game["winNumber"] > game["lastGuess"] and game["guessedNumber"] < game["lastGuess"] and game["lastGuess"] != 0:
        game["state"] = "Bad Turn"
        logger.info("User has triggered up 1")
        checkIdiot(1)
    elif game["guessedNumber"] == game["lastGuess"] and game["lastGuess"] != 0:
        game["state"] = "Bad Turn"
        logger.info("User has triggered up 2")
        checkIdiot(2)


def checkIdiot(up):
    """This function checks if the player don't read the text. It will apply some educative messures"""
    if up == 0:
        print(f'Really? I said the Number must be LOWER then {game["lastGuess"]} and now you come with {game["guessedNumber"]}?')
        print("That misbehavior will be punished with a loss of one additional try. You deserve it!\n")
        game["triesLeft"] -= 1
    elif up == 1:
        print (f'Really? I just told you that the number must be higher after you go for {game["lastGuess"]} and now you try {game["guessedNumber"]}?')
        print ("That misbehavior will be punished with a loss of one additional try. You deserve it!\n")
        game["triesLeft"] -= 1
    elif up == 2:
        print (f'.. yeah.. you guessed {game["guessedNumber"]} and last time you guessed {game["lastGuess"]}. Do you know whats the definiton of insanity?')
        print ("Insanity means doing the same things over and over again and expecting a different result.")
        print ("But you made it. The difference is, you have wasted one try!\n")


def debugMode():
    print(f'DEBUG MODE:\n |'
          f'Last guessed Number: {game["lastGuess"]}.\n |'
          f'New guessed number is: {game["guessedNumber"]}\n |'
          f'Win number is: {game["winNumber"]}\n |'
          f'Game State is: {game["state"]}\n |'
          f'Round: {game["round"]}\n |'
          f'Wins: {game["won"]}\n |'
          f'Losts: {game["lost"]}\n'
          f'{40 * "-"}\n')
    game["triesLeft"] = 999


def theGameItself():
    logger.info("User start a new game..")
    if game["debugMode"] == True:
        logger.info(".. in DEBUG Mode")
    while game["triesLeft"] > 0:
        game["lastGuess"] = game["guessedNumber"]
        riskyInput = input("\nPlease enter a number between 1 and 100: ")
        if checkInput(riskyInput) == False:
            continue
        else:
            print (40 * "-")
            print (f'Thank you for choosing the Number: {game["guessedNumber"]}')
            print(f'\nLet me see if you are correct..')
            print (40 * "-")
            if game["debugMode"] == True:
                debugMode()
            game["triesLeft"] -= 1
            time.sleep(1.5)

            if game["guessedNumber"] > game["winNumber"]:
                turnLogic()
                print ("Sorry, your Number is too big! Please try again!")
                print(f'You have {game["triesLeft"]} tries left!')
                continue

            elif game["guessedNumber"] < game["winNumber"]:
                turnLogic()
                print ("Sorry, the Number you've called is te.. oh wait.. its just to small. But try again!")
                print(f'You have {game["triesLeft"]} tries left!')
                continue

            else:
                print("Congratulations. You made it!")
                game["won"] += 1
                logger.info(f'User won a game. With {game["triesLeft"]} tries left.')
                restartGame()

    if game["triesLeft"] <= 0:
        print(f'It seems that you have lost the game because you are running out of tries. The correct Number was: {game["winNumber"]}')
        game["lost"] += 1
        logger.info(f'User lost a game. Win Number was: {game["winNumber"]}')
        restartGame()

LOG_FORMAT = "%(levelname)s: %(asctime)s - %(message)s"
logging.basicConfig(filename="outputlog.log", level=logging.DEBUG, format=LOG_FORMAT)
logger = logging.getLogger()
theGameItself()

Итак, что, если я сделаю что-то серьезное.И отправить его клиенту.У всей моей компании могут быть проблемы, если клиент станет троянским предупреждением.Что означает, мне нужно решение для этого, прежде чем я смогу использовать Python для продуктивных интересов.

У кого-нибудь есть какие-то решения?Заранее спасибо.

...