转载于:行者匠心
值得分享学习学习
# 图形界面
class PortScan(object):
def __init__(self):
# 初始化一个窗口实例
self.window = tk.Tk() # 初始化一个窗口实例
self.window.title('Port Scanner (公众号释然IT杂谈)') # 窗口标题
self.window.geometry("500x400") # 窗口大小
self.ip = 0 # 设置IP
tk.Label(self.window,text='配置如下:').place(x=10,y=20,anchor='nw')
# 定义两个单选框:单IP和IP段
self.var = tk.StringVar()
tk.Label(self.window,text='扫描方式:').place(x=10,y=50,anchor='nw')
self.single_ip = tk.Radiobutton(self.window, text='单IP', variable=self.var, value='S')
self.multi_ip = tk.Radiobutton(self.window, text='IP段', variable=self.var, value='M')
# IP标签和输入框
tk.Label(self.window,text='IP:').place(x=10,y=90,anchor='nw')
self.ip = tk.Entry(self.window,show='')
# port标签和输入框
tk.Label(self.window,text='端口:').place(x=10,y=130,anchor='nw')
self.port = tk.Entry(self.window,show='')
# 超时标签和输入框
tk.Label(self.window,text='超时:').place(x=10,y=170,anchor='nw')
self.time = tk.Entry(self.window,show='',width=5)
tk.Label(self.window,text='毫秒').place(x=110,y=170,anchor='nw')
# 线程滚动条
self.s = tk.Scale(self.window,label='线程',from_=3,to=21,orient=tk.HORIZONTAL,
length=200, showvalue=2, tickinterval=6, resolution=1,command=self.thread)
# 输出文本框
self.text1 = tk.Text(self.window,height=20,width=30)
# 按钮:扫描、退出和清空
tk.Button(self.window,text='扫描',width=5,command=self.scan).place(x=20,y=310,anchor='nw')
tk.Button(self.window,text='退出',width=5,command=self.exit).place(x=90,y=310,anchor='nw')
tk.Button(self.window,text='清空',width=5,command=self.delete).place(x=160,y=310,anchor='nw')
tk.Label(self.window,text='扫描结果:').place(x=250,y=20,anchor='nw')
# 组件布置/定位
def gui_arrand(self):
self.single_ip.place(x=80,y=50,anchor='nw')
self.multi_ip.place(x=150,y=50,anchor='nw')
self.ip.place(x=60,y=90,anchor='nw')
self.port.place(x=60,y=130,anchor='nw')
self.time.place(x=60,y=170,anchor='nw')
self.s.place(x=10,y=210,anchor='nw')
self.text1.place(x=255,y=50,anchor='nw',width='230')
完整代码获取及生成的exe文件后台回复 “ GUI ” 获取
原文始发于微信公众号(释然IT杂谈):Python GUI界面版端口扫描工具
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论