Python proudly holds the position as one of the world’s most popular programming languages. In most of the domains, it is giving its share. Employing python allows the user to work on multiple domains ranging from Data Science, Machine Learning, Deep Learning, Artificial Intelligence, Scientific Computing Scripting, Networking, Game Development to Web Development. Owing to the programming language’s multiple domain integrity, it is greatly loved by communities.
Python contains Domain-Specific Libraries. Stay tuned with us as we go through the multiple domains of development.
Who Created Python?
Guido Van Rossum is the man behind the creation of the Python Programming Language. He was born in 1956 in Haarlem in the Netherlands.
The name Python came from an Old BBC television comedy sketch series called “Monty Python Flying Circus”.
While various programming languages have been generated by large corporations equipping themselves with numerous experts and professionals, Python is an Exception.
What is Python?
Do you think it is a Snake? Actually not.
In the Computer World, Python is a Programming Language. It’s used for fulfilling demands of :
Interpreted Programming Language: In this language, the Interpreter always runs & checks Codes Line by Line.
Object-Oriented Programming Language: In this language, an Object (abstract data type) integrates State (data) & Behaviour (code).
High-Level Programming Language: It is a Programming Language that does not depend on any particular type of Computer Machine to write Codes.
General Purpose Programming Language: It is a Programming Language that is designed to be used in a wide variety of domains.
In order to start our journey, let’s get familiar with the environment in which we are going to implement Python Programming. Here, we will consider different environments for different domains of development that are available on the Internet.
Python Interpreter & Scripting with Python can give us a better approach for interacting with Operating Systems as well as integrating with them. These methods are especially useful in various technologies from Cyber Security to Infrastructure Management.
Here, we use Python Interpreter in Linux Environment which will help us in understanding Python as well as a Linux environment which is the backend of most of today’s technologies.
Let's start our journey which is a complete pool of Fun…..
Lab Required :
VMware or VirtualBox installed
KALI Linux Virtual Machine
KALi Linux with configured Repository
Install Python in KALI Linux
Alternate Lab :
WSL 2 (Windows Subsystem Linux) enabled
Download KALI Linux from Microsoft App Store
Configure Repository in WSL2 KALI
Install Python in WSL2 KALI
Hands-On with Python :
1. How do commands run in Linux?
So let’s investigate the source of operation.
Source Location of Commands
Usually, Commands operate from /usr/bin or /usr/sbin directory in Linux. It means we have to create our own commands in these directories.
Creation of File at Specific Location
Here, we created our file where we will put in our code to do some operation.
Permission required for Command File
If we try to operate the command, we get an error:
bash: /usr/bin/moon: Permission denied
What does this error mean?
It means /usr/bin has a moon file but it does not have permission to execute. So, we have to make it executable.
Permit a file to be Executable
This time there is no error in the execution of the moon file.
2. How will Code behave with Interpreter & Command File
Python Interpreter Working
As you can see, I just print my name using Python Code and it’s working well. Here, you got the behavior of the Interpreter what we have defined in Interpreted Programming Language.
Now, Put the same code in the command file & Save it.
Editing a file with Python Code
Now, try to execute the moon file.
Error due to execution of Command FIle
Here, you got an error :
/usr/bin/moon: line 1: syntax error near unexpected token `"Priyanshu Gupta"'
/usr/bin/moon: line 1: `print("Priyanshu Gupta")'
Even you have put the same code as you write in Python Interpreter. Because this file is a Plain Text File, to execute it we need a program that can understand & lead this program.
Alternative way of execution of Command
Here, just focus we execute the Python 3 interpreter by executing the source of location, which leads to the Python 3 Interpreter. We will follow the same to lead our plain text file. Because Script will run line by line where First line execution for Python Interpreter then we move ahead to write the Code.
Interpreted Characteristic of Script & Python
This is the syntax we need to follow when calling a command to lead the code. Like this, write your code & Save it.
Final Execution of our Command in both way
This is how we developed our Own Command which is executable in both ways.
Python 3 has been integrated with Linux OS which gives us the basic idea of the functionality of commands. Linux is an open-source environment that is used by most companies in almost every field from development to management of IT Infrastructures.
Here, we integrate Linux & Python to work with both Linux as well as Python. We also determine the Interpreted behavior of Python which is very useful in the development of scripts. This is also used to create our own software with Terminal User Interface.
This type of development environment is very useful in the domain of Cyber Security & Networking. Especially where tasks are in an order of Priority. This setup also gives us free hands to work in the integration of multiple technologies.
In this series, we will learn to use Python3 for creating Scripts.
“You are not Script Kiddies, You have your Own way of Defending & Attacking ”
Hoping you enjoyed going through this blog.