Skip to content

Instantly share code, notes, and snippets.

View natmchugh's full-sized avatar

Nathaniel McHugh natmchugh

View GitHub Profile
@natmchugh
natmchugh / cpc.sh
Last active July 19, 2016 11:08
My version of hash clashes shell script with some things fixed
#!/bin/bash
export BIRTHDAYSEARCH=../md5birthdaysearch
export HELPER=../md5diffpathhelper
export FORWARD=../md5diffpathforward
export BACKWARD=../md5diffpathbackward
export CONNECT=../md5diffpathconnect
export CPUS=8
export TTT=12
@natmchugh
natmchugh / MD5_no_padding.php
Last active February 28, 2025 05:19
MD5 algo with padding commented out this makes it suitable for use in length extension attacks as output can then be used as initial values for next block
<?php
//Pre-processing: adding a single 1 bit
// append "1" bit to message
// Notice: the input bytes are considered as bits strings,
// where the first bit is the most significant bit of the byte.[46]
//Pre-processing: padding with zeros
// append "0" bit until message length in bits ≡ 448 (mod 512)
function preProcess($message) {
// $message .= chr(128);
<?php
$hashes = [];
$count = 0;
while (true) {
$randBytes = openssl_random_pseudo_bytes(100);
++$count;
$hash = hash('md5', $randBytes);
$smallerHash = substr($hash, 0, 8);
if (isset($hashes[$smallerHash])) {

Keybase proof

I hereby claim:

  • I am natmchugh on github.
  • I am natmchugh (https://keybase.io/natmchugh) on keybase.
  • I have a public key whose fingerprint is 1807 554C EDC9 A540 CEBA B189 53CA 1AC2 5751 A4A8

To claim this, I am signing this object:

@natmchugh
natmchugh / md4.php
Created March 29, 2014 13:05
Pure PHP MD4 implementation
<?php
function preProcess($message) {
$message .= chr(128);
while (((strlen($message) + 8) % 64) !== 0) {
$message .= chr(0);
}
return $message;
}
@natmchugh
natmchugh / sha1.php
Last active August 10, 2018 15:08
Pure PHP implementation of SHA1from wikipedia pseudo code
<?php
/*
Note 1: All variables are unsigned 32 bits and wrap modulo 232 when calculating, except
ml the message length which is 64 bits, and
hh the message digest which is 160 bits.
Note 2: All constants in this pseudo code are in big endian.
Within each word, the most significant byte is stored in the leftmost byte position
*/
<?php
define('π', M_PI);
var_dump(π);
<?php
require (__DIR__.'/../vendor/autoload.php');
use Guzzle\Http\Client;
use Fishtrap\Guzzle\Plugin\OAuth2Plugin;
use Guzzle\Log\MessageFormatter;
<?php
function changeMessage($ip, $msg)
{
$fp = fsockopen($ip, 9100, $errno, $errstr, 5);
if (!$fp) {
echo "$errstr ($errno)";
} else {
$string = "\x1B%-12345X@PJL RDYMSG DISPLAY = \"".$msg."\"\r\n\x1B%-12345X\r\n";
fwrite($fp, $string);
@natmchugh
natmchugh / Response.php
Created February 1, 2013 12:41
for mark
/**
* getConfirmedDeliveryDate
*
* @return void
*/
public function getConfirmedDeliveryDate()
{
return $this->_confirmedDeliveryDate;
}