Page cover
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Python

00. Common

  • Externally Managed Fix

mkdir -p ~/.config/pip && printf "[global]\nbreak-system-packages = true\n" > ~/.config/pip/pip.conf
  • Virtual Environments

sudo pip install virtualenv

virtualenv -p python2 venv
virtualenv -p python venv
source venv/bin/activate
deactivate

python -m venv env
source env/bin/activate
  • Sandbox escape

## ------------------| input function
__import__('os').system('ping -c 2 <IP>')
  • Regular expressions

## ------------------| Basic serach
>>> import re
>>> s = 'Part 1. Part 2. Part 3 then more text'
>>> re.search(r'Part 1\.(.*?)Part 3', s).group(1)
' Part 2. '
>>> re.search(r'Part 1(.*?)Part 3', s).group(1)
'. Part 2. '

## ------------------| Search word in respond 
respond = (requests.get('http://IP/index.php').text).strip()
fetch = re.search("\[(.*?)\]",respond).group(1)
                    ^ <->  ^            ^
## fetch string start with '[' and end with ']' and show first block only

## ------------------| Search multiple lines in respond 
regex = re.compile(r"<h3>(.*)</h3>", re.DOTALL)
respond = requests.get('http://IP/index.php')
match = re.search(regex, respond.text)
print (match.group(1))
  • Slicing

  • Get user inputs

  • Read file line by line

  • Requests libs

  • Send HTTP requests with a randomly changing source IP address

  • Common

  • Loops

  • File operators

syntax
sample

open(file.txt, 'r')

To open a file for reading

open(file.txt, 'w')

To open a file for writing

open(file.txt, 'a')

To append to a file

open(file.txt, 'x')

To create a new file and raise an error if it already exists

01. Flask

  • Web Proxy using Flask

02. Blind SQL injection

03. LFI with python

04. XXE with python

05. SSL/HTTPS Server

  • Click here for get advance code.

06. Package Manager RCE

Last updated