Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢

Mohd Shahril shahril96

🐢
View GitHub Profile
@shahril96
shahril96 / float2ieee754.c
Last active Apr 18, 2022
Floating Point to IEEE 754 32-bit Converter
View float2ieee754.c
// Floating Point to IEEE 754 32-bit Converter
// this was written when i'm started to learn C
// code look suck, well, this shit is from 2 years ago :) (ahh unforgotten memories)
// hope you can learn somethings from this code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h> // to use bool (c99 standard)
@shahril96
shahril96 / pi.c
Created Jul 26, 2015
Implementation of Chudnovsky's algorithm to calculate approximation of Pi using C
View pi.c
#include <stdio.h>
#include <math.h>
#define SIZE 100
unsigned __int128 fact(int N) // calculate factorial with O(n)
{
static unsigned __int128 memo[SIZE] = {-1};
if(memo[N] > -1) return memo[N];
else return memo[N] = (N <= 1) ? 1 : fact(N-1) + fact(N-2);
@shahril96
shahril96 / format_string_got.c
Last active Nov 26, 2021
A demonstration on how to overwrite GOT (Global Offset Table) table entry using format string vulnerability.
View format_string_got.c
/*
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 Oct 22, 2021
Heavily commented simple GUI program made using Win32 API.
View winMain.cpp
#include <Windows.h>
// function prototype
LRESULT CALLBACK wndProcedure(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
// constant
LPCTSTR NAME = "My Window";
/**
*
@shahril96
shahril96 / postfix.java
Created Feb 19, 2016
Infix to Postfix - Java Converter (no invalid expressions checking)
View postfix.java
import java.util.*;
public class postfix {
public static void main(String args[]) {
String infix = "x-(y*a/b-(z+d*e)+c)/f";
System.out.println("Infix : " + infix);
System.out.println("Postfix : " + inf2postf(infix));
@shahril96
shahril96 / binary_heap.cpp
Last active Sep 26, 2021
Binary heap implementation using dynamic array (std::vector)
View binary_heap.cpp
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class heap {
private:
@shahril96
shahril96 / z3_prime.py
Last active Jun 25, 2021
Generating list of valid prime numbers using Z3 theorem prover
View z3_prime.py
'''
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 / uncompyle6-recursive.sh
Created May 30, 2019
Decompile all pyc files recursively under current directory
View uncompyle6-recursive.sh
find . -name "*.pyc" -execdir uncompyle6 -o . {} \;
@shahril96
shahril96 / fact128.c
Last active May 7, 2021
Factorial using __int128 integer
View fact128.c
#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 / conkyrc
Created Nov 28, 2014
My simple conkyrc file. :)
View conkyrc
#========================================================================
# 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):