Pip is a package management system written in Python. It can download custom Python package so we can create a malicious package to execute arbitrary code.
To package the project, run the following command in the project root.
# If you don't have modules below, install them first.pip3installsetuptoolspip3installbuild# Buildpython3-mbuild
It generates .tar.gz file in dist folder.
2. Download the Package
We need to host the package using pypi-server.
# Install the module if you don't have itpip3installpypiserver# Copy the tar.gz file into the "package" folder.mkdirpackagecp./exploitpy/dist/exploitpy-0.0.1.tar.gz./packagepypi-serverrun-v-p8000./package
Then download the package by the following command.
If the pip command can be executed as root, we can also escalate privileges.
When downloading, arbitrary code, that we specified in setup.py, will be executed.