Created
May 21, 2018 21:42
-
-
Save JburkeRSAC/fe2dccb97189f403f40972550c2c8802 to your computer and use it in GitHub Desktop.
jburke's HackMiami6 (2018) Conference Scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Examples: Wedding - 693848d56098a0ad16736bea7f24336c9b47a7f0a6f776659e8d01f00b46af76 | |
$GLOBALS['P2PKH_Count'] = 0; | |
$transaction_id = $argv[1]; | |
if($argv[0] == "bitcoinphp.php"){ | |
$url = "https://blockchain.info/tx/$transaction_id?show_adv=true&format=json"; | |
$result = file_get_contents($url); | |
$resultJSON = json_decode($result, true); | |
} | |
function hex2str($hex) { | |
#echo $hex."\n"; | |
$str2 = substr($hex, 4); | |
$hex = $str2; | |
unset($str2); | |
$str = ''; | |
for($i=0;$i<strlen($hex);$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); | |
return $str; | |
} | |
function stripAndDecode($hash){ | |
//uncomment below and comment out echo $code in fetchPotentialMSG to inspect hex | |
#echo "\t".$hash."\n"; | |
$fileOpcode = "76a914"; | |
$pos = strpos($hash, $fileOpcode); | |
if($pos === false){ | |
$str2 = substr($hash, 6); | |
$hash = $str2; | |
unset($str2); | |
$str3 = substr($hash, 0, -4); | |
$hash = hex2str($str3); | |
unset($str3); | |
return $hash; | |
}else{ | |
$GLOBALS['P2PKH_Count'] += 1; | |
if($GLOBALS['P2PKH_Count'] > 1){ | |
#echo "P2PKH, terminating... run decode.php instead\n"; | |
exit; | |
}else{ | |
#echo "Normal EOF Hit... terminating...\n"; | |
} | |
} | |
} | |
function fetchPotentialMSG($resultJSON){ | |
$outgoing_transaction = $resultJSON['out']; | |
foreach($outgoing_transaction AS $this_transaction){ | |
if($this_transaction['value'] == 0){ | |
$code = $this_transaction['script']; | |
#echo "\n".hex2str($code)."\n"; | |
}else{ | |
$code = $this_transaction['script']; | |
if(isset($code)){ | |
$code = stripAndDecode($code); | |
if(!(is_null($code))){ | |
#echo $code."\n"; | |
} | |
} | |
} | |
} | |
} | |
fetchPotentialMSG($resultJSON); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$transaction_id = $argv[1]; | |
$url = "https://blockchain.info/tx/$transaction_id?show_adv=true&format=json"; | |
$result = file_get_contents($url); | |
$resultJSON = json_decode($result, true); | |
function hex2str($hex){ | |
//uncomment below and comment out echo $code in fetchPotentialMSG to inspect hex | |
#echo "\t".$hex."\n\n"; | |
$str = ''; | |
for($i=0;$i<strlen($hex);$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); | |
return $str; | |
} | |
function fetchPotentialMSG($resultJSON){ | |
$outgoing_transaction = $resultJSON['out']; | |
foreach($outgoing_transaction AS $this_transaction){ | |
$code = $this_transaction['script']; | |
$str2 = substr($code, 6); | |
$code = $str2; | |
unset($str2); | |
$str3 = substr($code, 0, -4); | |
$code = hex2str($str3); | |
unset($str3); | |
echo $code; | |
} | |
} | |
fetchPotentialMSG($resultJSON); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment