100% found this document useful (1 vote)
406 views66 pages

Ethical Hacking with Python Tools

This document summarizes how Python can be used for ethical hacking and penetration testing. It discusses several Python modules like Sockets, Requests, BeautifulSoup, and Shodan that allow analyzing network traffic and metadata. It also covers port scanning and checking for vulnerabilities using tools like Nmap, port scanning networks asynchronously, and using Nmap scripts to detect vulnerabilities on open ports. Advanced techniques discussed include interfacing with Metasploit through its API, scraping a Nexpose vulnerabilities server with BeautifulSoup, and referencing other Python penetration testing tools and libraries.

Uploaded by

korab korab
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
406 views66 pages

Ethical Hacking with Python Tools

This document summarizes how Python can be used for ethical hacking and penetration testing. It discusses several Python modules like Sockets, Requests, BeautifulSoup, and Shodan that allow analyzing network traffic and metadata. It also covers port scanning and checking for vulnerabilities using tools like Nmap, port scanning networks asynchronously, and using Nmap scripts to detect vulnerabilities on open ports. Advanced techniques discussed include interfacing with Metasploit through its API, scraping a Nexpose vulnerabilities server with BeautifulSoup, and referencing other Python penetration testing tools and libraries.

Uploaded by

korab korab
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
  • Introduction Python Pentesting
  • Tools
  • Sockets Port Scan
  • Banner Server
  • Requests
  • BeautifulSoup
  • Shodan
  • BuiltWith
  • Analysis Metadata
  • Port Scanning
  • Check FTP Login Anonymous
  • PyWebFuzz
  • Heartbleed
  • Advanced Tools
  • Metasploit
  • Nexpose
  • Pentesting Tool
  • References & Libs
  • Books
  • Conclusion

Ethical hacking with

Python tools
JOSE MANUEL ORTEGA
@JMORTEGAC

[Link]

INDEX
Introduction Python pentesting
Modules(Sockets,Requests,BeautifulSoup,Shodan)
Analysis metadata

Port scanning & Checking vulnerabilities


Advanced tools
Pentesting-tool

Python Pentesting
Multi platform
Prototypes and proofs of concept(POC)
Many tools and libraries focused on security
OSINT and Pentesting tools
Very good documentation

Python Pentesting

[Link]

The Harvester

The Harvester

W3AF

Tools
Scapy
Capturing

and analysing network packets

FiMap
Detecting

RFI/LFI vulnerabilites

XSScrapy
Detecting

XSS vulnerabilites

Sockets Port scan


import socket
#TCP
sock = socket(socket.AF_INET,socket.SOCK_STREAM)

result = sock.connect_ex(('[Link]',80))
if result == 0:
print "Port is open"
else:
print "Port is filtered"

Sockets Port scan

Socket resolving IP/domain

Banner server

Banner server

Requests

Checking headers

Checking headers

Requests
import requests
http_proxy = "[Link]
https_proxy = "[Link]

proxyDict = {
"http" : http_proxy,
"https" : https_proxy
}

r = [Link](url,proxies=proxyDict)

Requests Authentication

BeautifulSoup

Internal/external links

Internal/external links

Extract images and documents

Scrapy

Web Scraping

Shodan

[Link]

Shodan
import shodan
SHODAN_API_KEY = "insert your API key here"
api = [Link](SHODAN_API_KEY)

Shodan

[Link]

Shodan

Shodan

BuiltWith
pip install builtwith
[Link]([Link]

Analysis metadata

Analysis metadata

Analysis metadata

Port Scanning

Python-nmap
Automating port scanning
Synchronous and asynchronous modes

import nmap
# Synchronous
nm = [Link]()
# [Link](ip/range,port_list)
results = [Link]('[Link]', '22,25,80,443')

NmapScanner

NmapScanner
for port in port_list:
NmapScanner().nmapScan(ip, port)

NmapScanner Async
#Asynchronous
nm_async = [Link]()
def callback_result(host, scan_result):
print '------------------'
print host, scan_result
nm_async.scan(hosts='[Link]/30', arguments='-sP',
callback=callback_result)
while nm_async .still_scanning():
print("Waiting >>>")
nm_async.wait(2)

NmapScanner Async

Scripts Nmap

Scripts Nmap
Programming routines allow to find potential

vulnerabilities in a given target


First check if the port is open
Detect vulnerabilities in the service port openned

[Link](arguments="-n -A -p3306 -script=/usr/share/nmap/scripts/[Link]")

Mysql Scripts Nmap

Check FTP Login Anonymous

Check FTP Login Anonymous

Check Webs sites


pip install pywebfuzz

[Link]

PyWebFuzz
from pywebfuzz import fuzzdb
import requests
logins = [Link]

domain = "[Link]
for login in logins:
print Checking... "+ domain + login
response = [Link](domain + login)
if response.status_code == 200:
print "Login Resource: " +login

PyWebFuzz

Heartbleed
Vulnerability in OpenSSL V1.0.1
Multi-threaded tool for scanning hosts for CVE-

2014-0160.
[Link]
[Link]

Heartbleed

Heartbleed

Advanced tools

Metasploit
python-msfrpc

Metasploit API call


Calls in msgpack format

Nexpose
Tool developed by Rapid7 for scanning

and vulnerability discovery.


It allows programmatic access to other
programs via HTTP/s requests.
BeautifulSoup to obtain data from
vulnerabilities server

Nexpose

Pentesting tool

[Link]

[Link]

References & libs


[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

penetration-testers%E2%80%8B/
[Link]

Books

Books

THANK YOU!

JOSE MANUEL ORTEGA 
@JMORTEGAC 
Ethical hacking with  
Python tools
 
https://speakerdeck.com/jmortega
INDEX 
 
Introduction Python pentesting 
Modules(Sockets,Requests,BeautifulSoup,Shodan) 
Analysis metadata 
Port scanning
Python Pentesting 
 
Multi platform 
Prototypes and proofs of concept(POC) 
Many tools and libraries focused on security
Python Pentesting
 
http://sparta.secforce.com/
 
The Harvester
 
The Harvester
 
W3AF
Tools 
 
Scapy 
Capturing and analysing network packets 
FiMap 
Detecting RFI/LFI vulnerabilites 
XSScrapy 
Detecting

You might also like