Skip to content

Instantly share code, notes, and snippets.

View alirezaarzehgar's full-sized avatar
😃
Focusing

Ali alirezaarzehgar

😃
Focusing
View GitHub Profile
@alirezaarzehgar
alirezaarzehgar / showsigs.c
Created October 27, 2022 08:53
Example for signal, strsignal and pause functions (or syscalls).
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdbool.h>
#include <signal.h>
void sig_handler(int signo)
{
printf("Yo yo : %s\n", strsignal(signo));
@alirezaarzehgar
alirezaarzehgar / vulnerable.c
Last active October 29, 2022 12:26
Making security hole with using stdlib on signal handler
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdbool.h>
#include <signal.h>
#include <sys/time.h>
#include <pwd.h>
#include <err.h>
@alirezaarzehgar
alirezaarzehgar / poemd.c
Created November 6, 2022 07:22
A deamon for sending poem form poem.conf to clients based on KISS <3
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <syslog.h>
#include <setjmp.h>
#include <time.h>
#include <errno.h>
#include <err.h>
@alirezaarzehgar
alirezaarzehgar / capslock.cpp
Last active December 10, 2022 19:06
A very simple example for students ...
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
bool caps = false;
cin >> n;
@alirezaarzehgar
alirezaarzehgar / short_files.sh
Last active February 28, 2023 09:25
Sort source files with its lines.
#!/usr/bin/env bash
if [ "$1" ]; then
cd "$1" || exit
fi
exts="*.[ch]"
dirs=$(ls -d -- */ 2>/dev/null)
if [ "${dirs}" ]; then
for d in ${dirs}; do
count=0
@alirezaarzehgar
alirezaarzehgar / functions.fish
Last active January 25, 2023 12:08
My env utils
function big_lines
for arg in $argv
set i 1
for line in (cat $arg);
set cnt (echo $line | wc -c)
if test $cnt -gt 80;
printf "$i($cnt)\t$line\n"
end
set i (math $i + 1)
end
@alirezaarzehgar
alirezaarzehgar / learn-new-tec.md
Last active April 7, 2023 07:06
My interest links

Don't start from details

If you have some topics or tools to learn, You should learn them step by step and little by little. TODO:

  • List every term and tool that you need to learn
  • Just search and learn this terms (in less that 5 minutes)
  • Start reading overview of their documentions (in less that 20 minutes)
  • Playing with "Quick start" or "Getting started"
  • Run examples and do exercise
@alirezaarzehgar
alirezaarzehgar / complex-install.sh
Last active February 7, 2023 08:21
Embed binary in bash
#!/usr/bin/env bash
add_command() {
echo "
lstart=\$(awk '/^__'${1}'_PAYLOAD_BEGIN__/ { print NR + 1; exit 0; }' \$0)
lend=\$(awk '/^__'${1}'_PAYLOAD_END__/ { print NR + 1; exit 0; }' \$0)
cat \$0 | head -n +\${lend} | tail -n +\${lstart} > \${dir}/${1}
chmod +x \${dir}/${1}"
}
#!/usr/bin/env bash
INF=enp2s0
ip tuntap add dev virttap mode tap user $USER
brctl addbr virtbr
brctl addif virtbr ${INF}
brctl addif virtbr virttap
ip link set virtbr up
@alirezaarzehgar
alirezaarzehgar / streverse.asm
Created March 24, 2023 20:15
Assembly exercises
section .bss
strp resb 10
buf resb 1
section .text
global _start
_start:
mov rax, 0
mov rdi, 0