Skip to content

Instantly share code, notes, and snippets.

@netrunn3r
netrunn3r / linux.md
Last active February 22, 2018 20:54

Simple things

Output to console string which goes to bc, and result from bc
echo "2+3" | tee /dev/tty | bc

Remove country specific characters and [^a-zA-Z0-9._] in filename for FILE in *.doc ; do mv "$FILE" "$( echo $FILE | iconv -f UTF-8 -t US-ASCII//TRANSLIT - | sed -r 's/[^a-z0-9._]+/_/ig' )" ; done

Split file to 'n' lines:
split -l <lines> <input> <prefix>

@netrunn3r
netrunn3r / qemu.md
Last active December 8, 2017 08:22
QEMU cheetsheet

Boot VM from iso with port redirection

qemu-system-x86_64 -enable-kvm -usbdevice tablet
-boot d -cdrom image.iso    # boot from iso
-m 512                      # 512MB RAM
-netdev user,id=net0,hostfwd=tcp::8080-:80 -device e1000,netdev=net0  # redirect host 8080 to guest 80

Create new disk

qemu-img create mydisk.img 10G

@netrunn3r
netrunn3r / awk.md
Last active December 3, 2017 01:53
AWK cheatsheet

To filter sth out, like 'grep -v'

{                                                                                         
    if (($0 !~ "fatal: Not a git") &&
        ($0 !~ "Nokogiri was built") &&
        ($0 !~ "No platform") &&
        ($0 !~ "No Arch") &&
        ($0 !~ "No encoder") &&
        ($0 !~ "succeeded with size") &&
 ($0 !~ /Found [0-9]* compatible encoders/) &amp;&amp;
@netrunn3r
netrunn3r / git.md
Last active November 17, 2017 12:36

https://www.sslshopper.com/article-most-common-openssl-commands.html

General OpenSSL Commands

These commands allow you to generate CSRs, Certificates, Private Keys and do other miscellaneous tasks.

  1. Generate a new private key and Certificate Signing Request
    openssl req -out CSR.csr -new -newkey rsa:2048 -nodes -keyout privateKey.key
  2. Generate a self-signed certificate (see How to Create and Install an Apache Self Signed Certificate for more info)
    openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privateKey.key -out certificate.crt
  3. Generate a certificate signing request (CSR) for an existing private key
    openssl req -out CSR.csr -key privateKey.key -new
@netrunn3r
netrunn3r / bash.md
Last active December 7, 2017 12:38
Bash cheatsheet

Arrays

distro=("redhat" "debian" "gentoo")
echo ${distro[0]} 
echo ${distro[2]}  # will print gentoo
echo ${#distro[@]} # print array size, here 3

tLen=${#distro[@]} 
for (( i=0; i<${tLen}; i++ ));
do
@netrunn3r
netrunn3r / security.md
Last active June 24, 2020 14:14
Security tools cheatsheet

HTTrack

httrack --near --display --extra-log --keep-alive --tolerant --can-go-up-and-down --check-type=2 --urlhack --timeout=60 --retries=9 -O ./intranet/ http://intranet

To use proxy, add -P 127.0.0.1:8080 .
When something go wired, delete output folder (eg. when httrack don't want to use proxy)

For proxy we can use burp:

  1. User option tab, set user
  2. proxy tab run proxy
@netrunn3r
netrunn3r / ssh.md
Last active December 11, 2017 07:25
SSH cheatsheet

Passwordless

  1. Generate key (if necessary): ssh-keygen -o -a 100 -t ed25519
  2. Add content of the PUBLIC key to ~/.ssh/authorized_keys file on the server
  3. Check that ~/.ssh has 700 and ~/.ssh/authorized_keys has 600 perm (on server)

Config file

Create ~/.ssh/config file:

VisualHostKey=yes 
@netrunn3r
netrunn3r / tmux.md
Last active December 1, 2017 09:31
tmux cheatsheet

Equally balance split panes

Vertically

select-layout even-vertical
Usually assigned to: C-b M-2

Horizontally

select-layout even-horizontal
Usually assigned to: C-b M-1

C-b means Control-b and M-2 means alt+2<\kbd>.

@netrunn3r
netrunn3r / network.md
Last active December 6, 2017 13:20
Network cheatsheet

Check external IP

curl ifconfig.me
curl icanhazip.com
curl ipecho.net/plain
curl ifconfig.co