0

I have a python script that I converted to an exe, which windows defender is detecting as a virus.

I know the script is not malicious, it just downloads iso files from the microsoft website.

I want it to be usable on windows pcs without being detected as a virus, and without any exception tweaks in Defender.

Screenshot of Defender output

Here is my code (before I compiled it):

import sys
import requests
import time

def download_url(link):
    start = time.time()
    file_name_start_pos = link.rfind("/") + 1
    file_name = link[file_name_start_pos:]
    with open(file_name, "wb") as f:
        print("Downloading %s" % file_name)
        response = requests.get(link, stream=True)
        total_length = response.headers.get('content-length')
        if total_length is None: # no content length header
            f.write(response.content)
        else:
            dl = 0
            total_length = int(total_length)
            for data in response.iter_content(chunk_size=4096):
                dl += len(data)
                f.write(data)
                done = int(50 * dl / total_length)
                percent = int(100 * dl / total_length)
                toataltime = time.time() - start
                sys.stdout.write("\r[%s%s] " % ('#' * done, ' ' * (50-done))+str(percent)+"% ("+str(dl)+"/"+str(total_length)+") "+str(round(round((((dl/1024)/1024)*8))/toataltime))+" Mbps Avg")
                sys.stdout.flush()
    print("\n")


#Windows 7 Home
download_url("https://download.microsoft.com/download/E/A/8/EA804D86-C3DF-4719-9966-6A66C9306598/7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_HOMEPREMIUM_x64FRE_en-us.iso")

#Windows 7 Pro
download_url("https://download.microsoft.com/download/0/6/3/06365375-C346-4D65-87C7-EE41F55F736B/7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_PROFESSIONAL_x64FRE_en-us.iso")

#Windows 7 Ultimate
download_url("https://download.microsoft.com/download/5/1/9/5195A765-3A41-4A72-87D8-200D897CBE21/7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_ULTIMATE_x64FRE_en-us.iso")

#Windows 8.1
download_url("https://software-download.microsoft.com/pr/Win8.1_English_x64.iso?t=3f986a33-d055-4091-aa7b-c63192d916ab&e=1638067997&h=67f853a7ef459f36f45647c06d2a29a0")

#Windows 10
download_url("https://software-download.microsoft.com/pr/Win10_21H2_English_x64.iso?t=e3833d87-c6a1-409d-af98-aaabfa52a5fe&e=1638068076&h=e1421b879b14b6900da6ec8e6e1ea547")

#Windows 11
download_url("https://software-download.microsoft.com/pr/Win11_English_x64.iso?t=35afe7c0-aac5-497f-96fd-120a6d1ea9e1&e=1638068135&h=41e1d770adde9f4ad56cb2d357b55c61")

This was compiled using pyinstaller Also, I do not want to have to recompile things with vs code

Should I use a different python compiler or maybe edit my code?

martineau
  • 112,593
  • 23
  • 157
  • 280
Coolcreeper
  • 144
  • 8
  • It probably just doesn't like the fact that you're downloading files that may contain unsafe content from an external website. I doubt it cares that it's microsoft.com. – MattDMo Nov 27 '21 at 21:11
  • 1
    This is known issue and asked multiple times on SO, there are multiple questions – buran Nov 27 '21 at 21:18

0 Answers0