Skip to content

Latest commit

 

History

History
executable file
·
419 lines (414 loc) · 24.1 KB

useful_python_modules.md

File metadata and controls

executable file
·
419 lines (414 loc) · 24.1 KB

Useful Python Modules

The document is to act as a cumulative list of all Python modules we have encountered and recommend all individuals at least know of. This list was originally written by John and written for Pat, but obviously it it considered open and readable/writable to everything.

  • urllib: interact with web applications, get and post to websites -- use requests instead, but use this to encode/decode URL encoding with the quote/unquote functions
  • requests: better module than urllib; use this to actually interact with webpages,
  • base64: encode and decode base64 data, b64encode() and b64decode()
  • binascii: convert ascii data to hex and hex data to ascii easily
  • socket: connect and automate network connections -- essentially netcat in [Python
  • pwntools: better library to connect to services, also has a LOT of exploitation functions
  • json: interact with JSON data, quickly create and load from strings and files with loads() and dumps()
  • os: get information from OS and filesystem; use to create, copy, move files and test for path directories, change directories, etc. Also used to call quick shell commands with system()
  • subprocess: used to actually call a remote process, like a shell command. You can control all standard input/output/error streams with it through Popen() or just quickly grab output of a command with check_output().
  • zipfile: create or extract from .zip files, can be used to try and crack passwords against an archive file
  • PIL: library for working with image files; interact with all pixels and colors and lots more; absolutely awesome for some steganography challenges.
  • scapy: save the world through network packet manipulation. lets you loop through every packet in a pcap file and do things with it, along with sniff and send packets of your own
  • BeautifulSoup: parse through HTML pages extremely easily
  • re: use regular expressions
  • sqlite3: interact with SQLite databases
  • string: library that holds the entire alphabet in uppercase and lowercase, along with all numbers and whitespace characters and printable characters etc.
  • Flask: used to create a web server with Python -- often used in CTF challenges (and we seriously saw it as the backend of one challenge at Cyberstakes LIVE last year) so it is good to know how it works or at least what it looks like
  • random: used to get a random number
  • sympy: symbolic calculation, like solving equations or derivatives or integrals
  • math: basic math functions, round a number up or down, absolute value, etc.
  • sys: get information from the system; most commonly used to get command-line arguments for your script through argv
  • struct: perform conversions between Python values and C structs; most commonly used with pack to convert a hex number memory address into an encoded string for an exploit
  • pexpect: not often used, but can be used to automate the interactions of a program
  • colorama: just used to print in color on the terminal; really nice for scripts and writing exploits
  • threading: used to create multiple threads; let your program multitask!
  • time: work with time: convert it, get dates, sleep for a certain duration, etc
  • sh: can call any external program as if it were a function
  • pyenchant: spell-checker and dictionary; can be used to test for English during a brute-force attack
  • pycrypto: cryptography library for Python; does practically everything you could ever need for crypto (but it also bewildering)
  • nltk: the Natural Language Toolkit has pretty much every word ever and can tokenize sentences and paragraphs well; not often used in exploitation, but good to know it exists
  • paramiko: used for automating SFTP or SSH connection in Python
  • gtk: to create a GUI; again not often seen in CTF challenges but a good module to know