Skip to content

Instantly share code, notes, and snippets.

View arsperger's full-sized avatar

Arsen Semenov arsperger

View GitHub Profile
Let suppose few things first
num = 55 Integer to perform bitwise operations (set, get, clear, toggle).
n = 4 0 based bit position to perform bitwise operations.
How to get a bit?
To get the nth bit of num right shift num, n times. Then perform bitwise AND & with 1.
bit = (num >> n) & 1;
How it works?
0011 0111 (55 in decimal)
@arsperger
arsperger / wireshark101_tcp_syn_without_synack.md
Created April 13, 2021 05:58
Wireshark tcp connection timeout (SYN/SYNACK)

Wireshark find SYN w/o SYNACK

  • set display filter 'tcp.flags eq 0x02' (only SYN flag set)
  • open Statistics -> Conversations
  • Select the option "Limit to display filter"
  • Select the tab TCP
  • Sort the output by "Packets".

Those connections with 1 packet are likely the "good" connections (one SYN only)

@arsperger
arsperger / troubleshoot_tls_sip_sngrep.md
Last active July 30, 2021 15:36
Troubleshoot TLS SIP sngrep

Troubleshoot TLS SIP traffic

HEP/EEP version 3 packets work only with sngrep 1.4.7 and above

cat <<EOF >> ~/.sngrep
set capture.device lo
set eep.listen on
set eep.listen.version 2
set eep.listen.address 127.0.0.1
@arsperger
arsperger / gdb_cheat_sheet.md
Created April 12, 2021 10:21
GDB commands simple guide

GDB commands by function - simple guide

Startup

% gdb  -help         	print startup help, show switches
% gdb object      	normal debug 
% gdb object core 	core debug (must specify core file)
%% gdb object pid  	attach to running process
% gdb  use file command to load object 
@arsperger
arsperger / tasks.json
Created August 15, 2020 14:27 — forked from mattmc3/tasks.json
VSCode tasks for running a Makefile
// Makefile
// ${workspaceRoot} the path of the folder opened in VS Code
// ${file} the current opened file
// ${fileBasename} the current opened file's basename
// ${fileDirname} the current opened file's dirname
// ${fileExtname} the current opened file's extension
// ${cwd} the task runner's current working directory on startup
{
"version": "0.1.0",
"command": "bash",
@arsperger
arsperger / vimdiff.md
Last active April 13, 2021 06:08 — forked from mattratleph/vimdiff.md
vimdiff cheat sheet

Vimdiff cheat sheet

git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@arsperger
arsperger / import-private-go-modules-from-gitlab-repositories
Created June 17, 2020 10:12
How to import private go module from private gitlab repo
## 1
# make git use SSH instead of HTTPS
git config --global url."git@gitlab.com:".insteadof="https://gitlab.com"
# or edit .gitconfig
[url "git@gitlab.com:"] insteadOf = https://gitlab.com
## 2
# in gitlab repo and create access tocken
@arsperger
arsperger / iptables.sh
Created June 10, 2020 18:07 — forked from thomasfr/iptables.sh
iptable rules to allow outgoing DNS lookups, outgoing icmp (ping) requests, outgoing connections to configured package servers, outgoing connections to all ips on port 22, all incoming connections to port 22, 80 and 443 and everything on localhost
#!/bin/bash
IPT="/sbin/iptables"
# Server IP
SERVER_IP="$(ip addr show eth0 | grep 'inet ' | cut -f2 | awk '{ print $2}')"
# Your DNS servers you use: cat /etc/resolv.conf
DNS_SERVER="8.8.4.4 8.8.8.8"
# Allow connections to this package servers
@arsperger
arsperger / cgr-tester-LCR.py
Created June 14, 2018 11:07
Python script for various test of CGRateS engine.
# jsonclient.py
# A simple JSONRPC client library, created to work with Go servers
# Written by Stephen Day
# Modified by Bruce Eckel to work with both Python 2 & 3
import json, socket, itertools, time
from datetime import datetime
class JSONClient(object):
def __init__(self, addr, codec=json):