Skip to content

Instantly share code, notes, and snippets.

@bom-d-van
bom-d-van / mmap.go
Created September 26, 2017 01:43
Faster File Reading In Go
// +build ignore
package main
import (
"fmt"
"os"
"runtime"
"syscall"
)

Using nc and protoc as protobuf client and server

Inspiration: Linux and Unix nc command

Example protobuf definition:

message Person {
  required string name = 1;
  required int32 id = 2;
@bom-d-van
bom-d-van / ddos.txt
Created February 12, 2017 11:46
Detecting and Mitigating DDOS Attacks
Detecting and Mitigating DDOS Attacks
#List all Finish (FIN) packets
machine1 : sudo /usr/sbin/tcpdump -Nnn -i any -s0 'tcp[13] & 1 != 0'
#List all SYN and SYN-ACK packets
machine1 : sudo /usr/sbin/tcpdump -Nnn -i any -s0 'tcp[13] & 2 != 0'
@bom-d-van
bom-d-van / rpm.md
Last active February 20, 2017 03:29
rpm local build usage
# deploy (example)
rpm -iv pkg-{version}-x86_64.rpm

# list current version
rpm -qi pkg

# uninstall
rpm -ev pkg
@bom-d-van
bom-d-van / nc-as-http-server.sh
Created November 1, 2016 08:57
NC/NetCat Tips
# osx
cat test.http | nc -l -p 8000
# linux
cat test.http | nc -l 8000
# centos fix
# http://serverfault.com/a/729768/71640
# Removes the old package
yum erase nc
@bom-d-van
bom-d-van / virtualbox-shared-folder-setup.sh
Created November 1, 2016 02:46
VirtualBox Shared Folder Setup
# set up shared folder
VBoxManage sharedfolder add "VM name" --name "sharename" --hostpath "/path"
# test mounting
mkdir ~/path
sudo mount -t vboxsf sharename ~/path
# error: /sbin/mount.vboxsf: mounting failed with the error: No such file or directory
sudo apt-get install dkms build-essential linux-headers-$(uname -r) virtualbox-guest-additions-iso
sudo reboot
@bom-d-van
bom-d-van / tmux-cheatsheet.markdown
Created October 30, 2016 04:04 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@bom-d-van
bom-d-van / mysql-tcpdump.sh
Last active December 31, 2023 10:59
tcpdump advanced filters
# https://www.percona.com/blog/2008/11/07/poor-mans-query-logging/
tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | perl -e '
while(<>) { chomp; next if /^[^ ]+[ ]*$/;
if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER)/i) {
if (defined $q) { print "$q\n"; }
$q=$_;
} else {
$_ =~ s/^[ \t]+//; $q.=" $_";
}
# osx
lsof -iTCP -sTCP:LISTEN
# linux: tuna please!
netstat -tunapl
nc -l 2000 -k -c 'xargs -n 2 echo'