PYTHON端口扫描小程序
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PYTHON端口扫描小程序相关的知识,希望对你有一定的参考价值。
#coding:utf-8 import socket import threading import time class SkPort(threading.Thread): def __init__(self,ip,port): threading.Thread.__init__(self) self.ip = ip self.port = port def run(self): sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sk.settimeout(1000) #print(‘Port scaning:%d‘ % self.port) try: sk.connect((self.ip,self.port)) print(‘Server %s port %d OK!‘ % (self.ip,self.port)) except Exception: print(‘Server %s port %d is not connected!‘ % (self.ip,self.port)) sk.close() def main(): ip = raw_input(‘Please input ip(default:127.0.0.1): ‘) sport = int(raw_input(‘Please input start port(default:80): ‘)) eport = int(raw_input(‘Please input start port(default:80): ‘)) for port in range(sport,eport+1): item = (ip,port) t = SkPort(ip,port) t.start() time.sleep(0.1) if __name__ == ‘__main__‘: main()
本文出自 “江湖笑笑生” 博客,请务必保留此出处http://hashlinux.blog.51cto.com/9647696/1794851
以上是关于PYTHON端口扫描小程序的主要内容,如果未能解决你的问题,请参考以下文章
Java开发技术:Socket编程端口扫描小程序(完整源码)
Java开发技术:Socket编程端口扫描小程序(完整源码)
python Python端口扫描程序 - TCP SYN(半开)扫描