Skip to content

Instantly share code, notes, and snippets.

View craigfrancis's full-sized avatar

Craig Francis craigfrancis

View GitHub Profile
@craigfrancis
craigfrancis / check.sh
Created February 17, 2020 12:56
Check www-data folder and crontab permissions
#!/bin/bash
set -u;
root="/opt/permission-tester/";
output=`mktemp -t permission-tester.XXXXXXXXXX`;
#--------------------------------------------------
# Check excluded folders exist, and are noexec
#--------------------------------------------------
@craigfrancis
craigfrancis / base64-random-keys.php
Created January 6, 2018 12:28
Why you need to be careful when using base64 encoding to get a random key from random_bytes()
<?php
$characters = [];
for ($k = 0; $k < 500000; $k++) {
$key = base64_encode(random_bytes(32)); // 32 bytes results in "=" padding; try changing to 30 to fix.
foreach (str_split($key) as $c) {
if (!isset($characters[$c])) {