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 ...
随机推荐
- 细数meta标签的奥秘
因为看到了一个很不错的h5自适应网站,觉得很不错,于是好奇心作祟,让我翻开了它的源码一探究竟,最先研究的是它的meta标签,好了,废话不多说,以下是我总结的和比较实用的meta标签,如有错误,请多多指 ...
- Fiddler debug 拦截文件
前言 前端每次本地调试的需要重新build文件,而且如果当前文件是在另外一个项目中使用,则还需要拷贝到另外一个项目下面.这个工作很耗时.如果使用替换包,可以节省很多时间,也便于开发. 解决方案 用Fi ...
- Github首次使用,上传代码
参考博客:https://blog.csdn.net/zhangsiyao11/article/details/77007684 1.首先下载客户端github下载地址为 https://github ...
- 使用ajax时给ajax绑定上一个进度条的简单示例
直接放代码. <%@ page contentType="text/html;charset=UTF-8" language="java" %> & ...
- electron+react项目改为typescript
1.添加typescript依赖 yarn add typescript 2.修改tsconfig.json "isolatedModules": true => " ...
- PHP入门(五)
一.超级全局变量 超级全局变量在PHP 4.1.0之后被启用, 是PHP系统中自带的变量,在一个脚本的全部作用域中都可用. PHP中预定义了几个超级全局变量(superglobals) ,这意味着它们 ...
- re.compile 函数
re.compile 函数 compile 函数用于编译正则表达式,生成一个正则表达式( Pattern )对象,供 match() 和 search() 这两个函数使用. 语法格式为: re.com ...
- Linux开机启动和登录时各个文件的执行顺序
1.在Linux内核被加载后,第一个运行的程序便是/sbin/init 该文件会读取/etc/inittab文件,并依据此文件来进行初始化工作.其中/etc/inittab文件最主要的作用就是设定Li ...
- python3.6+Xadmin2.0系列(一) xadmin下载及安装
环境配置:win7+python3.6+Django2.1+xadmin2+PyCharm 一.Xadmin下载及安装: 1.下载: 下载地址:https://github.com/sshwsfc/x ...
- Codeforces Round #201 (Div. 2). E--Number Transformation II(贪心)
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description You ar ...