Skip to content

Instantly share code, notes, and snippets.

View ssigwart's full-sized avatar

Stephen Sigwart ssigwart

View GitHub Profile
@ssigwart
ssigwart / phpDeceivingExceptionPossiblyBug.php
Last active January 28, 2021 14:29
Deceiving PHP Exception Trace
<?php
function traceTest(SplFixedArray $arr, string $str, int $num)
{
print '----- Before variables changed -----' . PHP_EOL;
$e = new RuntimeException();
print $e->getTraceAsString() . PHP_EOL;
debug_print_backtrace();
print PHP_EOL;
@ssigwart
ssigwart / phpNestedSerializationBug.php
Last active August 30, 2019 20:14
PHP Nested Serialization Bug
<?php
// Possibly related:
// https://wiki.php.net/rfc/custom_object_serialization (Problems with existing custom object serialization mechanism)
// https://bugs.php.net/bug.php?id=76632
// https://bugs.php.net/bug.php?id=66052
// https://externals.io/message/98834
class ABase implements Serializable
{
@ssigwart
ssigwart / passwordLookup.php
Created August 4, 2017 03:36
Lookup a password to see if it's been cracked in a breach.
<?php
# Download text file from https://haveibeenpwned.com/Passwords
/** Password SHA1 searches */
class PasswordSha1Search
{
/** Line Size (sha1 + \r\n) */
const RECORD_SIZE = 42;
@ssigwart
ssigwart / redline_executor.rb
Last active May 20, 2017 15:31 — forked from mago0/redline_executor.rb
Segment of Redline13 Executor Script
require 'rest-client'
require 'json'
opts = {}
api_url = 'https://www.redline13.com/Api'
redline_key = 'REDACTED'
redline = RestClient::Resource.new(
"#{api_url}",
'headers' => {
@ssigwart
ssigwart / gist:aa4a2cdf8ffc4024bf89
Created March 13, 2015 00:30
Simple Redline13 Test Stats API Call
<?php
define('API_ENDPOINT', 'https://www.redline13.com/Api/');
define('API_AUTH_KEY', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
define('RUN_SIMPLE_LOAD_TEST', true);
// Build POST
$post = array(
'testType' => 'simple',
'name' => 'Simple Test With Name Via API',
@ssigwart
ssigwart / gist:886dcb3f0718d53c516b
Created March 13, 2015 00:28
Simple Redline13 Test Stats API Call
<?php
define('API_ENDPOINT', 'https://www.redline13.com/Api/');
define('API_AUTH_KEY', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
// Make request
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => API_ENDPOINT . 'StatsDownloadUrls?loadTestId=123',
@ssigwart
ssigwart / gist:def32a5486da90813abd
Created January 30, 2015 03:20
Redline13.com Custom PHP Load Test Downloading Credentials
<?php
/**
* This example is for writing a Custom PHP Load Test on redline13.com that might need to pick a random E-mail or other data.
* If placed inside of the CustomTest constructor, you can download a list of E-mails and randomly pick one to use for the test.
* The initial locking part ensures that the file is only downloaded once.
* This approach can be used to download other types of files that might be needed as well.
* For example, if you need to test uploading files, this can be used to download the files that you will be uploading in your test.
*/
@ssigwart
ssigwart / buildMultipartFormData.php
Created January 24, 2015 16:21
Build multipart/form-data in PHP
/**
* Build multipart/form-data
*
* @param array @$data Data
* @param array @$files 1-D array of files where key is field name and value if file contents
* @param string &$contentType Retun variable for content type
*
* @return string Encoded data
*/
function buildMultipartFormData(array &$data, array &$files, &$contentType)