Qt 文件被报告为病毒并且无法启动
Posted
技术标签:
【中文标题】Qt 文件被报告为病毒并且无法启动【英文标题】:Qt file gets reported as virus and won't launch 【发布时间】:2014-06-02 18:26:06 【问题描述】:我最近做了一个Qt文件,刚刚编译。编译后,我的 Avast 防病毒软件将其作为病毒阻止。我花了几个小时试图找到语法错误/无限循环/打字错误。我已经阅读了其他问题并用谷歌搜索了这个问题。我得出一个结论,这超出了我的理解范围。这是我的文件:
top_secret.h
#ifndef TOP_SECRET_H
#define TOP_SECRET_H
#include <QtGui>
class top_secret : public QMainWindow
Q_OBJECT
public:
top_secret();
private slots:
void password_ckeck();
void go_to_page_1();
void go_to_page_2();
void go_to_page_3();
void go_to_page_4();
void quit();
void lock();
void about();
private:
QStackedWidget *book;
QWidget *lock_window;
QWidget *window1;
QWidget *window2;
QWidget *window3;
QWidget *window4;
QLineEdit *input;
QAction *quit_action;
QAction *lock_action;
QAction *about_action;
QMenu *fileMenu;
;
#endif
submain.cpp
#include "top_secret.h"
top_secret::top_secret()
//main things
quit_action = new QAction(tr("Quit"), this);
about_action = new QAction(tr("About"), this);
lock_action = new QAction(tr("Lock"), this);
connect(quit_action, SIGNAL(triggered()), this, SLOT(quit()));
connect(about_action, SIGNAL(triggered()), this, SLOT(about()));
connect(lock_action, SIGNAL(triggered()), this, SLOT(lock()));
fileMenu = menuBar() -> addMenu(tr("File"));
fileMenu -> addAction(lock_action);
fileMenu -> addAction(about_action);
fileMenu -> addSeparator();
fileMenu -> addAction(quit_action);
book = new QStackedWidget;
//lock window
lock_window = new QWidget;
QLabel *label = new QLabel(tr("Enter password"));
input = new QLineEdit;
QPushButton *button = new QPushButton(tr("Go"));
connect(button, SIGNAL(clicked()), this, SLOT(password_ckeck()));
QHBoxLayout *lock_layout;
lock_layout -> addWidget(label);
lock_layout -> addWidget(input);
lock_layout -> addWidget(button);
lock_window -> setLayout(lock_layout);
//window 1
window1 = new QWidget;
QLabel *label1 = new QLabel("Name: Jakub Jagielski<br>Date of birth: 21/01/2014<br>Gender: Male<br>\
Interested in: Women<br>Hair colour: Brown<br>Eye colour: brown");
QPushButton *button1 = new QPushButton(tr("Next"));
connect(button1, SIGNAL(clicked()), this, SLOT(go_to_page_2()));
QVBoxLayout *layout1;
layout1 -> addWidget(label1);
layout1 -> addWidget(button1);
window1 -> setLayout(layout1);
//window 2
window2 = new QWidget;
QLabel *label2 = new QLabel("Interests: Piano playing, science,<br>programming, computer science,<br>\
Xbox 360 playing, reading facts,<br>Logical puzzles, security programs,<br>bypassing self-made security \
programs,<br>creating complex security programs,<br>creating 2D games in Python tkinter,<br>creating apps \
like this one.");
QPushButton *button2previous = new QPushButton("back");
QPushButton *button2next = new QPushButton("next");
connect(button2previous, SIGNAL(clicked()), this, SLOT(go_to_page_1()));
connect(button2next, SIGNAL(clicked()), this, SLOT(go_to_page_3()));
QHBoxLayout *layout2bottom;
QVBoxLayout *layout2;
layout2bottom -> addWidget(button2previous);
layout2bottom -> addWidget(button2next);
layout2 -> addWidget(label2);
layout2 -> addLayout(layout2bottom);
window2 -> setLayout(layout2);
//window 3
window3 = new QWidget;
QLabel *label3 = new QLabel("Programming languages known by this user<br>rated out of 10:<br>\
Python: 9/10<br>C++: 8/10<br>Java: 5/10<br>html/Css/javascript: 8/10<br>php: 2/10<br>Batch: 5/10<br>");
QPushButton *button3previous = new QPushButton("back");
QPushButton *button3next = new QPushButton("next");
connect(button3previous, SIGNAL(clicked()), this, SLOT(go_to_page_2()));
connect(button3next, SIGNAL(clicked()), this, SLOT(go_to_page_4()));
QHBoxLayout *layout3bottom;
QVBoxLayout *layout3;
layout3bottom -> addWidget(button3previous);
layout3bottom -> addWidget(button3next);
layout3 -> addWidget(label3);
layout3 -> addLayout(layout3bottom);
window3 -> setLayout(layout3);
//window 4
window4 = new QWidget;
QLabel *label4 = new QLabel("This app has only been created <br> to try to make an app with<br>\
C++ and its wonderful library called Qt.<br>This person's account hasn't been<br>really hacked. In \
fact, the person<br>has made this app himself.");
QPushButton *button4previous = new QPushButton("back");
QPushButton *button4end = new QPushButton("quit");
connect(button4previous, SIGNAL(clicked()), this, SLOT(go_to_page_3()));
connect(button4end, SIGNAL(clicked()), this, SLOT(quit()));
QHBoxLayout *layout4bottom;
QVBoxLayout *layout4;
layout4bottom -> addWidget(button4previous);
layout4bottom -> addWidget(button4end);
layout4 -> addWidget(label4);
layout4 -> addLayout(layout4bottom);
window4 -> setLayout(layout4);
//main
book -> addWidget(lock_window);
book -> addWidget(window1);
book -> addWidget(window2);
book -> addWidget(window3);
book -> addWidget(window4);
setCentralWidget(book);
void top_secret::password_ckeck()
QString attempt = input -> text();
if (attempt == "Jakub")
top_secret::book -> setCurrentIndex(1);
void top_secret::go_to_page_1()
top_secret::book -> setCurrentIndex(1);
void top_secret::go_to_page_2()
top_secret::book -> setCurrentIndex(2);
void top_secret::go_to_page_3()
top_secret::book -> setCurrentIndex(3);
void top_secret::go_to_page_4()
top_secret::book -> setCurrentIndex(4);
void top_secret::lock()
top_secret::book -> setCurrentIndex(0);
void top_secret::quit()
QMessageBox messagebox;
messagebox.setText("Do you really wish to quit?");
messagebox.setWindowTitle("exit?");
messagebox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
if (messagebox.exec() == QMessageBox::Yes)
close();
void top_secret::about()
QMessageBox messagebox2;
messagebox2.setText("This app is a test to try out my new C++ abilities. This app \
would take me half the time it took me if I wrote it in Python.");
messagebox2.setWindowTitle("About");
messagebox2.exec();
main.cpp
#include "top_secret.h"
#include <QApplication>
int main(int argc, char *argv[])
QApplication app(argc, argv);
top_secret *program = new top_secret;
program -> show();
return app.exec();
对于目前的代码量,我感到非常抱歉,我不希望得到完美的答案,但如果我能理解我做错了什么,我会非常高兴。此外,当我添加要被我的防病毒软件忽略的文件时,它只是无法启动。
请注意,我的其他 Qt 程序运行良好,所以我确信这是由于我的代码造成的。
【问题讨论】:
会不会是您使用的名称top_secret
?此外,您可以将 AV 设置为不扫描该目录或可执行文件。
我尝试了不同的名称,但它保持不变。当我告诉我的防病毒软件不要管该文件时,它确实如此。那么文件根本不会启动(或没有弹出窗口)。
...也许你的系统上真的有病毒感染了你的可执行文件?
Linux 是终极的病毒补救措施,所以升级到 linux 并享受吧。还是卸载 Avast?
【参考方案1】:
我在使用 avast 时遇到了同样的问题。但这不是 Qt 特有的东西。 Avast 阻止了我编程的所有内容。
您只需转到设置并取消选中“未知来源”之类的框。 Avast 不知道您的程序来自哪里并阻止它,因为它可能是病毒。至少那是 avast 对我的程序所做的。在我取消选中该复选框后,一切正常。
【讨论】:
Windows 8 附带的新 SmartScreen 行为非常相似。 en.wikipedia.org/wiki/Microsoft_SmartScreen 这是我的预期,但我的代码是否有问题,因为我双击它时没有任何反应? 您的代码一切正常。我不认为您的防病毒程序会查看您的源代码并检查是否有坏词。 我的意思是,当它被编译时,它必须以某种方式表现得像病毒。以上是关于Qt 文件被报告为病毒并且无法启动的主要内容,如果未能解决你的问题,请参考以下文章
Virtual box无法启动虚拟系统,提示内存不能为read
kb578685m.log病毒无法删除,每次都会重新启动,请指教