Skip to content

Instantly share code, notes, and snippets.

View leolovenet's full-sized avatar
🏡
Working from home

liu lei leolovenet

🏡
Working from home
View GitHub Profile

ELF Format Cheatsheet

Introduction

Executable and Linkable Format (ELF), is the default binary format on Linux-based systems.

ELF

Compilation

@leolovenet
leolovenet / revsu
Last active December 6, 2023 03:19
revsu
#!/system/bin/sh
# https://github.com/topjohnwu/Magisk/blob/master/native/src/core/su/su_daemon.cpp
# https://android.stackexchange.com/a/217104/400354
UID=$(grep com.termux /data/system/packages.list | awk '{print $2}')
############################################################################################################
# This command needs to be edited manually before use,
@leolovenet
leolovenet / fishshell luarocks path
Last active June 29, 2022 07:41
luarocks path command for fishshell
for i in (luarocks path | awk '{sub(/PATH=/, "PATH ", $2); print "set -gx "$2}'); eval $i; end
@leolovenet
leolovenet / settings.json
Last active May 5, 2022 02:50
Make vscode-lldb automatically support Rust std lib sourcemaps, add it directly to VSCode's settings.json, https://github.com/vadimcn/vscode-lldb/issues/204#issuecomment-1113981923
"lldb.launch.preRunCommands": [
"script lldb.debugger.HandleCommand('settings set target.source-map /rustc/{} \"{}/lib/rustlib/src/rust\"'.format(os.popen('rustc --version --verbose').read().split('commit-hash: ')[1].split('\\n')[0].strip(), os.popen('rustc --print sysroot').readline().strip()))"
]
#!/usr/local/bin/luajit
local interface = "Wi-Fi"
local action = arg[1]
assert(action == "add" or action == "del" or action == "get")
local cmd = ""
if action == "get" then
cmd = "/usr/bin/sudo /usr/sbin/networksetup -getadditionalroutes " .. interface
print(cmd)
@leolovenet
leolovenet / install_StrongSwan.sh
Created July 6, 2016 08:50
IPSEC VPN on Centos6 with StrongSwan for iOS9
#!/bin/bash
## Main reference https://raymii.org/s/tutorials/IPSEC_vpn_with_CentOS_7.html
yum -y install epel-release
yum -y install haveged strongswan
/etc/init.d/haveged start
chkconfig haveged on
cd /etc/strongswan || exit
cat > strongswan.conf <<'EOF'
((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|((:[0-9A-Fa-f]{1,4}){1,6})|:)|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0
@leolovenet
leolovenet / proxy.fish
Created March 13, 2021 11:40
Functions to enable or disable proxy-related variables in the fish shell
function __proxy_enable
set IP 127.0.0.1
set PORT 12345
set PROT socks5
set OPT -gx
if test (count $argv) -gt 0
for i in (seq 1 (count $argv))
set arg $argv[$i]
switch $arg
@leolovenet
leolovenet / Self-Documented Makefile
Last active November 27, 2020 04:26
Automatically have "make help" print the usage of your Makefile. from https://www.thapaliya.com/en/writings/well-documented-makefiles/
.DEFAULT_GOAL:=help
SHELL:=/bin/bash
##@ Dependencies
.PHONY: deps
deps: ## Check dependencies
$(info Checking and getting dependencies)
#add this function to your $HOME/.config/fish/config.fish
function man
set -x LESS_TERMCAP_mb (printf "\e[01;32m")
set -x LESS_TERMCAP_md (printf "\e[01;32m")
set -x LESS_TERMCAP_me (printf "\e[0m")
set -x LESS_TERMCAP_se (printf "\e[0m")
set -x LESS_TERMCAP_so (printf "\e[01;33m")
set -x LESS_TERMCAP_ue (printf "\e[0m")
set -x LESS_TERMCAP_us (printf "\e[1;4;31m")