15
22

More than 3 years have passed since last update.

PyInstallerでexeファイル化したものがAVASTやAVGでトロイの木馬ウイルスと誤認される問題の一時的な解決法

Last updated at Posted at 2020-10-05

PythonをPyInstallerでexe化したときにウイルス認識される問題

Pythonを簡単にexe化する時に便利なPyInstallerですが、これでexe化したものがいくつかのウイルスソフトでトロイの木馬と認識されるようになっているようだ。

ウイルス認識された手順(使用しない)

環境

Windows10 64ビット
Python3.8

下記手順でexe化したものは結構ウイルス判定が多くでてしまった。

1)コマンドプロンプトでpipインストール
pip install pyinstaller

2)コマンドプロンプトでexe化
pyinstaller ファイル名 -–onefile -–noconsole

image.png

解決方法

1)コマンドプロンプトでGitクローンを行う

git clone https://github.com/pyinstaller/pyinstaller

▼Gitを入れてない人は下記リンクを参考に入れておく
https://git-scm.com/book/ja/v2/%E4%BD%BF%E3%81%84%E5%A7%8B%E3%82%81%E3%82%8B-Git%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB

2)コマンドプロンプトでPyInstaller下のboot loaderに移動

cd pyinstaller

cd bootloader

3)コマンドプロンプトで下記を入力

python ./waf distclean all

Linux系の場合はPythonの所をPython3とする。
ここでエラーが出るがクリーンすることが目的なのでエラーを無視します。

4)コマンドプロンプトで下記を入力し、ブートローダーを構築する

python setup.py install

5)pyinstallerの導入確認

コマンドプロンプトで下記を入力してpyinstallerのコマンドを確認
pyinstaller

6)コマンドプロンプトでexe化

pythonコードを作成したフォルダへcdコマンドで移動し下記を入力
pyinstaller ファイル名 -–onefile -–noconsole

改善結果

目的のAVASTやAVG等の誤認は改善でき、他のソフトでのウイルス検知もかなり減ったがまだウイルス検出がでる。
色々調べたがPyInstallerがウイルス作成に高頻度で使用されているから仕方ないという海外の記事しか見つからなかった。
一時的な解決方法ではあるが備忘録として記載しておく。
image.png

参考

how to recompile the bootloader of Pyinstaller

15
22
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
22