Skip to content

Instantly share code, notes, and snippets.

@orangeblock
orangeblock / renamer.py
Last active Mar 28, 2021
Run as `python3 renamer.py /path/to/normalize`. Renames all files and subdirectories at specified root to be UNIX-friendly and not require any quoting.
View renamer.py
#!/usr/bin/python3
import os
import re
import sys
try:
PATH = sys.argv[1]
except IndexError:
print("Usage: %s /path/to/normalize" % sys.argv[0])
exit(0)
@orangeblock
orangeblock / portcheck.ps1
Last active Mar 27, 2021
Powershell script to check which hosts have a port open. You can use it without any arguments to scan local addresses [192.168.1.2 - 192.168.1.30] for port 22, or use the arguments at the top to specify various properties.
View portcheck.ps1
param(
[string]$HostPrefix = "192.168.1.",
[int]$Port = 22,
[int]$StartIndex = 2,
[int]$EndIndex = 30,
[int]$ConnectTimeout = 150
)
function testport ($hostname, $port, $timeout) {
$client = New-Object System.Net.Sockets.TcpClient
@orangeblock
orangeblock / dler.py
Last active Dec 23, 2018
Customizable concurrent URL downloader. Works with Python 2.7x and 3.x, only using core libraries. Can be ran as a command line script or used as a library. Simply pass a list of URLs to download_files. For the rest simply read the docstring or --help from the CL.
View dler.py
#!/usr/bin/python
import os
import sys
import csv
import time
import shutil
from multiprocessing.dummy import Pool as ThreadPool
from collections import Iterable
try:
@orangeblock
orangeblock / handler.sh
Last active Mar 22, 2020
GitHub webhook listener, using netcat and bash. `listen.sh` and `handler.sh` must be in the same directory. Start with `./listen.sh <port> <path-to-script> [<endpoint>]`. All files (including scripts) must be executable.
View handler.sh
#!/bin/bash
# parse endpoint (only works for POST)
read request
url="${request#POST }"
url="${url% HTTP/*}"
# change this!!!
secret="top-secret"