2

I've made a simple python program to upload files to a server for people in my company to use (it's a short-term solution for now). The user runs the file and it asks them to choose files, which are then uploaded to a server. My code is here:

import os
from tkinter import filedialog, Tk, Label, Button
import paramiko
import urllib.parse
import os
from pathlib import Path

class MyGUI:
    def __init__(self, master):
        self.master = master
        master.title("Server Uploader")
        master.resizable(height=False, width=False)
        master.configure(bg="white")

        self.label = Label(master, text="There was a problem connecting to the server. Please try again later or contact me.", fg="black", bg="white")
        self.label.config(font=("Courier", 12))
        self.label.pack()

class SuccessfulUpload:
    def __init__(self, master):
        self.master = master
        master.title("Successful Upload")
        master.resizable(height=False,width=False)

        self.label = Label(master, text="Upload successful. You can now close this window.")
        self.label.config(font=("Courier, 12"))
        self.label.pack()

#Connect to server using SFTP
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
    ssh_client.connect(hostname='hostname',port=portno,username='username',password='password')
except paramiko.ssh_exception.AuthenticationException as e:
    root = Tk()
    my_gui = MyGUI(root)
    root.mainloop()
    raise SystemExit

#Ask for user to choose files to upload
root = Tk()
root.withdraw()
files = filedialog.askopenfilenames(title="Choose Files to Upload to the Server", filetypes=(("All Files","*.*"),("PDF Files","*.pdf"), ("Word Files","*.doc*")))
print (root.tk.splitlist(files))

s = ssh_client.open_sftp()
if files == "":
    raise SystemExit

#Define local and remote path for file
for file in files:
    localpath = file
    parts = Path(file).parts
    endpath = parts[-1]
    print(endpath)
    remotepath="/Path/" + endpath
    print(remotepath)
    s.put(localpath,remotepath)

root = Tk()
fin = SuccessfulUpload(root)
root.mainloop()

s.close()
root.destroy()

complete = input("Upload Successful. Press any key to exit.")

I converted the .py file into a .exe file using pyinstaller. I then sent it to another computer. First, Windows tried to prevent the program from downloading (understandable), then once allowed to download, Windows tries to stop the program from running - bit annoying but OK. Still, after allowing the program twice through Windows, anti-virus (AVG) still prevents the program from running. To get it to run, I've had to go directly onto the anti-virus and make an exception for my program.

I can't send the program out whilst you have to manually make an exception for it within the anti-virus. Is there any way to make your file more trustworthy for other computers to download and run (without anti-virus completely stopping the program from running).

6
  • 3
    One requirement would be to digitally signed the executable. The other is simply for more people to download the file.
    – Ramhound
    Oct 30, 2017 at 15:01
  • @Ramhound How would having more people download the file help?
    – slhck
    Oct 30, 2017 at 15:05
  • 1
    @ConorHughes - You indicated you wanted to find a way to prevent Windows from warning you about the trustworthiness of the file. You can digitally sign code with a self-signed certificate without any costs, just requires you to trust the certificate, you created that signed to executable..
    – Ramhound
    Oct 30, 2017 at 17:08
  • 1
    The security software considers many aspects of the executable file to make a decision. Signing is a big one but even just having a company name, version number, etc all add up.. Applications generated with AutoIt are also commonly picked up because they just aren't seen as that legitimate, same with pytoexe type applications. You could upload the file to Virus Total after making changes to see if you're making it less likely to false-pos. Oct 30, 2017 at 19:18
  • 2
    Unfortunately, even if a program is digitally signed, Windows SmartScreen may still complain. There’s no satisfactory solution.
    – Daniel B
    Feb 20, 2018 at 9:29

1 Answer 1

0

for digital signing you can try it.( reference from https://steward-fu.github.io/website/driver/wdm/self_sign.htm) signtool get from MS SDK or Visual C++ for Python (http://aka.ms/vcpython27)

First time

Makecert -r -pe -ss YourName YourName.cer

certmgr.exe -add YourName.cer -s -r localMachine root

After

signtool sign /s YourName YourApp.exe

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .