Python Penetration Testing Cookbook: Practical recipes on implementing information gathering, network security, intrusion detection, and post-exploitation by Rejah Rehim

Python Penetration Testing Cookbook: Practical recipes on implementing information gathering, network security, intrusion detection, and post-exploitation by Rejah Rehim

Author:Rejah Rehim [Rehim, Rejah]
Language: eng
Format: epub, pdf
Tags: COM053000 - COMPUTERS / Security / General, COM051440 - COMPUTERS / Software Development and Engineering / Tools, COM088010 - COMPUTERS / System Administration / Linux and UNIX Administration
Publisher: Packt Publishing
Published: 2017-11-28T00:00:00+00:00


transport = TCP(dport=53, flags = 'S')

Here we pass the destination port and the flag is set to S for a SYN packet. We can also pass the destination ports as a list for creating multiple packets:

transport = TCP(dport=[(53, 100)], flags = 'S')

Next we can stack these layers with the / operator:

packet = ethernet/network/transport

Now we can check the packets generated by printing them with pprint:

pprint([pkt for pkt in packet])

We can also use ls() to inspect a packet:

for pkt in packet: ls(pkt)

Another option to get the packet details is the show() method in the packet:

for pkt in packet: pkt.show()

Now we can create a single packet with a script. The script will be as follows:

from scapy.all import * from pprint import pprint ethernet = Ether() network = IP(dst = ['rejahrehim.com']) transport = TCP(dport=[(80)], flags = 'S') packet = ethernet/network/transport for pkt in packet: pkt.show()

This will create a TCP/IP packet with the SYN flag set, the destination address https://rejahrehim.com/, and the destination port 80.

Now run the script with the sudo permission:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.