Skip to content

Instantly share code, notes, and snippets.

View cebe's full-sized avatar
☁️
working on cebe.cloud

Carsten Brandt cebe

☁️
working on cebe.cloud
View GitHub Profile
@cebe
cebe / basicauth.php
Created May 2, 2017 20:25
allow basic auth for users not logged in
<?php
class SomeController extends yii\web\Controller
{
/**
* @var array actions to authenticate via basicAuth if not logged in.
*/
public $basicAuthActions = [];
/**
@cebe
cebe / AR.php
Last active February 10, 2017 13:10
<?php
use yii\behaviors\TimestampBehavior;
public function behaviors()
{
return [
'timestamp' => function() {
$b = new TimeStampBehavior();
$b->attributes = [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
@cebe
cebe / phpmailer.sh
Last active December 28, 2016 12:38
command for finding vulnerable files and line of code for https://isc.sans.edu/forums/diary/Critical+security+update+PHPMailer+5218+CVE201610033/21855/ finds also really old versions, e.g. 2.0.4.
#!/bin/bash
for file in $(find /var/www |grep class.phpmailer.php) ; do echo $file; grep -ni '%s["'\''], $this->Sender' $file ; done

Keybase proof

I hereby claim:

  • I am cebe on github.
  • I am cebe (https://keybase.io/cebe) on keybase.
  • I have a public key whose fingerprint is E592 6050 AE9C 234A FF84 96FE BE4F 41DE 1DEE EED0

To claim this, I am signing this object:

@cebe
cebe / style.html
Created October 26, 2016 21:53
Background Color in combination with multiple Background images
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.somediv {
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACsAAAAXCAYAAACS5bYWAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABFpJREFUeNrUV0tIo1cUvpkYjQ4xxSA6DxuNqG0dtaUKOgs3s6i0dFd3pSsXdjeIixakiGA34sZuXCkoONLFwJTK4GMYLYXg29gatTpiXurkbd7vv9/5ub+IxuhA7eiFQ5Kbc8/57ne/e87/ywRBYLdl3GG3aNwqsLJ0k0tLS+fmcnNzWUVFBVMoFGx2djarvLxcm5OTw+bm5iytra2xc4ExNjY27iqVyvvwK6CpeDzuCYVC1urq6qDA9UcfPp+PHR4esmAwKK6tr68/l5/8rgQ2Ozub1dbWyiYmJooaGxt/VqvV38jlchX9l0qlwoFA4DWS/RKLxRxFRUVf5+XlPcaaT2AP0sVPJBL2SCRiAPBpu93+vKamZo/Ae71eZjabWV1dXVqw7CKwp43ksrCw8Bhg7MJ/PLDZ5PHx8cz29vYT5JGD/bSYLgTrcDgYdk6siSc6NjZWDaAe4ZoHQL+cmZnRpZPnhWDpD8kw7uKo9ML/NMCsd2tr61vkzboMrEyv138M7TyLRqMWMBsX3sMgaZhMpp+AR5EJrCocDpuEGzKg4x8khs+CVWxubvZfR9JkMik4nU7BarUKLpeLmLsKuwIqTLynp4fqmIzASrqQT09Pf1VVVfX0KsWZ6uHBwQHTaDSsoKAgo6/H4xHLEcrVyRwuEisrKzs5XrrIVAVwiUVDKRRrL+YI32ewdVhMApuHWvcj6vids6J2u90MF4yBHUZNgKoEBaRBQalJqFSqtJfUYrGIlQX+ydXVVTN+u0tKSjQNDQ1axJVl2iTypebn55d7e3v/kqoDgZU1NTU9LCws/Py0M+
@cebe
cebe / bug.sh
Created October 13, 2016 08:44
git tag bug
#!/bin/sh -e
mkdir gitbug && cd gitbug
git init
touch README.md
git add README.md
git commit -m "initial commit"
echo "this is the example from 'git help tag':"
GIT_COMMITTER_DATE="2006-10-02 10:31" git tag -s -m "mytag1" v1.0.1
echo "it has the correct date:"
@cebe
cebe / ls.php
Created October 5, 2016 20:20
PHP Scripts that can help you debug and remove huge (order of 10million files) directories.
<?php
// get the file count, because `ls |wc -l` will not complete in reasonable time
// usage: php ls.php path/
$path = $argv[1];
$dir = opendir($path);
if (!$dir) {
echo "unable to open dir\n";
<?php
public function actionFile($filename)
{
$storagePath = Yii::getAlias('@app/files');
// check filename for allowed chars (do not allow ../ to not allow listing)
if (!preg_match('/^[a-z0-9]+\.[a-z0-9]+$/i', $filename) || !is_file("$storagePath/$filename")) {
throw new NotFoundHttpException('The file does not exists.');
@cebe
cebe / composer.json
Created May 7, 2016 17:54
Demo for demonstrating maximum nesting level in markdown parser.
{
"require": {
"league/commonmark": "^0.13.2"
}
}
(gdb) run --portable
Starting program: /home/cebe/dev/tox/uTox/utox --portable
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Launching uTox in portable mode: All data will be saved to the tox folder in the current working directory
0
have GTK
[New Thread 0x7fffecf57700 (LWP 20190)]
[New Thread 0x7fffec138700 (LWP 20191)]
Using unencrypted save file; this is insecure!