SlideShare a Scribd company logo
P U R N A C H A N D E R
Pen-Test Techniques using
Python
Why?
 Easy ( Install, learn, Code)
 Tons of Libraries
 Code is easy to understand
 Multiplatform
 Good for Prototyping
 Free
History
 Conceived in late 80´s and first implementation in
1989
 Created by Guido Van Rossum
 Actually there are two branches 2.x and 3.0
Python
 Interpreted language
 Object oriented
 Indentation is significant in Python, block delimiter.
 Usual control structures (if, while, etc)
 Multiple levels of organization (function, classes,
modules, packages)
Who is using Python?
 Canvas W3AF
 Sqlmap Impacket
 Google
 ImmunityDebugger
 Peach
 Sulley
 Paimei
 Scapy
 Spike Proxy
 Core Impact
Data Types
Data types:
 Strings - “Hello”
 Numbers – 123
 Lists – [‘hello’,’2’,’1’]
 Tuples - (‘1’,’2’,’3’) (immutable)
 Dictionaries – d = {‘key1’:’dog’,’key2’:’cat’}
Basic Code bits
import sys
ofile = "dictionary.txt"
fil = open(ofile,'r')
x = fil.readlines()
for y in x:
print (y)
Urllib3
 Library to deal with HTTP
import urllib3
http = urllib3.PoolManager()
r = http.request('GET', 'https://python.org/')
print (r.status)
print (r.data)
7 Zip Cracker
import os, sys,
pas = open('passwords.txt', 'rb')
password=pas.readlines()
for x in password:
try:
fp = open('test.7z', 'rb')
archive = Archive7z(fp, password=x)
print ”The password is" + x
sys.exit()
except Exception, e:
fp.close()
Win32Com
 Library that allows us to access COM objects in
Win32 systems
 We can automate Word, Excel, Powerpoint, access
WMI and etc..
Excel Processing
from win32com.client import Dispatch
xlApp = Dispatch("Excel.Application")
xlApp.Visible = 1
xlApp.Workbooks.open("test.xls")
for x in range(1,100):
nombre=str(xlApp.ActiveSheet.Cells(x,5))
print nombre
xlApp.Quit()
WMI
import wmi
c = wmi.WMI ()
for process in c.Win32_Process ():
print process.ProcessId, process.Name
DEMO
Finding XSS Vulnerability in Web Application
SCRIPT
import http.client
for xss in xss_array:
#print (xss)
url = 'www.skywatcher.com'
conn = http.client.HTTPConnection(url)
print ( url+ '/downloads.php?cat='+ xss)
conn.request('GET', '/downloads.php?cat='+ xss)
resp = conn.getresponse()
body = resp.read()
if resp.version == 10:
print('HTTP/1.0 %s %s' % (resp.status, resp.reason))
if resp.version == 11:
print('HTTP/1.1 %s %s' % (resp.status, resp.reason))
for header in resp.getheaders():
print('%s: %s' % (header[0], header[1]))
#print ('n', body)
print ("------------------------------------------------------------------------------")
conn.close()
Console Output
THANK YOU
Q & A

More Related Content

PDF
An Introduction to User Space Filesystem Development
PPTX
Why learn Internals?
PPT
Introduction to python
PDF
Glusterfs session #18 intro to fuse and its trade offs
PPT
Python in 90mins
DOCX
source code which create file and write into it
PPTX
Learn PYTHON at ASIT
ODP
biopython, doctest and makefiles
An Introduction to User Space Filesystem Development
Why learn Internals?
Introduction to python
Glusterfs session #18 intro to fuse and its trade offs
Python in 90mins
source code which create file and write into it
Learn PYTHON at ASIT
biopython, doctest and makefiles

What's hot (20)

PDF
Coding in GO - GDG SL - NSBM
PPTX
Nodejs buffers
PPTX
n|u Dharamsala Humla : Memory Forensic by Tenzin Chokden
PDF
Linux intro 5 extra: makefiles
PDF
Build, Ship, and Run Any App, Anywhere using Docker
PDF
pa-pe-pi-po-pure Python Text Processing
PDF
Glusterfs session #8 memory tracking infra, io-threads
PPT
Unix tutorial-08
PDF
Distributed Multi-device Execution of TensorFlow – an Outlook
ODP
Clojure made simple - Lightning talk
PDF
Unix for Librarians
PDF
جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
PDF
Flowchart - Building next gen malware behavioural analysis environment
PDF
tokyotalk
PPTX
Using strace
PDF
A TurtleBot Configurations Measurement Harness to Build a Sensitivity Model
PDF
Compact ordered dict__k_lab_meeting_
ODP
Clojure made really really simple
PDF
Cotap Tech Talks: Keith Lazuka, Digital Communication using Sound and Swift
PDF
Coding in GO - GDG SL - NSBM
Nodejs buffers
n|u Dharamsala Humla : Memory Forensic by Tenzin Chokden
Linux intro 5 extra: makefiles
Build, Ship, and Run Any App, Anywhere using Docker
pa-pe-pi-po-pure Python Text Processing
Glusterfs session #8 memory tracking infra, io-threads
Unix tutorial-08
Distributed Multi-device Execution of TensorFlow – an Outlook
Clojure made simple - Lightning talk
Unix for Librarians
جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
Flowchart - Building next gen malware behavioural analysis environment
tokyotalk
Using strace
A TurtleBot Configurations Measurement Harness to Build a Sensitivity Model
Compact ordered dict__k_lab_meeting_
Clojure made really really simple
Cotap Tech Talks: Keith Lazuka, Digital Communication using Sound and Swift
Ad

Viewers also liked (20)

PDF
Analyse Yourself
PDF
Wireshark display filters
PDF
Short 1100 Jart Armin - The Pocket Botnet
PDF
Himakomers magazine
PDF
Hack x crack_scapy2
DOCX
Sushma Pati1mtech fresher
PDF
DefCon 2012 - Bluetooth Monitoring With SCAPY
PDF
Hallowed be thy packets by Paul Coggin
PDF
The jar of joy
PPT
A tale of two proxies
PPT
Scapy. Generación y manipulación básica de paquetes de red
PPTX
Attacks and their mitigations
PDF
Fun with TCP Packets
PDF
#RootedCON2012 - DNS: A botnet dialect - Carlos Diaz & Francisco J. Gomez
PDF
The (In)Security of Topology Discovery in Software Defined Networks
PDF
Jad NEHME - Alcatel-Lucent - Report
PDF
Exploiting First Hop Protocols to Own the Network - Paul Coggin
PDF
Python begin
PPTX
How to dominate a country
PPTX
Cybercamp 2015 - Python, hacking y sec-tools desde las trincheras
Analyse Yourself
Wireshark display filters
Short 1100 Jart Armin - The Pocket Botnet
Himakomers magazine
Hack x crack_scapy2
Sushma Pati1mtech fresher
DefCon 2012 - Bluetooth Monitoring With SCAPY
Hallowed be thy packets by Paul Coggin
The jar of joy
A tale of two proxies
Scapy. Generación y manipulación básica de paquetes de red
Attacks and their mitigations
Fun with TCP Packets
#RootedCON2012 - DNS: A botnet dialect - Carlos Diaz & Francisco J. Gomez
The (In)Security of Topology Discovery in Software Defined Networks
Jad NEHME - Alcatel-Lucent - Report
Exploiting First Hop Protocols to Own the Network - Paul Coggin
Python begin
How to dominate a country
Cybercamp 2015 - Python, hacking y sec-tools desde las trincheras
Ad

Similar to PenTest using Python By Purna Chander (20)

PPTX
Penetration testing using python
PDF
Python for Penetration testers
PPTX
How Python Empowers Ethical Hackers by Supriya Kumar Mitra
PDF
Python for web security - beginner
PPT
Master Python Basics Easily – From Zero to Real-World Applications for UG Stu...
PDF
Python Cookbook 1st Edition Martelli Alex Ascher David
PDF
Python Cookbook_ Nho Vĩnh Share.pdf
PPTX
python programming.pptx
PDF
summer training report on python
PDF
Python Cookbook 1st Edition Alex Martelli
PDF
Python quick guide1
PDF
Instant download Python Cookbook 1st Edition Alex Martelli pdf all chapter
PPTX
UNIT 1 PYTHON introduction and basic level
PPTX
Python with data Sciences
PPTX
Introduction to python for cybersecurity pythonminna
PDF
Python Cookbook 1st Edition Alex Martelli
PPTX
Python | What is Python | History of Python | Python Tutorial
PDF
Python Cookbook 1st Edition Alex Martelli
PDF
[FREE PDF sample] Programming Python with CD 2nd Edition Mark Lutz ebooks
PDF
What is Python? (Silicon Valley CodeCamp 2014)
Penetration testing using python
Python for Penetration testers
How Python Empowers Ethical Hackers by Supriya Kumar Mitra
Python for web security - beginner
Master Python Basics Easily – From Zero to Real-World Applications for UG Stu...
Python Cookbook 1st Edition Martelli Alex Ascher David
Python Cookbook_ Nho Vĩnh Share.pdf
python programming.pptx
summer training report on python
Python Cookbook 1st Edition Alex Martelli
Python quick guide1
Instant download Python Cookbook 1st Edition Alex Martelli pdf all chapter
UNIT 1 PYTHON introduction and basic level
Python with data Sciences
Introduction to python for cybersecurity pythonminna
Python Cookbook 1st Edition Alex Martelli
Python | What is Python | History of Python | Python Tutorial
Python Cookbook 1st Edition Alex Martelli
[FREE PDF sample] Programming Python with CD 2nd Edition Mark Lutz ebooks
What is Python? (Silicon Valley CodeCamp 2014)

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Cloud computing and distributed systems.
PDF
Approach and Philosophy of On baking technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Encapsulation theory and applications.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Electronic commerce courselecture one. Pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
The AUB Centre for AI in Media Proposal.docx
Cloud computing and distributed systems.
Approach and Philosophy of On baking technology
Review of recent advances in non-invasive hemoglobin estimation
Unlocking AI with Model Context Protocol (MCP)
Reach Out and Touch Someone: Haptics and Empathic Computing
Encapsulation theory and applications.pdf
Encapsulation_ Review paper, used for researhc scholars
“AI and Expert System Decision Support & Business Intelligence Systems”
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Electronic commerce courselecture one. Pdf
Big Data Technologies - Introduction.pptx
Advanced methodologies resolving dimensionality complications for autism neur...

PenTest using Python By Purna Chander

  • 1. P U R N A C H A N D E R Pen-Test Techniques using Python
  • 2. Why?  Easy ( Install, learn, Code)  Tons of Libraries  Code is easy to understand  Multiplatform  Good for Prototyping  Free
  • 3. History  Conceived in late 80´s and first implementation in 1989  Created by Guido Van Rossum  Actually there are two branches 2.x and 3.0
  • 4. Python  Interpreted language  Object oriented  Indentation is significant in Python, block delimiter.  Usual control structures (if, while, etc)  Multiple levels of organization (function, classes, modules, packages)
  • 5. Who is using Python?  Canvas W3AF  Sqlmap Impacket  Google  ImmunityDebugger  Peach  Sulley  Paimei  Scapy  Spike Proxy  Core Impact
  • 6. Data Types Data types:  Strings - “Hello”  Numbers – 123  Lists – [‘hello’,’2’,’1’]  Tuples - (‘1’,’2’,’3’) (immutable)  Dictionaries – d = {‘key1’:’dog’,’key2’:’cat’}
  • 7. Basic Code bits import sys ofile = "dictionary.txt" fil = open(ofile,'r') x = fil.readlines() for y in x: print (y)
  • 8. Urllib3  Library to deal with HTTP import urllib3 http = urllib3.PoolManager() r = http.request('GET', 'https://python.org/') print (r.status) print (r.data)
  • 9. 7 Zip Cracker import os, sys, pas = open('passwords.txt', 'rb') password=pas.readlines() for x in password: try: fp = open('test.7z', 'rb') archive = Archive7z(fp, password=x) print ”The password is" + x sys.exit() except Exception, e: fp.close()
  • 10. Win32Com  Library that allows us to access COM objects in Win32 systems  We can automate Word, Excel, Powerpoint, access WMI and etc..
  • 11. Excel Processing from win32com.client import Dispatch xlApp = Dispatch("Excel.Application") xlApp.Visible = 1 xlApp.Workbooks.open("test.xls") for x in range(1,100): nombre=str(xlApp.ActiveSheet.Cells(x,5)) print nombre xlApp.Quit()
  • 12. WMI import wmi c = wmi.WMI () for process in c.Win32_Process (): print process.ProcessId, process.Name
  • 13. DEMO Finding XSS Vulnerability in Web Application
  • 14. SCRIPT import http.client for xss in xss_array: #print (xss) url = 'www.skywatcher.com' conn = http.client.HTTPConnection(url) print ( url+ '/downloads.php?cat='+ xss) conn.request('GET', '/downloads.php?cat='+ xss) resp = conn.getresponse() body = resp.read() if resp.version == 10: print('HTTP/1.0 %s %s' % (resp.status, resp.reason)) if resp.version == 11: print('HTTP/1.1 %s %s' % (resp.status, resp.reason)) for header in resp.getheaders(): print('%s: %s' % (header[0], header[1])) #print ('n', body) print ("------------------------------------------------------------------------------") conn.close()