How to Write Python Scripts
In this part of the book, you’ll learn how to write codes using the Python language. It will
also explain the fundamental terms, concepts, and syntax of Python codes. Read this
material carefully; it will help you become a knowledgeable programmer and hacker.
Important Note: You need to use a text editor when writing codes. Kali Linux has a builtin text editor called “Leafpad”. As you can see, Kali Linux contains everything you need
to hack computers and systems.
Proper Formatting
Formatting plays an important role in the Python language. The interpreter of Python
groups codes based on their format. Keep in mind that consistency is more important than
precision. You don’t have to follow strict formatting rules. You just have to be consistent
with the format you are using.
For example, if you’ll use double indentation to differentiate a code block, indent each line
of that code block twice. Forgetting this simple rule can lead to error messages and/or
failed attacks.
How to Run a Python File
Nothing beats active learning. To help you master this process, let’s write a basic piece of
code using Leafpad. Here’s the code:
#! /user/bin/python
name=””
print “Hi, ” + name + “!”
Save the file as “sample.py”.
This code consists of three lines. The first one triggers the interpreter of Python. The
second one creates a variable called “name” and sets a value for it. The last line
concatenates the word “Hi” with the user’s input and inserts an exclamation mark.
At this point, you can’t execute the code yet. You must give yourself the permission to run
In this part of the book, you’ll learn how to write codes using the Python language. It will
also explain the fundamental terms, concepts, and syntax of Python codes. Read this
material carefully; it will help you become a knowledgeable programmer and hacker.
Important Note: You need to use a text editor when writing codes. Kali Linux has a builtin text editor called “Leafpad”. As you can see, Kali Linux contains everything you need
to hack computers and systems.
Proper Formatting
Formatting plays an important role in the Python language. The interpreter of Python
groups codes based on their format. Keep in mind that consistency is more important than
precision. You don’t have to follow strict formatting rules. You just have to be consistent
with the format you are using.
For example, if you’ll use double indentation to differentiate a code block, indent each line
of that code block twice. Forgetting this simple rule can lead to error messages and/or
failed attacks.
How to Run a Python File
Nothing beats active learning. To help you master this process, let’s write a basic piece of
code using Leafpad. Here’s the code:
#! /user/bin/python
name=”
print “Hi, ” + name + “!”
Save the file as “sample.py”.
This code consists of three lines. The first one triggers the interpreter of Python. The
second one creates a variable called “name” and sets a value for it. The last line
concatenates the word “Hi” with the user’s input and inserts an exclamation mark.
At this point, you can’t execute the code yet. You must give yourself the permission to run
