Skip to content

Instantly share code, notes, and snippets.

View paranlee's full-sized avatar
🐧
Run RISC-V run!

Paran Lee paranlee

🐧
Run RISC-V run!
View GitHub Profile
@paranlee
paranlee / traceroute.py
Created June 26, 2024 09:09 — forked from aalmiramolla/traceroute.py
Python implementation of traceroute
# references:
# Learning by doing: Writing your own traceroute in 8 easy steps (Ksplice Blog)
# https://blogs.oracle.com/ksplice/entry/learning_by_doing_writing_your
# Edited by: Alejandro Almira <laboral at alejandroalmira.com>
import datetime
import socket
import sys
@paranlee
paranlee / encrypt_openssl.md
Created June 20, 2024 10:15 — forked from dreikanter/encrypt_openssl.md
File encryption using OpenSSL

Symmetic encryption

For symmetic encryption, you can use the following:

To encrypt:

openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt

To decrypt:

@paranlee
paranlee / Linux 内核及内核模块开发环境搭建
Created December 29, 2023 12:07 — forked from Civitasv/Linux 内核及内核模块开发环境搭建
Build and run minimal Linux / Busybox systems in Qemu
## Common
````
export OPT=/opt
export BUILDS=/some/where/mini_linux
mkdir -p $BUILDS
````
## Linux kernel
@paranlee
paranlee / elf_format_cheatsheet.md
Created December 16, 2023 04:34 — forked from x0nu11byt3/elf_format_cheatsheet.md
ELF Format Cheatsheet

ELF Format Cheatsheet

Introduction

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

ELF

Compilation

@paranlee
paranlee / socket.c
Created May 15, 2023 12:58 — forked from nolim1t/socket.c
HTTP Request in C using low level write to socket functionality
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
@paranlee
paranlee / http-server.c
Last active May 15, 2023 14:01 — forked from keiya/http-server.c
`gcc http.c -lcurl -o http.o` `sudo apt install libcurl4-openssl-dev -y` [ a simple http server ]feature: directory listing, high-throughput mmap io
#include <stdio.h> /* fprintf() */
#include <stdlib.h> /* exit() */
#include <sys/types.h> /* socket(), wait4() */
#include <sys/socket.h> /* socket() */
#include <netinet/in.h> /* struct sockaddr_in */
#include <sys/resource.h> /* wait4() */
#include <sys/wait.h> /* wait4() */
#include <pthread.h> /* pthread_create */
#include <netdb.h> /* getnameinfo() */
#include <string.h> /* strlen() */
@paranlee
paranlee / shell.c
Created April 23, 2023 17:03 — forked from parse/shell.c
Simple shell in C
/* Compile with: g++ -Wall –Werror -o shell shell.c */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
@paranlee
paranlee / scrape-images.py
Created April 21, 2023 14:09 — forked from firxworx/scrape-images.py
Web scraping with python: download all files linked to from a given web page with BeautifulSoup, urllib, and shutil
import urllib
import shutil
import re
from pathlib import Path
from bs4 import BeautifulSoup
# target page containing links to the image files
target_page = 'http://example.ca/image_links.php'
# local path
@paranlee
paranlee / DumpHex.c
Created December 13, 2022 11:23 — forked from ccbrown/DumpHex.c
Compact C Hex Dump Function w/ASCII
#include <stdio.h>
void DumpHex(const void* data, size_t size) {
char ascii[17];
size_t i, j;
ascii[16] = '\0';
for (i = 0; i < size; ++i) {
printf("%02X ", ((unsigned char*)data)[i]);
if (((unsigned char*)data)[i] >= ' ' && ((unsigned char*)data)[i] <= '~') {
ascii[i % 16] = ((unsigned char*)data)[i];
@paranlee
paranlee / mallocng.md
Created December 12, 2022 12:40 — forked from MaskRay/mallocng.md
musl mallocng

Introduced in musl v1.2.1. Design goal: "Strong hardening against memory usage errors by the caller, including detection of overflows, double-free, and use-after-free, and does not admit corruption of allocator state via these errors."

context

// Singleton: ctx
struct malloc_context {
  uint64_t secret;
#ifndef PAGESIZE
  size_t pagesize;