Skip to Main Content
Mastering Python Networking - Second Edition
book

Mastering Python Networking - Second Edition

by Eric Chou
August 2018
Intermediate to advanced content levelIntermediate to advanced
466 pages
10h 23m
English
Packt Publishing
Content preview from Mastering Python Networking - Second Edition

The TCP port scan

The first step for any potential hackers is almost always trying to learn which service is open on the network, so they can concentrate their effort on the attack. Of course, we need to open certain ports in order to service our customer; that is part of the risk we need to accept. But we should also close any other open port that needlessly expose a larger attack surface. We can use Scapy to do a simple TCP open port scan to scan our own host.

We can send a SYN packet and see whether the server will return with SYN-ACK:

>>> p = sr1(IP(dst="10.0.0.14")/TCP(sport=666,dport=23,flags="S"))>>> p.show()###[ IP ]### version= 4L ihl= 5L tos= 0x0 len= 40 id= 25373 flags= DF frag= 0L ttl= 62 proto= tcp chksum= 0xc59b src= 10.0.0.14 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Python Networking

Mastering Python Networking

Eric Chou
Learning Python Networking - Second Edition

Learning Python Networking - Second Edition

José Manuel Ortega, Dr. M. O. Faruque Sarker, Sam Washington

Publisher Resources

ISBN: 9781789135992Supplemental Content