Feb 27, 2019 at 11:18pm UTC
Sent to a friend to see his reaction, and basically all his anti viruses went off including Windows, why?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
#include <iostream>
#include <thread>
#include <chrono>
#include <string>
#include <stdlib.h>
#include <math.h>
void AI();
void Pause();
int Calculate();
int hidden_number;
int Closest[] = { 0, 101 };
int ai_guess;
std::string PauseTheConsole = " " ;
void simulate_input(const std::string& prompt, const std::string& input) {
static const auto initial_delay = std::chrono::milliseconds(0);
static const auto inter_char_delay = std::chrono::milliseconds(1000);
std::cout << prompt << ": " ;
std::this_thread::sleep_for(initial_delay);
for (char c : input) {
std::cout << c << std::flush;
std::this_thread::sleep_for(inter_char_delay);
}
std::cout << std::endl;
}
void simulate_input(const std::string& prompt, int input) {
simulate_input(prompt, std::to_string(input));
}
int main() {
srand(time(0));
std::cout << "Player: Enter hidden number (1-100): " ;
std::cin >> hidden_number;
ai_guess = rand() % 50 + 25;
simulate_input("AI: Type in a guess 1-100" , ai_guess);
AI();
Pause();
return 0;
}
void AI() {
while (true ) {
if (ai_guess < hidden_number && ai_guess > Closest[0]) {
Closest[0] = ai_guess;
}
else if (ai_guess > hidden_number && ai_guess < Closest[1]) {
Closest[1] = ai_guess;
}
if (ai_guess == hidden_number) {
std::cout << "Correct!\n\n" ;
break ;
}
else if (ai_guess < hidden_number) {
std::cout << "Too low\n\n" ;
}
else if (ai_guess > hidden_number) {
std::cout << "Too high\n\n" ;
}
ai_guess = Calculate();
simulate_input("Try again" , ai_guess);
}
return ;
}
int Calculate() {
int Subtract = Closest[1] - Closest[0];
int Divide = Subtract / 2;
int ai_guess = Divide + Closest[0];
return ai_guess;
}
void Pause() {
std::cin.clear();
std::cin.ignore(std::cin.rdbuf()->in_avail());
std::cout << "Press ENTER to continue..." << std::endl;
std::cin.get();
}
Last edited on Feb 28, 2019 at 2:09am UTC
Feb 28, 2019 at 4:40am UTC
Optimistic:
Your friends AV takes a whitelist approach, only allowing known good files, and flagging everything else.
Pessimistic:
Your compiler has been compromised, and it's injecting malware into every executable you produce.
Does your Windows flag problems with your own programs?
Feb 28, 2019 at 5:16am UTC
If you sent a "debug" build, try a "release" build (just a guess/experiment).
Feb 28, 2019 at 12:03pm UTC
Windows does not flag my programs. I'll try what Dutch said when I get home. (Compiler: Visual Studio)
Last edited on Feb 28, 2019 at 12:04pm UTC
Feb 28, 2019 at 4:43pm UTC
What version of Visual Studio?
Might be related:
https://stackoverflow.com/questions/7987712/why-does-avgantivirus-detect-an-executable-produced-from-dev-c-as-a-virus
Apparently you can use a website called virustotal.com to upload a file to see what multiple malware scanners detect it as. Worth a shot to see if it gets similar results to your friend.
Also, if the problem is the download itself, try renaming the file to something other than ".exe" and have your friend change it back. This usually gets past email scanners that don't allow sending .bat or .exe files to another user. Putting in in a zip/archive file also sometimes will prevent email providers from flagging it.
Last edited on Feb 28, 2019 at 4:49pm UTC
Feb 28, 2019 at 4:59pm UTC
Hello Majeek,
I have no idea how to write any kind of virus into a program, but I have had "AVG"'s software flag and quarantine a couple of ".exe" programs I wrote.
Think back I believe the problem may have come from the programs doing something with time. and this was misinterpreted as a virus.
Later I found out how to exclude certain directories that "AVG" would check and never had a problem after that.
dutch's idea of "debug" or "release" may also be worth trying.
Hope that helps,
Andy
Feb 28, 2019 at 5:20pm UTC
do a deep scan on the .exe file to ensure that some actual virus has not attached itself to your program, or check/clean your system, rebuild the exe, and redeploy it. If all is well, then you can add your program as an exception to the virus scanner, or do whatever you need to get it accepted on the system.