Skip to content

Instantly share code, notes, and snippets.

@dcui
dcui / port-forwarding.py
Created February 28, 2023 20:52 — forked from WangYihang/port-forwarding.py
port forwarding via python socket
#!/usr/bin/env python3
# Tcp Port Forwarding (Reverse Proxy)
# Author : WangYihang <wangyihanger@gmail.com>
'''
+-----------------------------+ +---------------------------------------------+ +--------------------------------+
| My Laptop (Alice) | | Intermediary Server (Bob) | | Internal Server (Carol) |
+-----------------------------+ +----------------------+----------------------+ +--------------------------------+
| $ ssh -p 1022 carol@1.2.3.4 |<------->| IF 1: 1.2.3.4 | IF 2: 192.168.1.1 |<------->| IF 1: 192.168.1.2 |
| carol@1.2.3.4's password: | +----------------------+----------------------+ +--------------------------------+
@dcui
dcui / how-to-install-latest-gcc-on-ubuntu-lts.txt
Created September 1, 2021 00:12 — forked from application2000/how-to-install-latest-gcc-on-ubuntu-lts.txt
How to install latest gcc on Ubuntu LTS (12.04, 14.04, 16.04)
These commands are based on a askubuntu answer http://askubuntu.com/a/581497
To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below.
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING.
ABSOLUTELY NO WARRANTY.
If you are still reading let's carry on with the code.
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
@dcui
dcui / latency.txt
Created May 24, 2021 18:55 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@dcui
dcui / centos-install-kernel-debuginfo.sh
Created August 3, 2020 18:55 — forked from jarek-przygodzki/centos-install-kernel-debuginfo.sh
CentOS 7 - How to install kernel-debuginfo
yum --enablerepo=base-debuginfo install -y kernel-debuginfo-$(uname -r)
/*
* IP checksumming functions.
* (c) 2008 Gerd Hoffmann <kraxel@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; under version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@dcui
dcui / packet-generator.cpp
Created July 11, 2020 19:11 — forked from jonhoo/packet-generator.cpp
Complete example code showing how to construct a UDP packet from scratch and inject it on a WiFi interface in Linux
/**
* Hello, and welcome to this brief, but hopefully complete, example file for
* wireless packet injection using pcap.
*
* Although there are various resources for this spread on the web, it is hard
* to find a single, cohesive piece that shows how everything fits together.
* This file aims to give such an example, constructing a fully valid UDP packet
* all the way from the 802.11 PHY header (through radiotap) to the data part of
* the packet and then injecting it on a wireless interface
*
@dcui
dcui / source.list
Created May 8, 2020 22:53 — forked from malikalichsan/sources.list
/etc/apt/source.list for ubuntu 19.10
# deb cdrom:[Ubuntu 19.10 _Eoan Ermine_ - Release amd64 (20191017)]/ eoan main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://id.archive.ubuntu.com/ubuntu/ eoan main restricted
# deb-src http://id.archive.ubuntu.com/ubuntu/ eoan main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://id.archive.ubuntu.com/ubuntu/ eoan-updates main restricted
@dcui
dcui / toeplitz_based_hash.py
Created May 9, 2019 17:37 — forked from joongh/toeplitz_based_hash.py
Python implementation of Toeplitz-based hash function. It is implemented to understand how the Toeplitz-based hash function works.
#!/usr/bin/env python
#-*- coding: utf-8 -*-
# Test data including the secret key, ip, port numbers and the hash values
# as the result is from "Intel Ethernet Controller 710 Series Datasheet".
KEY=[]
def reset_key():
global KEY
@dcui
dcui / memory_layout.md
Created May 10, 2017 12:11 — forked from CMCDragonkai/memory_layout.md
Linux: Understanding the Memory Layout of Linux Executables

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
@dcui
dcui / sendRawEth.c
Created May 20, 2016 10:06 — forked from austinmarton/sendRawEth.c
Send a raw Ethernet frame in Linux
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>