Skip to content

Instantly share code, notes, and snippets.

View am009's full-sized avatar

am009 am009

  • Huazhong University of Science and Technology
  • Wuhan, China
  • 09:59 (UTC +08:00)
View GitHub Profile
@am009
am009 / forward_exec.py
Last active September 13, 2025 12:12
็ซฏๅฃ่ฝฌๅ‘๏ผŒ้•ฟๆ—ถ้—ดๆฒกๆœ‰ๆดปๅŠจไผš่ถ…ๆ—ถ๏ผŒๅœๆญข็›ฎๆ ‡่ฟ›็จ‹ใ€‚ๅฐ่ฃ…ๅคงๆจกๅž‹APIๅฏไปฅ่Š‚็บฆๆ˜พๅญ˜็š„ๅŒๆ—ถ้šๆ—ถไฝฟ็”จใ€‚
#!/usr/bin/env python
import socket
import threading
import select
import sys
import time
import subprocess
import os
from datetime import datetime
@am009
am009 / benchmark-prepare.sh
Last active August 21, 2025 09:26
Prepare a Linux desktop PC for CPU sensitive benchmarking.
#!/bin/bash
set -e
# https://llvm.org/docs/Benchmarking.html
# https://smalldatum.blogspot.com/2024/10/managing-cpu-frequency-for-amd-on.html
# sudo apt install linux-tools-common linux-tools-generic linux-cloud-tools-generic cpuset
# disable hyper threading
for i in $(seq 16 31); do
echo 0 | sudo tee /sys/devices/system/cpu/cpu$i/online
@am009
am009 / wait-docker.sh
Created August 11, 2025 02:56
Wait till all docker containers are stopped.
#!/bin/bash
set -e
# ๆฏ3ๅˆ†้’Ÿๅพช็Žฏๆฃ€ๆต‹
while true; do
running_containers=$(docker ps -q) # ่Žทๅ–ๆ‰€ๆœ‰ๆญฃๅœจ่ฟ่กŒ็š„ๅฎนๅ™จID
if [ -z "$running_containers" ]; then
echo "ๆฒกๆœ‰ๆญฃๅœจ่ฟ่กŒ็š„ๅฎนๅ™จ๏ผŒ่ทณๅ‡บๅพช็Žฏ"
@am009
am009 / dpull.sh
Last active May 16, 2025 13:06
docker pull using proxy. (Use skopeo)
#!/bin/bash
export HTTP_PROXY=http://10.12.190.56:8010
export HTTPS_PROXY=http://10.12.190.56:8010
if [ $# -ne 1 ]; then
echo "็”จๆณ•: $0 <image_name[:tag]>"
exit 1
fi
@am009
am009 / convertDict.py
Last active April 4, 2025 02:43
Convert exported honggfuzz feedback dict to AFL++ dict format
import struct
import sys
def parse_hex_data(file_path):
entries = []
try:
with open(file_path, 'rb') as f:
data = f.read()
if len(data) < 4:
@am009
am009 / createAliases.sh
Created January 7, 2025 07:37 — forked from tokatoka/createAliases.sh
This scripts creates symlinks for llvm/clang tools so that their version number is removed from executables.
#!/bin/bash
# creates a symbolic link from bin-x.x to bin
# This just strips off last 3 characters when creating a link
LLVMFILES=/usr/bin/llvm*
CLANGFILES=/usr/bin/clang*
LLC=/usr/bin/llc-17
OPT=/usr/bin/opt-17
LLD=/usr/bin/lld-17
@am009
am009 / sendemail.py
Last active October 3, 2024 12:58
Rewrite sendemail (https://github.com/zehm/sendEmail) using python. the sendemail package in ubuntu is unable to connect many ssl smtp server.
#!/usr/bin/env python3
import argparse
import smtplib
import sys
from email.header import Header
from email.mime.text import MIMEText
from email.utils import parseaddr, formataddr
def send_email(from_addr, to_addr, subject, message, smtp_server, smtp_port, username, password, use_ssl):
"""
@am009
am009 / frpc.service
Last active October 13, 2024 13:22
Systemd service template that always restart when fails. Set StartLimitIntervalSec=0 to disable any rate limit. Add RestartSec=5 to restart after 5s if failure instead of 100ms (default value).
# /etc/systemd/system/frpc.service
[Unit]
# ๆœๅŠกๅ็งฐ๏ผŒๅฏ่‡ชๅฎšไน‰
Description = frp client
After = network.target syslog.target
Wants = network.target
StartLimitIntervalSec=0
[Service]
Type = simple
@am009
am009 / wrap-https.sh
Last active May 16, 2025 17:25
Wrap a http port to an https port. Simple reverse proxy and will change Host header. Simple bash script. Using https://github.com/go-gost/gost.
#!/bin/bash
cd /tmp
# argument 1 local url
# argument 2 port
if [ -z "$1" ]; then
echo "Please give the script first argument: IP:port to the http site. Do not add http:// prefix. For example: ./wrap-https.sh 127.0.0.1:7865 5002"
exit -1
fi
@am009
am009 / queue_log.py
Created May 28, 2023 15:20
multiprocessing download, log to one file.
from multiprocessing import Pool, Manager
import os
import subprocess
import pickle
import signal
def big_query_info_analysis(arg):
res_list, result_queue = arg
for res in res_list:
key, value = do_something()