Skip to content

Instantly share code, notes, and snippets.

View paceaux's full-sized avatar
🌐
Obsessing with languagey things

Paceaux paceaux

🌐
Obsessing with languagey things
View GitHub Profile
@paceaux
paceaux / evil.php
Created September 1, 2024 18:25
Basic Hacker management for folks looking for PHP vulnerabilities
<?php
function getUserIP() {
if( array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) {
if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',')>0) {
$addr = explode(",",$_SERVER['HTTP_X_FORWARDED_FOR']);
return trim($addr[0]);
} else {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
@paceaux
paceaux / levenshtein.js
Last active February 26, 2024 18:15
String comparisons
/**
* @description calculates the levenshtein distance between words
* @param {string} str a string
* @param {string} str2 another string
* @returns {object} with properties 'steps' and 'transitions'
*/
function levenshtein(str, str2) {
if (typeof str !== 'string' || typeof str2 !== 'string') return;
let [shorter, longer] = [str, str2].sort((a, b) => a.length - b.length);
@paceaux
paceaux / find-balada-infection.sh
Last active November 9, 2023 18:13
Find Balada-infected files on your wordpress host
#!/bin/bash
echo "hello" $USER "we're gonna find some infected files";
echo "=====First: let's find .oti Injections=====";
grep --include=\*.php -Hnrwo -P '^(@include)+.+(\.ot(i|\\x69|c)\"\);)' . ;
find . -type f -name "*.oti";
echo "=====Next: let's find PHP files with obfuscated code being evaluated=====";
echo " looking for the cookie/post files";
grep --include=\*.php -Hwnro -P '(\$_COOKIE(,|;))+.+(\$_POST)' . ;
echo " looking for the die() files"
grep --include=\*.php -Hwnro -P "(die+)(?:.[^'\"\$\s_a-z0-1]+)(\);)" . ;
@paceaux
paceaux / regexes.js
Created January 6, 2023 16:30
Pronoun Regexes
const masculinePronouns = new RegExp('\b(she|(her(s(elf|\b)|\b))|s(on|a|u(a|\b))|el{1,2}(a|e)(-même|\b))\b((\W(m(i|e)sma)|\b))', 'gi');
const femininePronouns = new RegExp('\b(she|(her(s(elf|\b)|\b))|s(on|a|u(a|\b))|el{1,2}(a|e)(-même|\b))\b((\W(m(i|e)sma)|\b))','gi');
/*
English: she, her, hers, herself
French: elle, elle-même, son, sa
Spanish: ella, su, ella misma
Portuguese: ela, sua, ela mesma
@paceaux
paceaux / tableOfContents.js
Created March 16, 2022 16:49
A class for generating a table of contents on a page.
class TableOfContents {
static listContainerClass = 'articleTOC__list';
static listItemClass = 'articleTOC__item';
static listLinkClass = 'articleTOC__link';
static modifierSeparator = '--';
/*
* @description Gets a list of all title elements having an ID in a given container
* @param {HTMLElement} container - An element containing title elements (h1, h2, h3)
/**
* @class Locker
* @description who doesn't like Konami?
* @example const locker = new Locker(); locker.initialize();
*
*/
// I'm not going to use Babel for a tiny static site
// eslint-disable-next-line no-unused-vars
class Locker {
/**
@paceaux
paceaux / clientStorage.js
Last active January 19, 2024 22:39
ClientStorage Module for saving things in a namespaced way to local or session storage.
class ClientStorage {
/**
* Converts a string into a namespaced string
* @param {string} namespace the namespace
* @param {string} keyname keyname
* @returns {string} a string with namespace.keyname
*/
static getNamespacedKeyName(namespace, keyname) {
let namespacedKeyName = "";
@paceaux
paceaux / README.md
Created October 19, 2021 14:16
Front-end Readme
@paceaux
paceaux / classname.regex.js
Created January 5, 2021 17:07
A Regex for finding a class name in html
/*
where "title" is the full class name
/class=(.*[ "]title[ "].*)/g
*/
const className = 'title';
const regex = new RegExp(`/class=(.*[ "]${className}[ "].*)/g`);
@paceaux
paceaux / jscss.js
Last active October 29, 2020 16:25
JSCSS, The quick and easy way to do CSS in the DOM
/**
* Class for adding CSS with JavaScript that relies on the CSSOM
*/
class JSCSS {
/**
* @param {string} cssText Text for a stylesheet. Rulesets, queries, and all
*/
constructor(cssText = '') {
const sheet = JSCSS.addStyleSheet();
this.stylesheet = JSCSS.getStyleSheet(sheet.title);