src: https://www.stationx.net/nmap-cheat-sheet
| Switch | Example | Description |
import os, stat | |
st = os.stat(src_file_name) | |
mode = stat.S_IMODE(st.st_mode) | |
os.chmod(dest_file_name, mode) |
import os, sys | |
if os.geteuid() != 0: | |
print 'You must be root to run this script' | |
sys.exit(0) |
src: https://www.stationx.net/nmap-cheat-sheet
| Switch | Example | Description |
#!/usr/bin/env python | |
# src: https://www.electricmonk.nl/log/2017/08/06/understanding-pythons-logging-module/ | |
# check the logger and all its parents to cech the log level, name, | |
# and configured handlers | |
log_to_debug = logging.getLogger("myapp.ui.edit") | |
while log_to_debug is not None: | |
print("level: %s, name: %s, handlers: %s".format( |
--- | |
# example of how to search a path for a file and do something with that file | |
# In this example we find a command (echo), then use the pipe lookup to | |
# run echo | |
- hosts: localhost | |
connection: local | |
gather_facts: no |
# start netcat listening on dest host: | |
nc -l 1234 | pbcopy | |
# send string to dest host via netcat: | |
echo $STR | nc 192.168.0.123 1234 |
apt install -y libmysqlclient-dev
apt install -y libssl-dev
Host * | |
ServerAliveCountMax 3 | |
StrictHostKeyChecking no | |
UserKnownHostsFile /dev/null | |
LogLevel ERROR | |
ServerAliveInterval 60 | |
IdentityFile ~/.ssh/id_rsa | |
Host *.proxied.domain.com | |
ProxyCommand ssh proxyhost.domain.com nc %h %p |
import sys | |
if sys.stdout.isatty(): | |
print("Not redirected or piped") | |
else: | |
print("Redirected or piped somewhere") |
#!/usr/bin/env python | |
""" | |
Find the differences between two mysql databases. | |
""" | |
from __future__ import print_function | |
import os | |
import re | |
import sys |