Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python Penetration Testing Essentials

You're reading from   Python Penetration Testing Essentials Techniques for ethical hacking with Python

Arrow left icon
Product type Paperback
Published in May 2018
Publisher
ISBN-13 9781789138962
Length 230 pages
Edition 2nd Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Mohit Raj Mohit Raj
Author Profile Icon Mohit Raj
Mohit Raj
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Python with Penetration Testing and Networking 2. Scanning Pentesting FREE CHAPTER 3. Sniffing and Penetration Testing 4. Network Attacks and Prevention 5. Wireless Pentesting 6. Honeypot – Building Traps for Attackers 7. Foot Printing a Web Server and a Web Application 8. Client-Side and DDoS Attacks 9. Pentesting SQL and XSS 10. Other Books You May Enjoy

Learning about packet crafting

This is a technique by which a hacker or pentester can create customized packets. By using a customized packet, a hacker can perform many tasks, such as probing firewall rule sets, port scans, and the behavior of the operating system. Lots of tools are available for packet crafting, such as Hping and Colasoft packet builder. Packet crafting is a skill. You can perform it with no tools, as you have Python.

First, we create Ethernet packets and then send them to the victim. Let's take a look at the entire code of eth.py and then understand it line by line:

import socket
s = socket.socket(socket.PF_PACKET, socket.SOCK_RAW, socket.ntohs(0x0800))
s.bind(("eth0",socket.htons(0x0800)))
sor = 'x00x0cx29x4fx8ex35'
des ='x00x0Cx29x2Ex84x7A'
code ='x08x00'
eth = des+sor+code
s.send(eth)

You've already seen s...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime