Skip to content

Instantly share code, notes, and snippets.

View nyrahul's full-sized avatar
🐞

Rahul Jadhav nyrahul

🐞
View GitHub Profile
@nyrahul
nyrahul / ssh-pushkey
Last active May 10, 2021 10:49
ssh password less login: Add my pub key to .ssh/authorized_keys
# Generate ssh keys
ssh-keygen -t rsa
# Add my pub key as an authorized key on the remote host rahul@vbox20
cat ~/.ssh/id_rsa.pub | ssh rahul@vbox20 'mkdir -p .ssh && cat >> .ssh/authorized_keys'
@nyrahul
nyrahul / dig-container.sh
Created January 13, 2021 19:18
Map the container syscall events using sysdig
#!/bin/bash
ignore_evts="futex switch clock_gettime io_getevents sched_getaffinity getrusage nanosleep rt_sigaction rt_sigprocmask ioctl sched_yield sigreturn times"
declare -A map
[[ "$1" == "" ]] && echo "Need container name as input" && exit 1
[[ $UID -ne 0 ]] && echo "Need to exec as root" && exit 1
[[ ! -x "$(which jq)" ]] && echo "Need jq command (try, apt install jq)" && exit 1
[[ ! -x "$(which sysdig)" ]] && echo "Need sysdig command (try, apt install sysdig)" && exit 1
@nyrahul
nyrahul / idspoof.py
Created December 31, 2020 11:51
Spoofing Cilium identity value in vxlan tunneled mode
#! /usr/bin/env python
# Aim of this script is to send a vxlan tunneled HTTP request with spoofed
# identity and pass through the authz checks implemented in cilium-ebpf.
# Configuration you need to set correct:
# 1. The target pod address (dip, dport) to which you want to make unauthorized access
# 2. The source identity (identity = 8849 below) to spoof. Use `cilium identity
# list` to check valid identity values.
# 3. The target node's vxlan IP address (vxlan_ip) and port (vxlan_port = 8472
@nyrahul
nyrahul / gitswitch.sh
Last active December 22, 2020 06:18
Switch all the remotes from https to git
#!/bin/bash
# Switch all the remotes from https to git
# e.g, https://github.com/username/reponame.git -> git@github.com:username/reponame.git
switch4remote()
{
url=`git remote get-url $1`
[[ ! $url =~ ^https ]] && echo "Remote [$1] might be on git already" && return 0
path=`echo $url | sed -Ene 's#https://github.com/(.*)#\1#p'`
❯ sudo perf stat -e 'syscalls:sys_enter_*' iperf -c localhost 2>&1 | awk '$1 != 0'
------------------------------------------------------------
Client connecting to localhost, TCP port 5001
TCP window size: 2.50 MByte (default)
------------------------------------------------------------
[ 3] local 127.0.0.1 port 41332 connected with 127.0.0.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 66.0 GBytes 56.7 Gbits/sec
Performance counter stats for 'iperf -c localhost':
@nyrahul
nyrahul / log_timestamp_perf.c
Created May 27, 2020 02:10
Measures impact of fancy timestamps in logging
/*
gtd format: ss:usec ... raw time of day format .. difficult to read ..
whitefield format: ss:ms .. eases timestamp reading cuz ms format used
cooja format: hh:mm:ss.ms ... most easiest to read
./a.out 7 // show sample test of all timestamps with print
./a.out 1 1 // perf-test gettimeofday only
./a.out 2 1 // perf-test whitefield style
./a.out 4 1 // perf-test cooja style
@nyrahul
nyrahul / disable touchpad on ubuntu
Created March 4, 2020 11:57
disable touchpad on ubuntu using gnome gsettings
gsettings set org.gnome.desktop.peripherals.touchpad send-events 'disabled'

Keybase proof

I hereby claim:

  • I am nyrahul on github.
  • I am rahuljadhav (https://keybase.io/rahuljadhav) on keybase.
  • I have a public key ASAMztGGPNImzJtw0dB_sZsMOL3zTEFoTt8wFfDwA1Stngo

To claim this, I am signing this object:

@nyrahul
nyrahul / stackup.sh
Created December 11, 2019 14:08
Stack up two videos side-by-side using ffmpeg
ffmpeg -i SVID_20191211_220354_1.mp4 -i SVID_20191211_220355_1.mp4 -filter_complex hstack out.mp4
# go to the kernel source folder
# Copy existing kernel's config
cp /boot/config-`uname -r` .config
make menuconfig #update config
make -j$(nproc) # This may take a long time.
sudo make modules_install
sudo make install