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 ...
随机推荐
- Acwing-283-多边形(区间DP)
链接: https://www.acwing.com/problem/content/285/ 题意: "多边形游戏"是一款单人益智游戏. 游戏开始时,给定玩家一个具有N个顶点N条 ...
- Nowcoder Circulant Matrix ( FWT )
题目链接 题意 : 给你一个a数组和b数组,构造出A[i][j]矩阵(A[i][j] = a[i xor j]) 给出等式 A * x = b ( mod p ) n等于4的时候有: A[0][0]* ...
- jmxtrans + OpenTSDB + granafa 监控套件使用手册
需求说明 编写背景 此手册的基础在于对<jmxtrans + influxdb + granafa 监控套件使用手册>的熟悉和使用.本手册仅介绍以下几项: OpenTSDB 的配置安装 对 ...
- python学习之路(20)
装饰器 由于函数也是一个对象,而且函数对象可以被赋值给变量,所以,通过变量也能调用该函数. >>> def now(): print('2019.0519') >>> ...
- 利用freemarker生成word,word另存为xml文件的标签解析
http://wenku.baidu.com/link?url=YxTZWVP3ssO-e_Br3LIZVq2xOQnqaSz8gLPiRUDN8NIR_wX2-Z25OqwbVn5kXqGiOFYU ...
- echarts之bootstrap选项卡不能显示其他标签echarts图表
在echarts跟bootstrap选项卡整合的时候,默认第一个选中选项卡可以正常加载echarts图表,但是切换其他选项的时候不能渲染出其他选项卡echarts图表. 解决方法: 在js中添加代码: ...
- Class constructor FileManager cannot be invoked without 'new' in undefined (line undefined, column undefined)
解决办法: 1.删除package.json属性devDependencies的 less 和 less-loader ; 2.重新安装 npm i less less-loader --save-d ...
- 文件读取及比较&文件信息保存
#include <stdio.h> #include <stdlib.h> //#include <regex.h> char* file_name_1 = &q ...
- Python学习笔记:外部数据的输入、存储等操作
查看current工作路径: >>> import os >>> os.getcwd() 'D:\\python' 更改工作路径: >>> os. ...
- 浏览器端-W3School-HTML:HTML DOM Table 对象
ylbtech-浏览器端-W3School-HTML:HTML DOM Table 对象 1.返回顶部 1. HTML DOM Table 对象 Table 对象 Table 对象代表一个 HTML ...