Skip to content

Instantly share code, notes, and snippets.

View limkokhole's full-sized avatar
🌴
On vacation

林果皞 limkokhole

🌴
On vacation
View GitHub Profile
@limkokhole
limkokhole / compare.py
Created August 21, 2019 11:41 — forked from astanin/compare.py
Compare two aligned images of the same size
#!/usr/bin/env python
"""Compare two aligned images of the same size.
Usage: python compare.py first-image second-image
"""
import sys
from scipy.misc import imread
from scipy.linalg import norm
@limkokhole
limkokhole / connect.c
Created August 3, 2019 22:15 — forked from skreuzer/connect.c
Make socket connection using SOCKS4/5 and HTTP tunnel
/***********************************************************************
* connect.c -- Make socket connection using SOCKS4/5 and HTTP tunnel.
*
* Copyright (c) 2000-2004 Shun-ichi Goto
* Copyright (c) 2002, J. Grant (English Corrections)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.

Detecting similar and identical images using perseptual hashes

Couple of my hobbies are travelling and photography. I love to take pictures and experiment with photography. Usually after my trips, I just copy the photos to either my iPad or couple of my external hard disks. After 10 years, I have over 200K photos distributed across several disks and machines. I had to find a way to organize these photos and create a workflow for future maintenance. In this post I want to address one of the issues I had to solve: ** finding duplicate images **.

First, I needed to find out what exactly is a duplicate image. Analysing my photos, I found couple of interesting things:

  1. Identical images: There were multiple copies of the same photo in different directories with different names.
  2. Similar images: I usually bracket (exposure compensate or flash compensate) important pictures. So I have photos that visually appear to be the same, but may be a little darker/lighter based on e
@limkokhole
limkokhole / exec-notify.c
Created July 5, 2019 11:47 — forked from L-P/exec-notify.c
Watch process creation.
/* exec-notify, so you can watch your acrobat reader or vim executing "bash -c"
* commands ;-)
* Requires some 2.6.x Linux kernel with proc connector enabled.
*
* $ cc -Wall -ansi -pedantic -std=c99 exec-notify.c
*
* (C) 2007-2010 Sebastian Krahmer <krahmer@suse.de> original netlink handling
* stolen from an proc-connector example, copyright folows:
*/
/*
@limkokhole
limkokhole / curl-websocket.sh
Created July 3, 2019 11:00 — forked from htp/curl-websocket.sh
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@limkokhole
limkokhole / glob_match.cc
Created July 2, 2019 18:09 — forked from alco/glob_match.cc
A translation of Python's fnmatch function into C++
#include <string>
#include "regex.h"
/*
* Return a new string with all occurrences of 'from' replaced with 'to'
*/
std::string replace_all(const std::string &str, const char *from, const char *to)
{
std::string result(str);
@limkokhole
limkokhole / requires.py
Created June 21, 2019 21:05 — forked from bbengfort/requires.py
Wraps pip freeze -r requirements.txt to provide better comment handling.
#!/usr/bin/env python
# requires
# Creates a requirements.txt file using pip freeze.
#
# Author: Benjamin Bengfort <benjamin@bengfort.com>
# Created: Fri Jan 22 08:50:31 2016 -0500
#
# Copyright (C) 2016 Bengfort.com
# For license information, see LICENSE.txt
#
@limkokhole
limkokhole / bytes.py
Created June 20, 2019 18:04 — forked from leepro/bytes.py
Human readable bytes conversions
## {{{ http://code.activestate.com/recipes/578019/ (r15)
#!/usr/bin/env python
"""
Bytes-to-human / human-to-bytes converter.
Based on: http://goo.gl/kTQMs
Working with Python 2.x and 3.x.
Author: Giampaolo Rodola' <g.rodola [AT] gmail [DOT] com>
License: MIT
@limkokhole
limkokhole / gql.py
Created June 3, 2019 19:54 — forked from LiveOverflow/gql.py
Blind GQL injection and optimised binary search - A7 ~ Gee cue elle (misc) Google CTF 2017
import requests
import string
import random
import urllib
import time
import base64
from decimal import Decimal
# Blind GQL injection and optimised binary search - A7 ~ Gee cue elle (misc) Google CTF 2017
# https://www.youtube.com/watch?v=za_9hrq-ZuA
@limkokhole
limkokhole / doit.py
Created June 3, 2019 15:52 — forked from kokjo/doit.py
Solution to CRC problem from asis ctf 2017
from pwn import *
s = log.waitfor("Calculating CRC reverse lookup table")
reverse_crc = {crc.crc_32(p16(i)): p16(i) for i in range(2**16)}
s.success()
e = ELF("./crcme_8416479dcf3a74133080df4f454cd0f76ec9cc8d")
r = process("./crcme_8416479dcf3a74133080df4f454cd0f76ec9cc8d")
@MemLeak