python tkinter 端口扫描程序
import socket
import tkinter.messagebox
from tkinter import *


class portScan:
    def __init__(self):
        window = Tk()
        window.title("端口扫描")

        frame = Frame(window)
        frame.pack()

        Label(frame, text="IP地址、域名 :").grid(row=1, column=1, sticky=E)
        self.ipName = StringVar()
        Entry(frame, textvariable=self.ipName).grid(row=1, column=2)

        Label(frame, text="起始端口(最小为1):").grid(row=2, column=1, sticky=E)
        self.startPort = IntVar()
        Entry(frame, textvariable=self.startPort).grid(row=2, column=2)

        Label(frame, text="结束端口(最大为65535):").grid(row=3, column=1, sticky=E)
        self.endPort = IntVar()
        Entry(frame, textvariable=self.endPort).grid(row=3, column=2)

        Button(frame, text="扫描", command=self.getPortScan).grid(row=4, column=1, sticky=E)

        self.text = Text(window)
        self.text.pack()

        window.mainloop()

    def getPortScan(self):
        try:
            if (self.startPort.get() < 0 or self.endPort.get() > 65535):
                tkinter.messagebox.showerror("error", "请输入正确的端口号!")
            elif (self.startPort.get() > self.endPort.get()):
                tkinter.messagebox.showerror("error", "请输入正确的端口号!")
            else:
                self.text.delete("1.0", "end")
                for port in range(self.startPort.get(), self.endPort.get() + 1):
                    try:
                        s = socket.socket()
                        s.settimeout(1)
                        s.connect((str(self.ipName.get()), int(port)))
                        self.text.insert(END, self.ipName.get() + ":" + str(port) + "已开放\n")
                    except socket.error:
                        self.text.insert(END, self.ipName.get() + ":" + str(port) + "未开放\n")
                    finally:
                        s.close()
                self.text.insert(END, "扫描完成")
        except tkinter.TclError:
            tkinter.messagebox.showerror("error", "请输入正确的端口号!")


portScan()
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇