Skip to content
RCE Write-up Beginner

Hacking And Getting Remote Access With Pip

The author published a malicious Python package on PyPI that, when installed with pip, executes a script giving the attacker a reverse shell on the victim's machine. An attacker could gain remote access to any user who installs the package.

Ansari Follow

Published on systemweakness.com

First before getting our hands dirty, lets see what is pip Most Python developers would obviously knows what is pip. For other developers, pip is the package installer for Python.

Ansari, on systemweakness.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely pip executes arbitrary code from packages during installation, and PyPI does not verify that the publisher is the legitimate owner of the linked source repository.

Impact

Anyone who installs the package could have their machine remotely controlled by the attacker.

What the attacker needed

Victim installs the malicious package

The fix

Users should verify the publisher and inspect the package's source repository before installing, and install packages in binary-only mode where possible.

How it was found

  1. Start a listener on a chosen port using netcat.
  2. Install the malicious package with pip.
  3. The listener receives a reverse shell from the victim machine.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

pip is the tool Python developers use to download and install code libraries from the internet. When you run pip install, that code runs on your computer with your permissions. The author uploaded a package that secretly opens a connection back to the attacker, giving them control of your machine.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.