Blog Spot!


Tcpdump usage examples

In most cases you will need root permission to be able to capture packets on an interface.

See the list of interfaces on which tcpdump can listen:

tcpdump -D

Listen on interface eth0:

tcpdump -i eth0

Listen on interface eth0, capture any packets where the destination port is 6020. Display IP addresses and port numbers:

tcpdump -i eth0 -n dst port 6020

Record the packet capture to a file called capture.cap:

tcpdump -w capture.cap

Record the packet capture to a file called capture.cap but display on-screen how many packets have been captured in real-time:

tcpdump -v -w capture.cap

Capture any packets where the source or destination host is 192.168.1.1. Display IP addresses and port numbers:

tcpdump -n host 192.168.1.1

Capture any packets where the destination port is 23. Display IP addresses and port numbers:

tcpdump -n dst port 23

Capture any packets with destination IP 192.168.1.1 and destination port 23. Display IP addresses and port numbers:

tcpdump -n "dst host 192.168.1.1 and dst port 23"

Capture only TCP packets where the destination port is is between 1 and 1023 inclusive. Display IP addresses and port numbers:

tcpdump -n tcp dst portrange 1-1023

tcpdump-article

Added on 28.Jun.2016
Tags: tcp tcpdump examples terminal linux

Disable mouse right click on a web page

document.oncontextmenu = document.body.oncontextmenu = function() {
    return false;
};

dont-disable-right-click (:

Added on 23.Jun.2016
Tags: js mouse clock disable

What is the best way to reduce the size of ibdata in mysql?

Step 01) MySQLDump all databases into a SQL text file (call it SQLData.sql) (More details here)

Step 02) Drop all databases (except mysql, performance_schema, and information_schema)

Step 03) Shutdown mysql

Step 04) Add the following lines to /etc/my.cnf

[mysqld]
innodb_file_per_table
innodb_flush_method=O_DIRECT
innodb_log_file_size=1G
innodb_buffer_pool_size=4G

Sidenote: Whatever your set for innodb_buffer_pool_size, make sure innodb_log_file_size is 25% of innodb_buffer_pool_size.

Step 05) Delete ibdata1, ib_logfile0 and ib_logfile1

At this point, there should only be the mysql schema in /var/lib/mysql

Step 06) Restart mysql

This will recreate ibdata1 at 10MB, ib_logfile0 and ib_logfile1 at 1G each

Step 07) Reload SQLData.sql into mysql

... full tutorial

Added on 23.Jun.2016
Tags: mysql sql optimize innodb

Encrypt and decrypt content with Nodejs

Encrypt and decrypt text:

// Part of https://github.com/chris-rock/node-crypto-examples
// Nodejs encryption with CTR

var crypto    = require('crypto'),
    algorithm = 'aes-256-ctr',
    password  = 'qwerty';

function encrypt(text){
    var cipher  = crypto.createCipher(algorithm,password);
    var crypted = cipher.update(text,'utf8','hex');
    crypted += cipher.final('hex');
    return crypted;
}

function decrypt(text){
    var decipher = crypto.createDecipher(algorithm,password);
    var dec      = decipher.update(text,'hex','utf8');
    dec += decipher.final('utf8');
    return dec;
}

var hw = encrypt("hello world");

console.log(hw);
console.log(decrypt(hw));

Encrypt and decrypt buffers

// Part of https://github.com/chris-rock/node-crypto-examples

var crypto    = require('crypto'),
    algorithm = 'aes-256-ctr',
    password  = 'd6F3Efeq';

function encrypt(buffer){
    var cipher  = crypto.createCipher(algorithm,password);
    var crypted = Buffer.concat([cipher.update(buffer),cipher.final()]);
    return crypted;
}

function decrypt(buffer){
    var decipher = crypto.createDecipher(algorithm,password);
    var dec      = Buffer.concat([decipher.update(buffer) , decipher.final()]);
    return dec;
}

var hw = encrypt(new Buffer("hello world", "utf8"));

console.log(hw);
console.log(decrypt(hw).toString('utf8'));

lollyrock

Added on 08.Jun.2016
Tags: js node encrypt decrypt aes

Lighttpd - Enable access log

Enable the accesslog module

sudo lighty-enable-mod accesslog

Reload the lighttpd daemon

sudo service lighttpd force-reload

Added on 01.Jun.2016
Tags: accesslog server lighttpd configs cfg

Search


PHP Libraries


Carbon lib / docs
Idiorm lib / docs
Image Workshop lib / docs
lorenzos/Minixed lib / docs
Parsedown lib / docs
PHP Paginator lib / docs
PHP Redis lib / docs
QrCode lib / docs
Requests lib / docs
Slim lib / docs
Spyc lib / docs
TWIG lib / docs
Upload lib / docs
Validation lib / docs
Zebra Image lib / docs

JS Libraries


AJV lib / docs
BackboneJS lib / docs
Bootstrap Notify lib / docs
C3.js lib / docs
ChartJS lib / docs
FastMD5 lib / docs
HighlightJS lib / docs
jQuery-Storage lib / docs
JS-Cookie lib / docs
Leaflet JS lib / docs
LowDB lib / docs
Marked lib / docs
NeedlyJS lib / docs
ParcelJS lib / docs
RequireJS lib / docs
Swig lib / docs
Toastr lib / docs
Underscore lib / docs
ValidateJS lib / docs
top