killchain-compendium/Miscellaneous/Python3 Cheatsheet.md

31 lines
1.2 KiB
Markdown
Raw Normal View History

2022-11-14 21:34:36 +01:00
# Python3 Cheatsheet
## Strings
* Python3 Strings ... just follow [fuckpep8](https://github.com/zardus/fuckpy3) or read on further and die ~S~trying
| What? | Function |
|--------------------------|------------------------------------|
| String -> Bytes | encode() |
| String <- Bytes | decode() |
| ASCII -> Dec | ord() |
| ASCII <- Dec | chr() |
| HexString -> Bytes | binascii.unhexlify() |
| HexBytes <- Bytes | binascii.hexlify() |
| HexString -> Bytes | bytes.fromhex() |
| HexString <- Bytes | hex() |
| Base64 -> HexString | base64.b64encode(bytes.fromhex()) |
| Base64 <- Bytes | base64.b64decode() |
| Bytes -> Long | Crypto.Util.number.bytes_to_long() |
| Bytes <- Long | Crypto.Util.number.long_to_bytes() |
## Exculsionary OR
Either use ` ^ ` or for ByteStrings while you are already pwning do
```sh
from pwn import *
xor()
```