Skip to content

Instantly share code, notes, and snippets.

View ninjatrench's full-sized avatar

Harsh Daftary ninjatrench

View GitHub Profile
@ninjatrench
ninjatrench / proof_of_work.py
Created February 8, 2021 21:40
Crypto - Proof of Work sample code in Python
from hashlib import sha1
import sys
def pow(challenge = "Bitcoin", numZeros = 2):
"""
Calculating the token that matches the proof of work.
Sample values by default: "Bitcoin" and 2 consecutive zeroes.
"""
@ninjatrench
ninjatrench / input_timeout.py
Created February 8, 2021 21:37
Python timeout user input
import signal
TIMEOUT = 2 # number of seconds your want for timeout
import sys
flag = 0
def interrupted(signum, frame):
"called when read times out"
#raise RuntimeError()
sys.exit(1)
@ninjatrench
ninjatrench / cloudflare_only.sh
Created January 25, 2018 17:29
Script (For Linux Servers) to Prevent Real IP address Leak Protected Behind CloudFlare
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "[-] This script must be run as root [-]"
exit 1
fi
echo "[+] Reseting Initiated [+]"
ufw disable
echo "[?] Current Status [?]"
ufw status numbered verbose
@ninjatrench
ninjatrench / compare.c
Created January 29, 2015 16:32
strlen vs sizeof
#include<stdio.h>
#include<string.h>
void main(){
const char str[] = "Heya Buddy";
printf("sizeof(%s): %zu\n", str ,sizeof(str));
printf("strlen(%s): %zu\n", str, strlen(str));