Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
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 (16) Chapters Close

Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
1. Python with Penetration Testing and Networking FREE CHAPTER 2. Scanning Pentesting 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 1. Other Books You May Enjoy Index

Fake ping reply


In this section, you will learn how to send fake ping reply packets. In the fake ping reply code, I have not used any libraries. 

Let's understand the code. The code name is icmp_reply.py. In order to run the code, you need to install the ping module from https://pypi.python.org/pypi/ping/0.2:

  • The following modules have been used in the code:
      import socket
      import struct
      import binascii
      import ping
      import Queue
      import threading
      import sys
      import random
      import my_logger
  • The following code defines a queue, Q, and two sockets. One socket will be used to receive packets and the other will be used to send packet:
      Q = Queue.Queue()
      IP_address = 0
      my_socket = socket.socket(socket.PF_PACKET, socket.SOCK_RAW, 
      socket.ntohs(0x0800))
      my_socket_s = socket.socket(socket.PF_PACKET, socket.SOCK_RAW, 
      socket.ntohs(0x0800))
      my_socket_s.bind(('eth0',socket.htons(0x0800)))
  • The following piece of code will...
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 £13.99/month. Cancel anytime
Visually different images