Book Image

Learning Python Web Penetration Testing

By : Christian Martorella
Book Image

Learning Python Web Penetration Testing

By: Christian Martorella

Overview of this book

Web penetration testing is the use of tools and code to attack a website or web app in order to assess its vulnerability to external threats. While there are an increasing number of sophisticated, ready-made tools to scan systems for vulnerabilities, the use of Python allows you to write system-specific scripts, or alter and extend existing testing tools to find, exploit, and record as many security weaknesses as possible. Learning Python Web Penetration Testing will walk you through the web application penetration testing methodology, showing you how to write your own tools with Python for each activity throughout the process. The book begins by emphasizing the importance of knowing how to write your own tools with Python for web application penetration testing. You will then learn to interact with a web application using Python, understand the anatomy of an HTTP request, URL, headers and message body, and later create a script to perform a request, and interpret the response and its headers. As you make your way through the book, you will write a web crawler using Python and the Scrappy library. The book will also help you to develop a tool to perform brute force attacks in different parts of the web application. You will then discover more on detecting and exploiting SQL injection vulnerabilities. By the end of this book, you will have successfully created an HTTP proxy based on the mitmproxy tool.
Table of Contents (9 chapters)

Advanced SQLi exploiting

In this section, we're going to add a function to read all the table names from the database, and we are going to add a function to read the files from the database server OS.

First, we're going to see how we can obtain all the table names that are in the database in order to see if we see something of interest, and then we're going to add the capability to reach finals from the OS file system.

Now, let's open the file SQLinjector-3.py. We have a new function in here that will help us obtain the table names in the different schemas, except the ones we are filtering out to reduce the noise in the output:

def detect_table_names(url):
new_url= url.replace("FUZZ","""\'%20union%20SELECT%20CONCAT('TOK',
table_schema,'TOK'),CONCAT('TOK',table_name,'TOK')%20FROM
%20information_schema...