Skip to content

Instantly share code, notes, and snippets.

@optman
optman / nc
Created February 24, 2017 07:32
nc transfer file
server:
cat x.bin |nc -l 12345
client:
nc host 12345 |pv -rb >x.bin
$lsof -ni:10001
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
aggregato 14790 optman 12u IPv4 90413759 0t0 TCP 192.168.100.3:37582->119.188.72.131:10001 (ESTABLISHED)
aggregato 14790 optman 14u IPv4 90413760 0t0 TCP 192.168.100.3:44111->115.231.155.86:10001 (ESTABLISHED)
@optman
optman / tcpflow
Created February 24, 2017 07:09
tcpflow -i any
~$ mkdir tcpflow
~$ cd tcpflow/
~/tcpflow$ sudo tcpflow -i any
tcpflow: listening on any
^Ctcpflow: terminating
~/tcpflow$ ls
172.017.000.002.08080-192.168.100.003.58240 172.019.000.004.33697-172.019.000.003.04150
172.017.000.009.09200-172.017.000.010.49593 172.019.000.004.35546-172.019.000.003.04150
172.017.000.010.49593-172.017.000.009.09200 172.019.000.004.37704-172.019.000.003.04150
@optman
optman / ngrep
Created February 24, 2017 07:03
ngrep -i "google" -d any -q
$ sudo ngrep -i "google" -d any -q
interface: any
match: google
U 192.168.100.3:50107 -> 192.168.100.1:53
.............www.google.com.....
@optman
optman / vlc command line
Created February 4, 2017 10:50
start vlc with rc interface
"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" --extraintf rc --rc-host 0.0.0.0:999
@optman
optman / ws-client.cpp
Last active December 20, 2021 05:06
libevent websocket client test
#include <event2/bufferevent.h>
#include <event2/buffer.h>
#include <event2/event.h>
#include <event2/dns.h>
#include <arpa/inet.h>
#include <iostream>
using namespace std;
@optman
optman / libevent-https.cpp
Last active February 13, 2020 16:21
libevent https demo
#include <event2/bufferevent_ssl.h>
#include <event2/bufferevent.h>
#include <event2/buffer.h>
#include <event2/event.h>
#include <event2/dns.h>
#include <openssl/ssl.h>
#include <iostream>
using namespace std;
@optman
optman / xargs
Last active December 16, 2016 02:57
tail and grep the latest log files
ls *.log -t | head -n 1 | xargs tail -f |grep xxxx
Total DISK READ : 214.84 K/s | Total DISK WRITE : 337.08 K/s
Actual DISK READ: 214.84 K/s | Actual DISK WRITE: 848.27 K/s
PID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND
152 be/3 root 0.00 B/s 0.00 B/s 0.00 % 94.28 % [jbd2/sda1-8]
10138 be/4 root 214.84 K/s 0.00 B/s 0.00 % 1.57 % bf_server -rep=/bfp2p/cache -tcp=:9998
10359 be/4 root 0.00 B/s 337.08 K/s 0.00 % 0.12 % python3 /bfp2p/bin/rpc_server.py -nsqd_addr nsqd:4150
@optman
optman / conntrack -L
Created November 11, 2016 14:24
netstat-nat /proc/net/ip_conntrack /proc/net/pf_conntrack
$ sudo conntrack -L |head
conntrack v1.4.1 (conntrack-tools): 213 flow entries have been shown.
tcp 6 404458 ESTABLISHED src=172.18.0.8 dst=172.18.0.5 sport=46900 dport=50051 src=172.18.0.5 dst=172.18.0.8 sport=50051 dport=46900 [ASSURED] mark=0 use=1
udp 17 179 src=172.18.0.6 dst=115.54.184.202 sport=9909 dport=9909 src=115.54.184.202 dst=192.168.1.15 sport=9909 dport=9909 [ASSURED] mark=0 use=1
udp 17 179 src=172.18.0.6 dst=61.52.121.141 sport=9909 dport=9909 src=61.52.121.141 dst=192.168.1.15 sport=9909 dport=9909 [ASSURED] mark=0 use=1
udp 17 167 src=172.18.0.6 dst=27.42.189.212 sport=9909 dport=9909 src=27.42.189.212 dst=192.168.1.15 sport=9909 dport=9909 [ASSURED] mark=0 use=1
udp 17 120 src=172.18.0.6 dst=221.218.229.187 sport=9909 dport=13573 src=221.218.229.187 dst=192.168.1.15 sport=13573 dport=9909 [ASSURED] mark=0 use=1
...