Python示例-TCP Port Scan
import socket
import threading # target host address
host = "127.0.0.1"
# thread list
threads = [] def tcp_connect_scan(host, port):
'''
TCP connect scanning
@param host: ip, host name or domain name
@param port: port number
'''
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(1)
result = sock.connect_ex((host, port))
if result == 0:
print("Host {} port {} status open".format(host, port))
else:
print("Host {} port {} status close".format(host, port))
except socket.error as err:
print("{}".format(err))
finally:
sock.close() def tcp_syn_scan(host, port):
'''
TCP SYN scanning
@param host: ip, host name or domain name
@param port: port number
'''
# To be continued
pass def main():
for port in range(0, 65535):
t = threading.Thread(target=tcp_connect_scan, args=(host, port))
threads.append(t)
t.start()
for task in threads:
task.join() if __name__ == '__main__':
main()
Python示例-TCP Port Scan的更多相关文章
- python之tcp自动重连
操作系统: CentOS 6.9_x64 python语言版本: 2.7.13 问题描述 现有一个tcp客户端程序,需定期从服务器取数据,但由于种种原因(网络不稳定等)需要自动重连. 测试服务器示例代 ...
- 【Python】TCP Socket的粘包和分包的处理
Reference: http://blog.csdn.net/yannanxiu/article/details/52096465 概述 在进行TCP Socket开发时,都需要处理数据包粘包和分包 ...
- python socket+tcp三次握手四次撒手学习+wireshark抓包
Python代码: server: #!/usr/bin/python # -*- coding: UTF-8 -*- # 文件名:server.py import socket # 导入 socke ...
- 浅谈原始套接字 SOCK_RAW 的内幕及其应用(port scan, packet sniffer, syn flood, icmp flood)
一.SOCK_RAW 内幕 首先在讲SOCK_RAW 之前,先来看创建socket 的函数: int socket(int domain, int type, int protocol); domai ...
- Python Hacking Tools - Port Scanner
Socket Programming 1. Scan the target Vulnerable Server. And test it by telnet. 2. Write the scanne ...
- Failed to connect to Xilinx hw_server. Check if the hw_server is running and correct TCP port is used.
Failed to connect to Xilinx hw_server. Check if the hw_server is running and correct TCP port is us ...
- 安装VisualSVN Server 报错The specified TCP port is occupied
安装过程中报错,如下图所示. The specified TCP port is occupied by another service.Please stop that service or use ...
- 【翻译自mos文章】OGG replicat 进程使用的 TCP port
OGG replicat 进程使用的 TCP port 来源于: TCP PORT USED BY REPLICAT PROCESSES (文档 ID 1060954.1) 适用于: Oracle G ...
- python 示例代码1
第一章 python基础一 在此不再赘述为什么学习python这门编程,网上搜索一箩筐.我在此仅说一句python的好,用了你就会爱上它. 本python示例代码1000+带你由浅入深的了解pyth ...
随机推荐
- sublime添加书签
ctrl+f2添加书签, f2切换书签
- 网络编程简介(OSI七层协议,TCP协议原理,三次握手与四次挥手)
目录 网络编程 软件开发架构 C/S架构 B/S架构 网络编程的发展史 互联网协议 1.物理连接层 2.数据链路层 3.网络层 4.传输层 5.应用层 三次握手四次挥手 三次握手建链接 数据传输 四次 ...
- Documents.Open返回值为null
上个月出现的一个问题,将解决方法记录一下~ [问题]无法通过SAP系统外部OS命令(SM69)执行OS服务器上Powershell文件对Office文档的相关命令操作(打开文档等命令). [现象]执行 ...
- docker 部署项目
一:我使用的是阿里云的ubuntu16.4系统. 项目数据库: # 数据源 spring: datasource: type: com.zaxxer.hikari.HikariDataSource d ...
- Vue-CLI项目搭建
一.环境搭建 1.安装服务器node 官网下载 https://nodejs.org/zh-cn/ node:用C++语言编写,用来运行JavaScript语言 node可以为前端项目提供server ...
- idea中JSP页面不能访问静态资源(图片,js,css)
必须配置SpringMvc对访问静态资源的支持,idea默认就是在main/webapp 下的文件路径,要在web-info同级的resource文件下放置,JSP中 ${pageContext.re ...
- [CSP-S模拟测试]:蛇(DP+构造+哈希)
题目传送门(内部题140) 输入格式 前两行有两个长度相同的字符串,描述林先森花园上的字母. 第三行一个字符串$S$. 输出格式 输出一行一个整数,表示有多少种可能的蛇,对$10^9+7$取模. 样例 ...
- _parameter:解决There is no getter for property named in class java.lang.String
我们知道在mybatis的映射中传参数,只能传入一个.通过#{参数名} 即可获取传入的值. Mapper接口文件: public int delete(int id) throws Exception ...
- Eclipse中文插件安装教程
先运行英文版Eclipse 点击Help选择Install New Software 直接点击Add按钮 Name输入: Babel Location输入: http://download.eclip ...
- 【CentOS】yum安装教训
前言:本来想安装sl在新安装的centos7上,网上搜了教程,很多都是先要你yum -y update,如下: 1.更新yum源: yum -y update 2.依赖安装: wget http:// ...