from smb.SMBConnection import SMBConnection from tkinter import * import tkinter.filedialog as filedialog class ConnectSamba(): def __init__(self): #self.username = 'root' #self.password = 'xxxxxxxx' self.my_name = 'anonymous' self.domain_name = '' #self.remote_smb_IP = 'xxx.xxx.xxx.xxx' #self.port = 1139 self.dir = '' self.display_path = '' def downloadFile(self): try: conn = SMBConnection(self.username.get(), self.password.get(), self.my_name, self.domain_name, use_ntlm_v2=True) conn.connect(self.remote_smb_IP.get(), int(self.port.get())) file_obj = open(ml.get(ml.curselection()), 'wb') conn.retrieveFile(self.dir, self.display_path + '/' + ml.get(ml.curselection()), file_obj) conn file_obj.close() return True except: return False def uploadFile(self): filetypes = [ ("All Files", '*'), ("Python Files", '*.py', 'TEXT'), ("Text Files", '*.txt', 'TEXT'), ("Exe Files", '*.exe', 'TEXT')] fobj = filedialog.askopenfile(filetypes=filetypes) if fobj: self.upload_path = fobj.name a = len(self.upload_path.split('/')) try: conn = SMBConnection(self.username.get(), self.password.get(), self.my_name, self.domain_name, use_ntlm_v2=True) conn.connect(self.remote_smb_IP.get(), int(self.port.get())) file_obj = open(self.upload_path, 'rb') conn.storeFile(self.dir, self.display_path + '/' + self.upload_path.split('/')[a - 1], file_obj) file_obj.close() return True except: return False else: pass def display(self, a):
远程访问斐讯天天链N1(python源码)写的不好 仅仅为了实现功能
最新推荐文章于 2024-05-11 18:00:09 发布
![](https://img-home.csdnimg.cn/images/20240709112858.png)