Skip to content

Instantly share code, notes, and snippets.

View alirezaarzehgar's full-sized avatar
😃
Focusing

Ali alirezaarzehgar

😃
Focusing
View GitHub Profile
@alirezaarzehgar
alirezaarzehgar / hello-entry-point.sh
Last active October 19, 2022 06:58
Example for using entrypoints on docker containers
#!/usr/bin/env bash
#set -x
[[ $(docker ps --all --filter=name=example-ps -q) ]] && exit
# create local files for coping on docker container
echo '#!/bin/sh
echo "Hello, Entrypoint"
@alirezaarzehgar
alirezaarzehgar / minimal-linux-live.sh
Last active October 1, 2025 08:43
Create Super Minimal Linux Live Distro!
#!/usr/bin/env bash
URL="https://www.busybox.net/downloads/binaries/1.31.0-defconfig-multiarch-musl/busybox-x86_64"
OS_NAME=AliOS.img
[ -d /tmp/root ] && rm /tmp/root/boot
# Install Busybox
mkdir -p /tmp/root/{bin,dev,etc,lib,mnt,proc,sbin,sys,tmp,var,boot/grub}
cd /tmp/root || exit
wget ${URL} --no-clobber -O bin/busybox
chmod +x bin/busybox
@alirezaarzehgar
alirezaarzehgar / install.sh
Last active May 25, 2024 07:11
Hello World OS
#!/usr/bin/env bash
nasm -f elf32 kernel.asm -o kasm.o
gcc -m32 -c kernel.c -o kc.o
ld -m elf_i386 -T link.ld -o kernel kasm.o kc.o
mkdir -p root/boot/grub
cp kernel root/boot
echo "multiboot /boot/kernel;boot" > root/boot/grub/grub.cfg
grub-mkrescue -o os.iso root
rm -rf root *.o
@alirezaarzehgar
alirezaarzehgar / gcc-cross-compiler.sh
Last active May 7, 2022 02:46
Download and install gcc for other targets and versions
#!/usr/bin/env bash
GCC="gcc-8.2.0"
BINUTILS="binutils-2.31.1"
GDB="gdb-9.1"
PREFIX=$(pwd)/cross
COMPILEFLAGS=--disable-multilib
mkdir $GCC-elf-objs
mkdir ${GDB}-build
@alirezaarzehgar
alirezaarzehgar / main.go
Last active October 19, 2022 06:58
Fahsha Saz. InsultingBot
// This source code used for sending many messages immediately on virtual networks
// you should create file with "fahsha.dic" name and code find all of them of corrent directory
// then read them and randomly select a line and type on selected entry and send it.
// for selecting entry and starting attack you should click and hold your mouse on a entry.
// where app says "Writing a message..." or "Type a message" etc
// then you should press ctrl+a keys on keyboard and attack will be started
//
// usage:
// wordlist format: fahsha.dic files on correct directory
// start attack: holding your mouse on entry and press ctrl+a
@alirezaarzehgar
alirezaarzehgar / shell.c
Created October 12, 2022 14:20
Simple educational shell
/**
* @file shell.c
* @author alirezaarzehgar (alirezaarzehgar82@gmail.com)
* @brief
* @version 0.1
* @date 2022-10-12
*
* @copyright Copyright (c) 2022
*
*/
@alirezaarzehgar
alirezaarzehgar / Makefile
Last active October 19, 2022 06:57
Dirty cli chatapp with C
CC = cc
DEBUG = -g -fsanitize=address -fno-omit-frame-pointer
SRC = $(wildcard *.c)
TARGETS = $(SRC:.c=)
all: $(TARGETS)
%: %.c
$(CC) $(DEBUG) $< -o $@
@alirezaarzehgar
alirezaarzehgar / Makefile
Created October 23, 2022 11:47
su command example for learning setuid & setgid in c
CC = cc
SRC = $(wildcard *.c)
OBJ = $(SRC:.c=.o)
TARGET = su
all: $(TARGET)
$(TARGET): $(OBJ)
$(CC) $(OBJ) -o $(TARGET)
@alirezaarzehgar
alirezaarzehgar / print_buffer_every_time.c
Created October 24, 2022 13:23
Funny bugs cause problem on understanding `fork()` syscall :)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
int main(int argc, char const *argv[])
{
printf("buffer:)) -> ");
/* Fix: `fflush(stdout);` */
@alirezaarzehgar
alirezaarzehgar / auth.c
Created October 27, 2022 08:29
Minimal example to use PAM
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <err.h>
#include <pwd.h>
#include <security/pam_appl.h>
int login_conv(int num_msg, const struct pam_message **msg,