Устанавливаем python kali linux

How to Install Python 3 on Kali Linux

In this tutorial, you will learn how to get the latest version of Python and pip installed on Kali Linux. Python can be installed from the Kali software repository with apt command, or we can get the latest Python release or pre-release from Python.org. We’ll cover both methods below.

Install From Kali Repo

Step 1. To check what version of Python is installed in your system:

$ python3 --version Python 3.10.8

Step 2. To install the latest version of Python, execute the following command:

$ sudo apt update $ sudo apt install python3

Step 3. To install pip on Kali (the package installer for Python):

$ sudo apt install python3-pip

Step 4. To launch Python, simply execute the next command:

Install Latest Version From Official Download

The next method takes a few additional steps, but ensures that you download and install the absolute latest Python release.

Step 1. Before installing Python, always make sure that you have your system up to date:

$ sudo apt update $ sudo apt upgrade

Step 2. Next, we’ll install the dependencies:

$ sudo apt install build-essential pkg-config zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev libbz2-dev

Step 3. Navigate to the Python download page and choose from either the latest stable release or pre-release version. Download either the compressed gzipped tarball, or the xz tarball.

Step 4. Extract the downloaded file with tar command:

$ cd ~/Downloads $ tar -xf Python-*

Источник

Python on Kali Linux: A beginner’s guide to get started

install and use python on kali linux

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.

Читайте также:  Linux route add to interface

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.

Читайте также:  Java jdk linux ubuntu

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.

Источник

Оцените статью
Adblock
detector