src: https://www.stationx.net/nmap-cheat-sheet
| Switch | Example | Description |
SHELL=/bin/bash | |
# to see all colors, run | |
# bash -c 'for c in {0..255}; do tput setaf $c; tput setaf $c | cat -v; echo =$c; done' | |
# the first 15 entries are the 8-bit colors | |
# define standard colors | |
ifneq (,$(findstring xterm,${TERM})) | |
BLACK := $(shell tput -Txterm setaf 0) | |
RED := $(shell tput -Txterm setaf 1) |
src: https://www.stationx.net/nmap-cheat-sheet
| Switch | Example | Description |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# with help from https://gist.github.com/miketaylr/5969656 | |
import sys | |
try: | |
from LaunchServices import ( | |
LSSetDefaultHandlerForURLScheme, |
#!/bin/bash | |
# see also | |
# - Google's Shell Style Guide: https://google.github.io/styleguide/shell.xml | |
# - ShellCheck: https://github.com/koalaman/shellcheck | |
# src: | |
# - http://hackaday.com/2017/07/21/linux-fu-better-bash-scripting | |
# - https://dev.to/thiht/shell-scripts-matter |
#!/usr/bin/env python | |
# src: http://pandas.pydata.org/pandas-docs/stable/io.html#io-excel-reader | |
import pandas as pd | |
# get a dataframe from xlsx object | |
xlsx = pd.ExcelFile('path_to_file.xls') | |
df = pd.read_excel(xlsx, 'Sheet1') |
#!/usr/bin/env python | |
""" | |
How to programatically run a playbook | |
(adapted from http://docs.ansible.com/ansible/dev_guide/developing_api.html#python-api-2-0) | |
Note that example from URL above only supports a single play per run, while actual playbooks | |
contain a list of plays. A playbook cannot be read in and run, but read in, and each play | |
run one at at time, and evaulate the result of each play separately (see below) | |
Also note that this is not a general purpose playbook runner, but one specifically suited to |
# usage: source colored_text.sh | |
# c_red("hello") | |
export C_BLACK="\\033[0;30m" | |
export C_DK_GRAY="\\033[1;30m" | |
export C_RED="\\033[0;31m" | |
export C_LT_RED="\\033[1;31m" | |
export C_GREEN="\\033[0;32m" |
#!/bin/sh | |
# check if a upd port is open with netcat | |
nc -v -u -z -w 3 localhost 5000 | |
# send a test packet | |
# -n - Tells the echo command to not output the trailing newline. | |
# -4u Use IPV4 addresses only. Use UDP instead of TCP. | |
# -w1 Silently close the session after 1 second of idle time. That way, we’re not stuck waiting for more data. | |
echo -n “foo” | nc -4u -w1 <host> <udp port> |
#!/bin/bash | |
# show prompt without a newline | |
echo -n "Password:" | |
# Turn off echo | |
stty -echo | |
# Read what the user typed | |
read passwd |
#!/usr/bin/env python3 | |
""" | |
Documentation about this script or module | |
""" | |
import os | |
import sys | |
from datetime import datetime | |
import argparse |