yura-choi / networkscanner Goto Github PK
View Code? Open in Web Editor NEWThis repository is for making various scanner on the network. Of course just for study.
This repository is for making various scanner on the network. Of course just for study.
environment
test code
import socket
src_ip = '127.0.0.1'
dest_ip = '127.0.0.1'
src_port = 8088
dest_port = 80
raw_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP)
raw_socket.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
ip_header = b"\x45\x00\x00\x40" # version, ihl, tos, Total length
ip_header += b"\x00\x00\x40\x00" # id, IP flags, fragment offset
ip_header += b"\x40\x06\x00\x00" # TTL, protocol, header checksum
ip_header += socket.inet_aton(src_ip) # source address
ip_header += socket.inet_aton(dest_ip) # destination address
tcp_header = src_port.to_bytes(2, 'big') + dest_port.to_bytes(2, 'big') # source port, destination port
tcp_header += b"\x00\x00\x00\x00" # seq number
tcp_header += b"\x00\x00\x00\x00" # ack number
tcp_header += b"\x50\x02\xff\xff" # offset, reserved, TCP flags, window
tcp_header += b"\x00\x00\x00\x00" # checksum, urgent pointer
raw_socket.sendto(ip_header + tcp_header, (dest_ip, dest_port))
response, _ = raw_socket.recvfrom(4096)
if response:
tcp_flag = int.from_bytes(response[33:34], "big")
if tcp_flag == 18: # SYN/ACK
print(f"{dest_port} is opened")
elif tcp_flag == 20: # RST
print(f"{dest_port} is closed")
raw_socket.sendto(ip_header + tcp_header, (dest_ip, dest_port))
OSError: [Errno 22] Invalid argument
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.