- How To Install python3 on Kali Linux
- What is python3
- Install python3 Using apt-get
- Install python3 Using apt
- Install python3 Using aptitude
- How To Uninstall python3 on Kali Linux
- Uninstall python3 And Its Dependencies
- Remove python3 Configurations and Data
- Remove python3 configuration, data, and all of its dependencies
- References
- Summary
- Python on Kali Linux: A beginner’s guide to get started
- Getting Started with Python on Kali Linux
- How to install Python on Kali Linux
- How to install PIP on Kali Linux
- Python libraries on Kali Linux
- Python code editors you can use on Kali Linux
- Practical applications with Python on Kali Linux
- Scan network and run attacks based on the results
- Packets sniffing and manipulation
- Coding malware
- Building tools for you
How To Install python3 on Kali Linux
In this tutorial we learn how to install python3 on Kali Linux.
What is python3
Python, the high-level, interactive object oriented language, includes an extensive class library with lots of goodies for network programming, system administration, sounds and graphics.
This package is a dependency package, which depends on Debian’s default Python 3 version (currently v3.9).
There are three ways to install python3 on Kali Linux . We can use apt-get , apt and aptitude . In the following sections we will describe each method. You can choose one of them.
Install python3 Using apt-get
Update apt database with apt-get using the following command.
After updating apt database, We can install python3 using apt-get by running the following command:
sudo apt-get -y install python3
Install python3 Using apt
Update apt database with apt using the following command.
After updating apt database, We can install python3 using apt by running the following command:
sudo apt -y install python3
Install python3 Using aptitude
If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Kali Linux. Update apt database with aptitude using the following command.
After updating apt database, We can install python3 using aptitude by running the following command:
sudo aptitude -y install python3
How To Uninstall python3 on Kali Linux
To uninstall only the python3 package we can use the following command:
sudo apt-get remove python3
Uninstall python3 And Its Dependencies
To uninstall python3 and its dependencies that are no longer needed by Kali Linux, we can use the command below:
sudo apt-get -y autoremove python3
Remove python3 Configurations and Data
To remove python3 configuration and data from Kali Linux we can use the following command:
sudo apt-get -y purge python3
Remove python3 configuration, data, and all of its dependencies
We can use the following command to remove python3 configurations, data and all of its dependencies, we can use the following command:
sudo apt-get -y autoremove --purge python3
References
Summary
In this tutorial we learn how to install python3 using different package management tools like apt, apt-get and aptitude.
Python on Kali Linux: A beginner’s guide to get started
Python is now the most used programming language in the world, with usage ranging from artificial intelligence to web development or even smartphone applications. For hackers and pen-testers, Python can also become a great ally on Kali Linux, to save time on many processes. Let’s see how to install and use Python on your favorite distribution.
On Kali Linux, a recent version of Python is already installed with dozens of libraries ready to use. No code editor is present, but most of them are available in the default repository and can be installed easily with APT.
Let’s start by checking your system installation, making sure Python is ready to use, and I’ll show you a few things you can try with Python on Kali Linux.
Getting Started with Python on Kali Linux
Even if coding in Python is maybe not the main goal for the typical Kali Linux user, everything is already set up for you on a fresh installation. Except choosing a text editor, there is almost nothing to do.
How to install Python on Kali Linux
Python is already installed by default on Kali Linux. I kept the default options during the installation (including the essentials tools), and it was already there.
You can use this command to make sure Python is installed, and see which version:
python —version
It should be Python 3, maybe not the latest version, but one that is pretty recent. You can always uninstall it and get the latest version manually, but in most cases it’s not worth the effort. Just do regular updates with APT, and it will get updated when ready:
sudo apt update
sudo apt upgrade
Hide your IP address and location with a free VPN:
Try it for free now, companies are paying for you.
1500 servers in 120 countries. It’s free. Forever. No email required.
By the way, if for any reason Python is not present on your system, you can install it with APT too:
sudo apt install python
How to install PIP on Kali Linux
PIP is a package manager for Python. It’s connected to a large database of libraries available online (Pyhton Package Index, or PyPi). It’s already installed by default on Kali Linux, so you can use it right away.
You can use this command to make sure it’s available and see the version:
pip —version
I’ll elaborate on libraries in the next paragraph, but basically, if you need any random library that is not available with APT (or pre-installed on Kali Linux), you can use this tool to download and install them quickly.
Python libraries on Kali Linux
Stay tuned with the latest security news!
You’ll enjoy receiving the recent articles directly in your inbox every week!
Python is nothing without its libraries. Each library adds new functions that you can use in your Python scripts. You don’t have to code everything yourself, you can rely on projects created by other developers, and just reuse their work in yours.
Dozens of libraries are pre-installed on a fresh Kali Linux system (probably more than 100 in fact). So, for most Python projects, you’ll already have the libraries you need available.
Here is a screenshot of some of them:
I got this list by using the “dpkg” command:
sudo dpkg -l | grep python3
I’ll take and example later, but if you need a library that is not pre-installed, you can generally install it with APT, by using this syntax:
sudo apt install python3-
Or by using the PIP tool I introduce earlier, like this:
pip install
We’re almost done, the only thing missing might be a fancy code editor, if you don’t want to use the default notepad or a text editor in a terminal.
Python code editors you can use on Kali Linux
Except the default notepad or Nano, Kali Linux doesn’t include any graphic text editor. However, Kali Linux is based on Debian, so most of them can be installed manually from the default repository, or by using packages provided by the developers.
That’s a bit strange that they didn’t include anything, when we see that everything else is taken care of. But I guess they weren’t able to decide which one to choose :-).
Anyway, I tried to install VS Code and Geany, and it was done easily.
VS Code is not open-source, but the open-source version (code-oss) is available in the default repository. If you are used to Visual Studio Code, it should be good enough. You can install it with APT:
sudo apt install code-oss
Same thing for Geany, that is available with:
sudo apt install geany
For other editors, you’ll find either find repositories that you can add, Debian packages or source files to compile and install manually. For example, if you prefer Sublime Text, you can download the Debian package here (a repository is also available).
Kali Linux For Beginners
Learn how the good and the bad guys hack!
Learn from the pros how to use Kali Linux easily and quickly.
Nano is available directly by default, several options are available in the default repository, and plenty of editors have a Linux version that works on Kali. So make your choice and move on once you’re ready.
Practical applications with Python on Kali Linux
All of this is very interesting, but Kali Linux is not really the first choice for Python developers. So, why should you use Python, and what can you do with it? Let’s see a few real-life examples.
Scan network and run attacks based on the results
Kali Linux comes with many tools, that are generally used in command lines. So, basically, you rely on tools, but you do everything manually, in a terminal (or via the graphic interface is there is one).
For example, Nmap is a popular tool to scan hosts on a network, but do you know that there is a library (python3-nmap) available to do it inside your Python scripts?
This way you can scan the network, and run actions based on the results you get. Maybe it’s a deeper scan on specific devices, or adding the IP addresses in the queue list for other scripts or tools you have.
Strangely, the Nmap library is not installed by default, but you can install it with:
sudo apt install python3-nmap
You can then use it in your scripts to detect open ports on the network.
Here is a basic example:
Stay tuned with the latest security news!
You’ll enjoy receiving the recent articles directly in your inbox every week!
This script will scan the ports open on my target (192.168.222.100), for a specific range (between 22 and 80). I then use the has_tcp() function to display a message to tell if SSH or HTTP are responding.
In a more concrete example, I could scan all the devices on the local network, and do something specific when I find one with the SSH port open (a brute force attack or something like that).
Note: If you use the version available on PyPi, the syntax will be slightly different, so make sure to follow the documentation corresponding to the library you use.
Packets sniffing and manipulation
Scapy is another tool you can use on Kali Linux to interact with network packets. It comes with a Python library, so you can do everything directly within your Python scripts.
Scapy and the corresponding Python library are installed by default on Kali Linux.
You can for example use the sniff() function to analyze packets on your network, and do specific actions depending on their content or destination. Or you can simply send a “ping” to any IP address, and do something if there is a response (like the port scanner code with Nmap).
You get the idea. It’s the same thing as with Nmap. We take a tool that is available on Kali Linux, but use it in Python, so we can use loops, conditions and run different actions based on the results. All the good stuff that programmers like.
If you want to give it a try, pick the library corresponding to a tool you know and read the online documentation for more details about the functions available.
Coding malware
You may not know it, but most malware is written in Python. So whether you’re a pen-tester or a budding hacker, you can use Python not only to make your life easier, but also to send attacks directly to a target and see how users react to the threat.
I do not endorse this type of practice, so I won’t give you more details about this, but it’s not a coincidence if Python is pre-installed on Kali Linux. Both types of users can benefit from it.
Building tools for you
Overall, Python is a good way to create custom tools or scripts for pen testing, auditing, etc.
Learning Python shouldn’t be that complicated, whether you already have some experience with other languages or not. In most cases, you can rely on existing libraries, and follow the examples available in their documentation to quickly get results.
- The complete Ethical Hacking course (Python & Kali Linux)
Perfect for beginners in Python, as most of the course is about Python.
It merges with ethical hacking near the end, but it’s mostly a Python course. - Ethical Hacking Bootcamp: Zero to mastery
The 5 phases of ethical hacking, with Python practice for each of them (port scanner, password cracking, etc.) - Applied Ethical Hacking
It’s like the top-level of ethical hacking course, once you already know the basics.
You’ll use most of the Kali Linux tools, Python, but also discover broader concepts like social engineering.
I gave you the basics to get started, now it’s up to you to apply them in your projects and environment. Following a complete course can save you a lot of time, but it’s not mandatory (you can always learn by yourself, it just requires more effort in general).
Hi, my name is Patrick, I’m a web developer and network administrator. I have always been interested in security, and I created this website to share my findings with you.