Skip to content

Instantly share code, notes, and snippets.

View shahril96's full-sized avatar
🐢

Mohd Shahril shahril96

🐢
View GitHub Profile
@shahril96
shahril96 / fact128.c
Last active October 18, 2022 18:41
Factorial using __int128 integer
#include <stdio.h>
typedef unsigned __int128 uint128;
/* printing 128-bit value isn't official support yet
so here's implementation of converting 128-bit value into string */
char *str_uint128(uint128 n)
{
/* got confused about arithmetic operation with '0'? read more about ascii :) */
static char buf[1000] = {0}, *buft = buf;
@shahril96
shahril96 / format_string_got.c
Last active November 26, 2021 03:17
A demonstration on how to overwrite GOT (Global Offset Table) table entry using format string vulnerability.
/*
DISABLE ASLR & NX THROUGH COMPILATION:
$ echo 0 | sudo tee /proc/sys/kernel/randomize_va_space # disable ASLR
$ gcc -fno-stack-protector -z execstack -o format_string format_string.c -g # compile with NX (DEP protection) disabled
#############
# CODE POC
#############
@shahril96
shahril96 / winMain.cpp
Last active October 22, 2021 17:50
Heavily commented simple GUI program made using Win32 API.
#include <Windows.h>
// function prototype
LRESULT CALLBACK wndProcedure(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
// constant
LPCTSTR NAME = "My Window";
/**
*
@shahril96
shahril96 / binary_heap.cpp
Last active September 26, 2021 08:23
Binary heap implementation using dynamic array (std::vector)
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class heap {
private:
@shahril96
shahril96 / z3_prime.py
Last active June 25, 2021 00:16
Generating list of valid prime numbers using Z3 theorem prover
'''
Using Z3 to check if the number is prime
Original reference: https://stackoverflow.com/a/35653749/1768052
'''
from z3 import *
def isPrime(x):
y, z = Ints("y z")
@shahril96
shahril96 / conkyrc
Created November 28, 2014 18:11
My simple conkyrc file. :)
#========================================================================
# Conky-Serdar
#----------------------------------------------------------------------
#sudo apt-get install conky
#extract the zip file and move files to .conky in your home folder
#----------------------------------------------------------------------
#Run(Terminal):
# conky -c ~/.conky/conkyrc
#----------------------------------------------------------------------
#Autostart(Openbox):
@shahril96
shahril96 / srtf.cpp
Last active December 5, 2020 04:33
Naive implementation of SRTF algorithm (Short Remaining TIme First) using C++
#include <iostream>
using namespace std;
int SIZE_STRUCT;
int choose_process(struct process Process[], int running[], int size_running);
int get_total_burst_time(struct process Process[]);
int check_if_exist(int running[], int size_running, int check);
void add_running_process(struct process Process[], int running[], int &size_running, int i);
@shahril96
shahril96 / garden_puzzle_z3.py
Created May 28, 2017 23:41
Using Z3 Theorem Solver to solve for Gardens Puzzle
import sys
import itertools
from z3 import *
#
# Original puzzle
#
'''
Five friends have their gardens next to one another, where they grow three kinds of crops:
@shahril96
shahril96 / bokep-exploit.py
Created December 21, 2019 03:52
Build exploit for wargames.my 2019's bokep (from nafiez)
import struct
buf = b'A' * 132
#
# virtualProtect() for rwx (msvcr71.dll – v7.10.3052.4)
# url: https://www.corelan.be/index.php/security/corelan-ropdb/#msvcr71dll_v71030524
#
rop_gadgets = [
from z3 import *
import struct
a = [BitVec("a{}".format(i), 8) for i in range(5)]
s = Solver()
def is_valid(x):
return Or(
And(x >= ord('1'), x <= ord('9')),
And(x >= ord('a'), x <= ord('z')),