Skip to content

Instantly share code, notes, and snippets.

View pkdavies's full-sized avatar

Peter Davies pkdavies

View GitHub Profile
@pkdavies
pkdavies / replaceme.php
Created June 6, 2023 16:31
Find and replace script
<?php
// Your search word goes here
$search_word = 'https://url.to.find/';
$replacement_word = 'https://cdn.new.com/';
// Set your database credentials
$servername = 'mysql.database.azure.com';
$database = "prod";
$username = "user";
@pkdavies
pkdavies / findme.php
Last active June 6, 2023 15:32
This PHP script will search all tables for a word
<?php
// Your search word goes here
$search_word = 'wordupdude';
// DB Details
$hostname = "mysql.database.azure.com";
$database = "wp_prod";
$username = "wp_prod_user";
$password = "wp_prod_pass";
@pkdavies
pkdavies / findtext.py
Last active May 31, 2023 21:18
Recursively find text within a site using multi-threading
import requests
from bs4 import BeautifulSoup
import threading
from queue import Queue
from fake_useragent import UserAgent
URL = 'https://example.com' # Replace with the website you want to start at
SEARCH_STRING = 'example' # Replace with the string you want to search for
MAX_THREADS = 10 # Set the maximum number of threads
@pkdavies
pkdavies / urlme.py
Created May 31, 2023 20:57
Extract URLs from a sitemap.xml
import requests
from xml.etree import ElementTree as ET
import random
def extract_urls(sitemap_url, urls=None):
if urls is None:
urls = []
well_known_user_agents = [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36',
@pkdavies
pkdavies / payload.js
Created April 1, 2022 13:43
ELSYS simple payload decoder.
/*
ELSYS simple payload decoder.
www.elsys.se | peter@elsys.se
Modified by Pete Davies @ CDS
Ref: https://www.elsys.se/en/elsys-payload/
Ref: https://lorawan-packet-decoder-0ta6puiniaut.runkit.sh/
*/
@pkdavies
pkdavies / wp-createpost.php
Created January 18, 2019 15:27
Generate 50k wordpress posts - stress test
<?php
if (ob_get_level() == 0) ob_start();
require_once("wp-load.php");
$postType = 'post'; // set to post or page
$userID = 1; // set to user id
$categoryID = '2'; // set to category id.
$postStatus = 'publish'; // set to future, draft, or publish
$start = 1;
$end = 50000;
@pkdavies
pkdavies / kill-site-http-request.sh
Created November 22, 2018 13:36
This tests a connection to a site to see at what point requests are denied by a rate limiting service
#!/bin/bash
for ((i=1;i<=50;i++)); do curl -v --header "Connection: keep-alive" "https://www.CLIENT.com/endpoint"; done
@pkdavies
pkdavies / warm.sh
Created November 22, 2018 13:33
Cache warming script using siege
#!/bin/bash
rm sitemap.xml
wget -q https://www.CLIENT.com/sitemap.xml
sed '/<loc>/!d; s/[[:space:]]*<loc>\(.*\)<\/loc>/\1/' sitemap.xml > links.txt
siege -b -v -c 10 -f links.txt -r once -H 'Accept-Encoding: gzip' 2>/dev/null
@pkdavies
pkdavies / geoip.php
Last active December 5, 2017 13:38
MaxMind GeoIP test
<h1>GEO IP Test</h1>
<h2>Info</h2>
<pre><?php
$cst = array(
'GEOIP_COUNTRY_EDITION' => GEOIP_COUNTRY_EDITION,
'GEOIP_REGION_EDITION_REV0' => GEOIP_REGION_EDITION_REV0,
'GEOIP_CITY_EDITION_REV0' => GEOIP_CITY_EDITION_REV0,
'GEOIP_ORG_EDITION' => GEOIP_ORG_EDITION,
'GEOIP_ISP_EDITION' => GEOIP_ISP_EDITION,
@pkdavies
pkdavies / azurewaf.php
Created October 27, 2017 20:37
Process Azure WAF logs from json debug
<?php
/**
* Created by PhpStorm.
* User: peted
* Date: 27/10/2017
* Time: 21:03
*
*/
$json_file = "test.json";