# python

# environments

The module used to create and manage virtual environments is called venv (opens new window).

# create

python3 -m venv env && source env/bin/activate    # creates a virtual env called env

deactivate  # run deactivate before deleting a virtua;l environment

# windows

python -m venv env
.\env\Scripts\activate

# pip

pip is the python package manager and install packages from https://pypi.org/ (opens new window) by default. pip3 is the python 3 version.

pip install requests
pip uninstall requests

python -m site  # view the global pip location

# requirements.txt

pip freeze  # list packages installed on machine or in virtual environment

pip freeze > requirements.txt   # create a requirements.txt using pip freeze

pip install -r requirements.txt   # install packages in requirements.txt

# http

# start a local webserver to serve files
python3 -m http.server

# wheels

A Python .whl file is essentially a ZIP (.zip) archive with a specially crafted filename that tells installers what Python versions and platforms the wheel will support.

A wheel is a type of built distribution. In this case, built means that the wheel comes in a ready-to-install format and allows you to skip the build stage required with source distributions. source (opens new window)

# bandit

Bandit - a Python source code security analyzer

bandit-config-generator -o config.yml # generate the bandit config file

bandit -c code/config.yml -r code/ -f json -o out.json  # run scan and output to son 

See here (opens new window) for more info.

# dll planting example

mkdir attacker_dir && cd attacker_dir
echo 'print("lol ur pwnt")' > pip.py
python -m pip install requests

See here (opens new window) for more info.