Skip to content

Instantly share code, notes, and snippets.

@igmoweb
igmoweb / scratch_3.html
Last active November 29, 2017 15:07
CSRF form
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Gana un iphone!</title>
</head>
<body>
<form action="http://www.soyjaimito.com/wp-admin/admin-ajax.php" id="esto-pica" method="post">
<input type="hidden" name="text" value="Hola, necesito ayuda con vuestro plugin. Se me ha roto, ¿Podríais enviarme mis datos privados ya de paso? Es que he perdido la contraseña">
@igmoweb
igmoweb / plugin.php
Created November 29, 2017 15:01
Otra vez problemas de CSRF
<?php
/**
* Plugin Name: Un ejemplo de plugin con un problema de CSRF
*/
add_action( 'init', 'wp_ajax_envia_email_a_soporte' );
function wp_ajax_envia_email_a_soporte() {
$text = $_POST['text'];
@igmoweb
igmoweb / plugin-corregido.php
Created November 29, 2017 14:46
Plugin sin CSRF
<?php
/**
* Plugin Name: Un ejemplo de plugin con un problema de CSRF
*/
add_action( 'init', 'maybe_delete_user' );
function maybe_delete_user() {
if ( isset( $_POST['action'] ) && $_POST['action'] === 'delete-user' ) {
@igmoweb
igmoweb / vas-a-ver.html
Created November 29, 2017 14:16
Prueba de CSRF
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Gana un iphone!</title>
</head>
<body>
<form action="http://www.soyjaimito.com" id="esto-pica" method="post">
<input type="hidden" name="user_id" value="1">
@igmoweb
igmoweb / plugin.php
Created November 29, 2017 14:04
Ejemplo de plugin con CSRF
<?php
/**
* Plugin Name: Un ejemplo de plugin con un problema de CSRF
*/
add_action( 'init', 'maybe_delete_user' );
function maybe_delete_user() {
if ( isset( $_POST['action'] ) && $_POST['action'] === 'delete-user' ) {
@igmoweb
igmoweb / .bash_profile
Last active May 1, 2020 09:08
Prevent rm doom!
function rm () {
local path
for path in "$@"; do
# ignore any arguments
if [[ "$path" = -* ]]; then :
else
local dst=${path##*/}
# append the time if necessary
while [ -e ~/.Trash/"$dst" ]; do
dst="$dst "$(date +%H-%M-%S)
@igmoweb
igmoweb / index.js
Created July 5, 2017 07:54
Just playing with compression algorythms
// Load the http module to create an http server.
var http = require('http');
var execFile = require('child_process').execFile;
var exec = require('child_process').exec;
var mozjpeg = require('mozjpeg');
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
@igmoweb
igmoweb / scratch_102.php
Created June 29, 2017 15:09
Check if a post is under knowledge category
<?php
function yell_is_knowledge_post( $post_id ) {
$categories = get_the_category( $post_id );
if ( in_array( 'knowledge', wp_list_pluck( $categories, 'slug' ), true ) ) {
return true;
}
$knowledge_cat = get_term_by( 'slug', 'knowledge', 'category' );
@igmoweb
igmoweb / webpack.config.js
Created April 28, 2017 10:50
Webpack with development/production configs
const path = require( 'path' );
// Configuración común para desarrollo y producción
var config = {
entry: [
'./src/index.js'
],
output: {
filename: 'app.js',
path: path.resolve( __dirname, 'build' )
@igmoweb
igmoweb / webpack.config.js
Last active April 28, 2017 10:16
Webpack with source maps (1)
const path = require( 'path' );
module.exports = {
entry: [
'./src/index.js'
],
output: {
filename: 'app.js',
path: path.resolve( __dirname, 'build' )
},