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 ...
随机推荐
- json校验失败的原因
如下原因会造成JSON校验失败,而且会让你不知道为什么失败 JSON字符串里的非数字型键值没有双引号 JSON中存在\t这样的制表符,看起来和空格一样,但是就是因为它的存在校验不通过.去掉就能过了. ...
- SQLSERVER 连接常见问题
1.从索引 0 处开始,初始化字符串的格式不符合规范 解决办法:检查数据库连接字符串 参考链接: https://www.cnblogs.com/guodongsky/archive/2013/04/ ...
- EF 操作数据库中的表
1.VS创建项目(实现数据库的增删改查.并在dataGridView中展示) 增.改通过Button,删通过快捷菜单ContextMenuStrip控件(DateGridView控件的ContextM ...
- python脚本中selenium启动浏览器报错os.path.basename(self.path), self.start_error_message) selenium.common.excep
在python脚本中,使用selenium启动浏览器报错,原因是未安装浏览器驱动,报错内容如下: # -*- coding:utf-8 -*-from selenium import webdrive ...
- Javascript事件:this.value()和this.select()
1.JavaScript的this.value() <asp:TextBox ID="txtComment" runat="server" Text=&q ...
- Boost学习
使用boost function使用类成员函数作为回调函数 #include <iostream> #include <boost/function.hpp> struct M ...
- maven打包加时间戳方法总结
基于Maven的项目,发布时需要打包,如tar.gz.web项目打成war格式包.每次打包时希望自己加上时间戳,假如我的项目名是myproject,默认打包后名为myproject.war.而我希望的 ...
- LeetCode 12. 整数转罗马数字(Integer to Roman)
题目描述 罗马数字包含以下七种字符: I, V, X, L,C,D 和 M. 字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 1000 例如, 罗马数字 2 写做 II , ...
- wls12C启用Gzip
https://community.oracle.com/message/14109820 https://docs.oracle.com/middleware/1221/wls/NOTES/what ...
- 使用同步上下文进行C#与VBA代码和Excel之间的交互
原始出处:www.cnblogs.com/Charltsing/p/RunVBA.html 大家都知道,Excel是个STA,不允许在Excel忙的时候对其Com对象进行操作,也不允许同时有多个线程对 ...