diff --git a/cheat b/cheat index b4d00da..03f4dd8 100755 --- a/cheat +++ b/cheat @@ -151,7 +151,7 @@ class CheatSheets(object): new_sheet = os.path.join(DEFAULT_CHEAT_DIR, cheat) shutil.copy(sheet_path, new_sheet) subprocess.call(editor + [new_sheet]) - + # fail gracefully if the cheatsheet cannot be copied. This # can happen if DEFAULT_CHEAT_DIR does not exist except IOError: @@ -179,7 +179,7 @@ class CheatSheets(object): "Please retry usig sudo." % cheat) print >> sys.stderr, error_msg exit(1) - except OSError, errno: + except OSError as errno: print >> sys.stderr, ("Could not launch `%s` as your editor : %s" % (editor[0], errno.strerror)) exit(1) @@ -216,7 +216,7 @@ class CheatSheets(object): output += ''.join([" " + line + '\n' for line in block.split('\n')]) if output: - print output, + sys.stdout.write(output); # Custom action for argparse @@ -230,7 +230,7 @@ class ListDirectories(argparse.Action): class ListCheatsheets(argparse.Action): """List cheatsheets and exit""" def __call__(self, parser, namespace, values, option_string=None): - print sheets.list() + print(sheets.list()); parser.exit() diff --git a/cheatsheets/apt-get b/cheatsheets/apt-get index 3888613..c7bc7f3 100644 --- a/cheatsheets/apt-get +++ b/cheatsheets/apt-get @@ -14,3 +14,12 @@ apt-get update && apt-get dist-upgrade # To install a new package(s) apt-get install package(s) + +# Download a package without installing it. (The package will be downloaded in your current working dir) +apt-get download modsecurity-crs + +# Change Cache dir and archive dir (where .deb are stored). +apt-get -o Dir::Cache="/path/to/destination/dir/" -o Dir::Cache::archives="./" install ... + +# Show apt-get installed packages. +grep 'install ' /var/log/dpkg.log diff --git a/cheatsheets/dd b/cheatsheets/dd index c1db5f3..2db5aaa 100644 --- a/cheatsheets/dd +++ b/cheatsheets/dd @@ -2,3 +2,16 @@ # Note: At the first iteration, we read 512 Bytes. # Note: At the second iteration, we read 512 Bytes. dd if=/dev/urandom of=/tmp/test.txt count=512 bs=2 + +# Watch the progress of 'dd' +dd if=/dev/zero of=/dev/null bs=4KB &; export dd_pid=`pgrep '^dd'`; while [[ -d /proc/$dd_pid ]]; do kill -USR1 $dd_pid && sleep 1 && clear; done + +# Watch the progress of 'dd' with `pv` and `dialog` (apt-get install pv dialog) +(pv -n /dev/zero | dd of=/dev/null bs=128M conv=notrunc,noerror) 2>&1 | dialog --gauge "Running dd command (cloning), please wait..." 10 70 0 + +# Watch the progress of 'dd' with `pv` and `zenity` (apt-get install pv zenity) +(pv -n /dev/zero | dd of=/dev/null bs=128M conv=notrunc,noerror) 2>&1 | zenity --title 'Running dd command (cloning), please wait...' --progress + +# DD with "graphical" return +dcfldd if=/dev/zero of=/dev/null bs=500K + diff --git a/cheatsheets/nmap b/cheatsheets/nmap index afa46ef..81c54a8 100644 --- a/cheatsheets/nmap +++ b/cheatsheets/nmap @@ -8,7 +8,7 @@ nmap -iL [list.txt] nmap -6 [target] # OS detection: -nmap -O [target] +nmap -O --osscan_guess [target] # Save output to text file: nmap -oN [output.txt] [target] @@ -22,6 +22,9 @@ nmap -source-port [port] [target] # Do an aggressive scan: nmap -A [target] +# Speedup your scan: +nmap -T5 --min-parallelism=50 [target] + # Traceroute: nmap -traceroute [target] diff --git a/cheatsheets/pacman b/cheatsheets/pacman index 353f6c5..cb51fc6 100644 --- a/cheatsheets/pacman +++ b/cheatsheets/pacman @@ -32,12 +32,17 @@ pacman -Qdt # You can't directly install packages from the Arch User Database (AUR) with pacman. -# You need yaourt to perform that. But considering yaourt itself is in the AUR, here is how to -build a package from its tarball. -# First, get the .tar.gz archive and unpack it -wget -tar -xzf -cd -# Then build the package and install it +# You need yaourt to perform that. But considering yaourt itself is in the AUR, here is how to build a package from its tarball. +# Installing a package from AUR is a relatively simple process: +# - Retrieve the archive corresponding to your package from AUR website +# - Extract the archive (preferably in a folder for this purpose) +# - Run makepkg in the extracted directory. (makepkg-s allows you to install any dependencies automatically from deposits.) +# - Install the package created using pacman +# Assuming $pkgname contains the package name. +wget "https://aur.archlinux.org/packages/${pkgname::2}/$pkgname/$pkgname.tar.gz" +tar zxvf "$pkgname.tar.gz" +cd "$pkgname" +# Build the package makepkg -s -pacman -U +# Install +sudo pacman -U