Python Penetration Testing - Tutorialspoint

Transcription

Python Penetration Testingi

Python Penetration TestingAbout the TutorialPenetration testing (Pen testing) is an attempt to evaluate the security of an ITinfrastructure by simulating a cyber-attack against computer system to exploitvulnerabilities. It helps an organization strengthen its defenses against cyber-attacks byidentifying vulnerabilities.AudienceThis tutorial will be useful for graduates, postgraduates, and research students who eitherhave an interest in this subject or have this subject as part of their curriculum. The readercan be a beginner or an advanced learner.PrerequisitesThe reader must have basic knowledge about Testing, Operating System, and ComputerNetworks. He/she should also be aware about basic Python programming concepts.Copyright & Disclaimer Copyright 2018 by Tutorials Point (I) Pvt. Ltd.All the content and graphics published in this e-book are the property of Tutorials Point (I)Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republishany contents or a part of contents of this e-book in any manner without written consentof the publisher.We strive to update the contents of our website and tutorials as timely and as precisely aspossible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt.Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of ourwebsite or its contents including this tutorial. If you discover any errors on our website orin this tutorial, please notify us at contact@tutorialspoint.comi

Python Penetration TestingTable of ContentsAbout the Tutorial . iAudience . iPrerequisites . iCopyright & Disclaimer . iTable of Contents . ii1.Python Penetration Testing — Introduction. 1Significance of Penetration (pen) Testing . 1Who is a good pen tester? . 2Penetration Testing Scope. 2What to install for practice penetration testing? . 32.Python Penetration Testing — Assessment Methodology . 4What is PTES? . 4Seven Phases of PTES . 4Pre-engagement Interactions Phase . 5Intelligence Gathering Phase . 6Threat Modeling Phase. 6Vulnerability Analysis Phase . 8Active testing . 8Passive testing . 8Validation . 9Research . 9Exploitation Phase . 9Post Exploitation Phase . 10Reporting . 103.Python Penetration Testing — A Primer on Network Communication . 13Reference Model . 13ii

Python Penetration TestingOSI Model . 14TCP/IP Model . 15Useful Architecture. 17Extended Ethernet Frame (Ethernet II frame) Format . 18The IP Packet Architecture . 19IPv4 . 19IPv6 . 21The TCP (Transmission Control Protocol) Header Architecture . 23The UDP (User Datagram Protocol) header architecture . 254.Python Penetration Testing — The Socket and its Methods . 27Python’s Socket Module for Socket Programming . 27Socket Methods . 28Program to establish a connection between server & client . 295.Python Penetration Testing — Python Network Scanner . 32Port Scanner using Socket . 32Port Scanner using ICMP (Live hosts in a network) . 33Concept of Ping Sweep . 34Port Scanner using TCP scan . 35Threaded Port Scanner for increasing efficiency . 376.Python Penetration Testing — Network Packet Sniffing . 39What can be sniffed? . 39How does sniffing work? . 39Types of Sniffing . 40The Sniffing Effects on Protocols . 40Implementation using Python . 417.Python Penetration Testing — ARP Spoofing . 43Working of ARP. 43What is ARP Spoofing? . 43iii

Python Penetration TestingImplementation using Python . 43Implementation using Scapy on Kali Linux . 458.Python Penetration Testing — Pentesting of Wireless Network . 47Important Terminologies . 47Communication between client and the wireless system . 47The Beacon Frame . 48Finding Wireless Service Set Identifier (SSID) using Python . 49Detecting Access Point Clients . 51Wireless Attacks . 519.Python Penetration Testing — Application Layer . 55Foot printing of a web server . 55Methods for footprinting of a web server . 55Footprinting of a Web Application . 58Methods for Footprinting of a Web Application . 5810. Python Penetration Testing — Client-side Validation . 60Server-side Validation & Client-side Validation . 60Tempering Client-side Parameter: Validation Bypass . 60Python Module for Validation Bypass . 6011. Python Penetration Testing — DoS & DDoS attack . 62DoS (Denial-of-Service) Attack . 62Types of DoS Attack & its Python Implementation . 62DDoS (Distributed Denial-of-Service) Attack . 6512. Python Penetration Testing — SQLi Web Attack . 67Types of SQLi Attack . 6713. Python Penetration Testing — XSS Web Attack . 70Types of XSS Attack . 70iv

1. Python Penetration Testing — IntroductionPython Penetration TestingPen test or penetration testing, may be defined as an attempt to evaluate the security ofan IT infrastructure by simulating a cyber-attack against computer system to exploitvulnerabilities.What is the difference between vulnerability scanning and penetration testing?Vulnerability scanning simply identifies the

We can perform penetration testing for servers, web applications, wireless networks, mobile devices and any other potential point of exposure using manual or automated technologies. Because of penetration testing, if we exploit any kind of vulnerabilities, the same must be forwarded to the IT and the network system manager to reach a strategic conclusion. Significance of Penetration (pen .