01. Lecture PPT - Python Programming Intro v2.3 (1)
01. Lecture PPT - Python Programming Intro v2.3 (1)
“Python is an open source, high level & general purpose programming language”
Hacking
Ethical
www.networkwalks.com Hacking
Lab Setup
For Cyber Security, Ethical Hacking, Networking & Programming practice
Main OS
(Windows10)
Manual IP: 10.0.0.2/24 (NATNetwork)
IP: x.x.x.x
Manual IP:
Manual IP: Manual IP: 10.0.0.16 /24 (NATNetwork) Manual IP:
10.0.0.10 /24 (NATNetwork) 10.0.0.7 /24 (NATNetwork) Follow networkwalks.com for detail 10.0.0.9 /24 (NATNetwork)
VIRUS ATTACKS
A. Version 1
B. Version 3
C. Version 4
www.networkwalks.com
Why Python for Cybersecurity & Networking?
Python is used heavily in Hacking scripts, pentesting scripts, Security tools & Network tools
• Python can be used to blend multiple technologies with Cybersecurity & Hacking like AI, ML, web applications,
Databases, perform complex mathematics, Data Analytics , …
• Python has a simple syntax, similar to the English language (making it simple for Cybersecurity & hacking related
tools)
• Python is object-oriented (main need for Cybersecurity & hacking related tools)
• Python runs on an interpreter system, meaning that code can be executed as soon as it is written, making it fast
(main need for Cybersecurity & hacking related tools)
• Python can be used by Hackers to create scripts & make malicious application.
• Python can be used by White-hat hackers to create defence scripts & Anti-viruses
• Python can be used to automate Security Devices like Firewalls & Networking Devices like Routers
www.networkwalks.com
Why Python for Cybersecurity & Networking?
DDoS tool Zip cracker Clipboard sniffer IP Location tracker BW monitoring tool
Beginner
Password Generator IP & MAC finder MAC Address Changer basic Network Mapping Tool (N-map)
Intermediate
Password Generator WiFi passwords stealer NFC Cracker WiFi Password cracker Vulnerabilities Scanner
Advanced
Network Automation for Cisco Routers Keylogger Replicating virus Kali Linux tools like MSF, Aircrack-ng, …
www.networkwalks.com
SOME MORE CYBERSECURITY PROJECTS/LABS BASED ON PYTHON
Practice Lab - Create a basic Network Mapping Tool (N-map) with single Port scan
Practice Lab - Create a Network Mapping Tool (N-map) with multiple ports scan (port range)
Practice Lab - Create a basic Network Automation Lab for Cisco Routers
Practice Lab - Create an advanced Network Automation Lab for Cisco Routers
• Many PCs and MACs will have python already installed. To check if you have
python installed on a Windows PC, search in the start bar for Python or run the
• If you find that you do not have python installed on your computer, then you can
www.python.org/downloads/windows/
www.python.org/downloads/release/python-381/
*Note: We have used Python version 3.8.1 in this course & labs. It is recommended that all
students should install & use same version to be in sync with class.
www.networkwalks.com
LIVEQUIZ
LIVE QUIZ
A. Pycharm
B. Turbo Pascal
C. Visual Studio Code
D. Sublime Text
www.networkwalks.com
Python Syntax (Rules)
✓ Take care of Indentation & whitespaces (no more curly brackets, as in other languages like C++)
✓ Variables don’t need to be declared first (they are declared as we assign first value to it)
www.networkwalks.com
Print Function (for display)
www.networkwalks.com
LIVEQUIZ
LIVE QUIZ
A. print(“One”)
B. print(One)
C. print(1)
www.networkwalks.com
User Input
www.networkwalks.com
If Else (Decision Making in Python)
✓ Example 1 a = 10
b = 2
if a>b:
print("a is greater than b")
✓ Example 2 a = 200
b = 33
if b>a:
print("b is greater than a")
else:
print("b is not greater than a")
All Python conditions:
• Equals: a == b
• Not Equals: a != b
• Less than: a < b
• Less than or equal to: a <= b
• Greater than: a > b
• Greater than or equal to: a >= b
*Elif is used for multiple level/nested IfElse
www.networkwalks.com
Loops (Repeated Tasks)
✓ While Loops Repeat a statement while a given condition is TRUE (tests the condition before executing the loop body)
Example i = 0
while i < 5:
print("Network Walks Academy")
i=i+1 #(or use i+=1)
www.networkwalks.com
LIVE QUIZ
networkwalks
networkwalks
networkwalks
networkwalks
networkwalks
www.networkwalks.com
Lecture PPT
NETWORKWALKS ACADEMY
www.networkwalks.com
Python Hierarchy
A Library is a collection of Packages & modules.
A Package is a collection of related modules that work together to provide certain functionality & so on…
Library
Pkg Pkg
fn fn fn fn fn fn fn fn
www.networkwalks.com
Python Libraries
A Library is a collection of Packages & modules. It is having a collection of related functionality of codes that allows us to
perform many tasks without writing full code. It is a reusable chunk of code that we can use by importing it in our program,
we can just use it by importing that library and calling the function of that library with period (.)
Example: Importing pandas library and call read_csv method/function using alias of pandas i.e. pd.
import pandas as pd
df = pd.read_csv("file1.csv")
www.networkwalks.com
Popular Python Libraries (General)
GUI
LIBRARIES
Tkinter
www.networkwalks.com
POPULAR PYTHON LIBRARIES for NETWORKING
Telnet
SUBPROCESS
pySNMP
pyATS
Paramiko
www.networkwalks.com
POPULAR PYTHON LIBRARIES for ETHICAL HACKING &
CYBERSECURITY
SUBPROCESS
Getmac
Telnet
Impacket
Getpass
www.networkwalks.com
Thank You