Skip to content

Instantly share code, notes, and snippets.

View eramax's full-sized avatar
🎯
Focusing

Ahmed Morsi eramax

🎯
Focusing
View GitHub Profile
@eramax
eramax / Remove_telegram_groups.py
Created March 8, 2023 15:06
Remove telegram groups
# Remove telegram groups
# python3 -m pip install --upgrade telethon
from telethon import TelegramClient, sync
# get an Id from https://my.telegram.org/apps
api_id = 111111111111
api_hash = 'xxxxxxxxxxxxx'
# List all the group names you want to keep, the script will delete other groups.
excluded_groups = ['gp1','gp2']
class TelegramAPIs(object):
@eramax
eramax / elf64.c
Created March 18, 2023 21:51
elf64
#include <stdint.h>
#include <stdio.h>
#include <sys/mman.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
@eramax
eramax / assembly_disassembly_x86_64.sh
Last active April 12, 2023 07:22
assembly and disassembly x86 64 instructions
n() { ndisasm -b64 tmp.bin; xxd -g1 tmp.bin; xxd -b tmp.bin; rm tmp.bin; }
a() { { echo "bits 64"; echo "$@"; } > tmp.s; nasm -f bin -D ARCH_x86_64 -o tmp.bin tmp.s; n; }
h() { printf '%s' "$@" | xxd -r -p > tmp.bin; n; }
b() { binary_value=$(echo "$@" | tr -d '[:space:]\n'); hex_value=$(printf '%0*X' $(((${#binary_value}+3)/4)) "$((2#$binary_value))"); h "$hex_value"; }
hx() { h "${@//[[:space:]]/}" ; }
# nasm_build() {
# ndisasm -b 64 tmp.bin
# xxd -g1 tmp.bin
@eramax
eramax / coder.Dockerfile
Created September 10, 2023 10:15
coder.Dockerfile
FROM ubuntu as base
LABEL maintainer="Ahmed Morsi"
ENV TZ Europe/Stockholm
ENV DEBIAN_FRONTEND noninteractive
# apps
RUN apt-get update && apt-get install -y curl tzdata nano htop cargo nodejs npm yarn build-essential git cmake locales zsh btop sudo iputils-ping wget tree jq python3 python3-pip
RUN apt-get -y autoremove
RUN apt-get -y clean
@eramax
eramax / gist:fd0950a5f54a28058f8318340242e895
Created October 14, 2023 00:29 — forked from chrisdone/gist:02e165a0004be33734ac2334f215380e
Build and run minimal Linux / Busybox systems in Qemu

Common

export OPT=/opt
export BUILDS=/some/where/mini_linux
mkdir -p $BUILDS

Linux kernel

@eramax
eramax / compile_kernel.sh
Created October 21, 2023 14:40 — forked from hangst/compile_kernel.sh
Compile mainline Linux kernel and boot on Amlogic Meson S905 through USB
# linux-meson.com/doku.php#howto
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image dtbs
mkimage -A arm64 -O linux -T kernel -C none -a 0x1080000 -e 0x1080000 -n linux-next -d arch/arm64/boot/Image ../uImage
cp arch/arm64/boot/dts/amlogic/meson-gxbb-wetek-play2.dtb ../uImage BOOT_PARTITION
# ROOTFS_PARTITION can be any arm64 Linux root filesystem
@eramax
eramax / arm64-on-Win10.md
Created October 22, 2023 16:36 — forked from billti/arm64-on-Win10.md
ARM64 Linux on Win10

Below are the steps to get an ARM64 version of Ubuntu running in the QEMU emulator on Windows 10.

Install QEMU

Install for Windows from https://qemu.weilnetz.de/w64/ (I used qemu-w64-setup-20181211.exe)

Put C:\Program Files\qemu on your PATH, and run the below to check it's working (which will list out the CPUs the AArch64 emulator can emulate):

qemu-system-aarch64 -M virt -cpu help
@eramax
eramax / UB18-Qemu-AARCH64.md
Created October 25, 2023 11:23 — forked from itzurabhi/UB18-Qemu-AARCH64.md
Run Ubuntu 18.04 on Qemu AARCH64 / ARM64

Install the dependecies

sudo apt install qemu-system-arm qemu-system-mips qemu-efi-aarch64 qemu-kvm qemu-efi cloud-image-utils

Prepare the EFI partition

dd if=/dev/zero of=flash0.img bs=1M count=64
dd if=/usr/share/qemu-efi/QEMU_EFI.fd of=flash0.img conv=notrunc
@eramax
eramax / extract_dtb_dts_firmware.sh
Last active October 27, 2023 15:52
Extract_dtb_dts_firmware.sh
#!/bin/bash
inp="$1" # Get the input file from the command line argument
# Check if the input file exists
if [ ! -f "$inp" ]; then
echo "File not found: $inp"
exit 1
fi
@eramax
eramax / aml-upgrade-package-extract.c
Created October 31, 2023 07:14 — forked from denji/aml-upgrade-package-extract.c
Utility to extract AMLogic "USB Burning Tool" .IMG firmware for Linux
// gcc aml-upgrade-package-extract.c -o aml-upgrade-package-extract
// ./aml-upgrade-package-extract update-usb-burning-mode.img
// /dev/sdX - fat32 sdcard
// Make bootable Android update:
// dd if=aml_sdc_burn.UBOOT bs=1 count=442 of=/dev/sdX
// dd if=aml_sdc_burn.UBOOT seek=1 skip=1 bs=512 of=/dev/sdX
// sync