and wrote a Pyqt4 gadget that was mainly used to learn

Source: Internet
Author: User

Part of the code:

#-*-Coding:utf-8-*-

"""
Module implementing Portscan.
"""

From Pyqt4.qtcore import pyqtsignature
From Pyqt4.qtgui import Qdialog
From PYQT4 import Qtgui,qtcore
From Ui_portscan import Ui_portscan
Import socket
Class Portscan (Qdialog, Ui_portscan):
"""
Class documentation goes here.
"""
def __init__ (self, Parent=none):
"""
Constructor

@param parent reference to the parent widget (Qwidget)
"""
Qdialog.__init__ (self, parent)
Self.setupui (self)
# QtCore.QObject.connect (Self.pushbutton,qtcore.signal ("clicked ()"), self.on_pushbutton_clicked)
@pyqtSignature ("")
def on_pushbutton_clicked (self):
For IP in Self.getiplist ():
Self.socket_port (IP)

def getiplist (self):
self.startnum = Int (Self.ip2num (str (Self.startlineEdit.text ())))
self.endnum = Int (Self.ip2num (str (Self.endlineEdit.text ())))
IPList = []
For NUM in range (self.startnum,self.endnum+1):
IP = self.num2ip (num)
Iplist.append (IP)
Return IPList

def ip2num (SELF,IP):
IP = [INT (x) for x in Ip.split ('. ')]
return ip[0]<<24|ip[1]<<16|ip[2]<<8|ip[3]
def num2ip (Self,num):
Return '%s.%s.%s.%s '% (num & 0xff000000) >> 24,
(Num & 0x00ff0000) >> 16,
(Num & 0x0000ff00) >> 8,
Num & 0x000000ff)
def socket_port (SELF,IP):
Port = Int (Self.portlineEdit.text ())
Try
Self.messagelabel.setText (u "scanning ip:%s:%d ..."% (Ip,port))
s = Socket.socket (socket.af_inet,socket. SOCK_STREAM)
S.connect ((Ip,port))
Self.textEdit.append (' ip:%s:%d Open '% (ip,port))
Except
Self.textEdit.append (' ip:%s:%d Closed '% (ip,port))

if __name__ = = "__main__":
Import Sys
App = Qtgui.qapplication (SYS.ARGV)
UI = Portscan ()
Ui.show ()
Sys.exit (App.exec_ ())

The

also writes a pyqt4 gadget that is used primarily for learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.