Restructure repository: organize tools by purpose, create what search tool
- Move single-file tools to tools/ organized by category (security, forensics, data, etc.) - Move multi-file projects to projects/ (go-tools, puzzlebox, timesketch, rust-tools) - Move system scripts to scripts/ (proxy, display, setup, windows) - Organize config files in config/ (shell, visidata, applications) - Move experimental tools to archive/experimental - Create 'what' fuzzy search tool with progressive enhancement (ollama->fzf->grep) - Add initial metadata database for intelligent tool discovery - Preserve git history using 'git mv' commands
This commit is contained in:
98
tools/cloud/cloudsend.py
Executable file
98
tools/cloud/cloudsend.py
Executable file
@@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import logging
|
||||
import owncloud
|
||||
import gnupg
|
||||
import os
|
||||
import requests
|
||||
import re
|
||||
from icecream import ic
|
||||
|
||||
|
||||
def isurl(text):
|
||||
pattern = 'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'
|
||||
matcher = re.compile(pattern)
|
||||
return matcher.match(text)
|
||||
|
||||
def upload(file,url):
|
||||
try:
|
||||
oc = owncloud.Client.from_public_link(args.url)
|
||||
ic(oc)
|
||||
response = oc.drop_file(fn)
|
||||
ic(response)
|
||||
return response
|
||||
except owncloud.owncloud.HTTPResponseError as e:
|
||||
logging.error(f'Error while uploading file {fn} <{e}>')
|
||||
|
||||
def upload_rq(file,url):
|
||||
CLOUDURL=""
|
||||
FOLDERTOKEN=""
|
||||
|
||||
# FILENAME="$1"
|
||||
|
||||
# CLOUDURL=''
|
||||
# # if we have index.php in the URL, process accordingly
|
||||
# if [[ $2 == *"index.php"* ]]; then
|
||||
# CLOUDURL="${2%/index.php/s/*}"
|
||||
# else
|
||||
# CLOUDURL="${2%/s/*}"
|
||||
# fi
|
||||
|
||||
# FOLDERTOKEN="${2##*/s/}"
|
||||
# -T "$FILENAME" -u "$FOLDERTOKEN":"$PASSWORD" -H "$HEADER" "$CLOUDURL/$PUBSUFFIX/$BFILENAME"
|
||||
# if [ ! -f "$FILENAME" ]; then
|
||||
# initError "Invalid input file: $FILENAME"
|
||||
# fi
|
||||
|
||||
# if [ -z "$CLOUDURL" ]; then
|
||||
# initError "Empty URL! Nowhere to send..."
|
||||
# fi
|
||||
|
||||
# if [ -z "$FOLDERTOKEN" ]; then
|
||||
# initError "Empty Folder Token! Nowhere to send..."
|
||||
# fi
|
||||
|
||||
|
||||
PUBSUFFIX="public.php/webdav"
|
||||
HEADER='X-Requested-With: XMLHttpRequest'
|
||||
INSECURE=''
|
||||
|
||||
headers = {
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
}
|
||||
|
||||
|
||||
response = requests.put('https://nextcloud.exampyocclientple.com/public.php/webdav/testfile.txt', headers=headers, verify=args.insecure, auth=('AtAxVrKorgC5YJf', ''))
|
||||
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-k","--insecure",action="store_false")
|
||||
parser.add_argument("-x","--encryption",action="store",default=None,const='*',nargs="?",type=str)
|
||||
parser.add_argument("url")
|
||||
parser.add_argument("file",nargs="+")
|
||||
args=parser.parse_args()
|
||||
|
||||
if args.encryption is not None:
|
||||
ic(args.encryption)
|
||||
|
||||
if not isurl(args.url):
|
||||
logging.warning(f"URL '{args.url}' is not valid")
|
||||
|
||||
ic(args)
|
||||
for fn in args.file:
|
||||
ic(os.path.isdir(fn))
|
||||
ic(os.path.isfile(fn))
|
||||
if os.path.isdir(fn):
|
||||
logging.warning("Foldersupport not implemented yet")
|
||||
continue
|
||||
if upload(fn,args.url):
|
||||
logging.info(f"{fn} successfully uploaded")
|
||||
else:
|
||||
logging.warning(f"Error uploading {fn}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
151
tools/cloud/cloudsend.sh
Executable file
151
tools/cloud/cloudsend.sh
Executable file
@@ -0,0 +1,151 @@
|
||||
#!/usr/bin/env bash
|
||||
############################################################
|
||||
# MIGRATED TO REPOSITORY
|
||||
# https://github.com/tavinus/cloudsend.sh
|
||||
#
|
||||
# This gist will NOT be updated anymore
|
||||
############################################################
|
||||
|
||||
|
||||
############################################################
|
||||
#
|
||||
# cloudsend.sh
|
||||
#
|
||||
# Uses curl to send files to a shared
|
||||
# Nextcloud/Owncloud folder
|
||||
#
|
||||
# Usage: ./cloudsend.sh <file> <folderLink>
|
||||
# Help: ./cloudsend.sh -h
|
||||
#
|
||||
# Gustavo Arnosti Neves
|
||||
# https://github.com/tavinus
|
||||
#
|
||||
# Contributors:
|
||||
# @MG2R @gessel
|
||||
#
|
||||
# Get this script to current folder with:
|
||||
# curl -O 'https://raw.githubusercontent.com/tavinus/cloudsend.sh/master/cloudsend.sh' && chmod +x cloudsend.sh
|
||||
#
|
||||
############################################################
|
||||
|
||||
|
||||
CS_VERSION="0.1.6"
|
||||
|
||||
|
||||
|
||||
# https://cloud.mydomain.net/s/fLDzToZF4MLvG28
|
||||
# curl -k -T myFile.ext -u "fLDzToZF4MLvG28:" -H 'X-Requested-With: XMLHttpRequest' https://cloud.mydomain.net/public.php/webdav/myFile.ext
|
||||
|
||||
log() {
|
||||
[ "$VERBOSE" == " -s" ] || printf "%s\n" "$1"
|
||||
}
|
||||
|
||||
printVersion() {
|
||||
printf "%s\n" "CloudSender v$CS_VERSION"
|
||||
}
|
||||
|
||||
initError() {
|
||||
printVersion >&2
|
||||
printf "%s\n" "Init Error! $1" >&2
|
||||
printf "%s\n" "Try: $0 --help" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
usage() {
|
||||
printVersion
|
||||
printf "\n%s%s\n" "Parameters:" "
|
||||
-h | --help Print this help and exits
|
||||
-q | --quiet Be quiet
|
||||
-x | --encrypt Encrypt Upload with Password
|
||||
-V | --version Prints version and exits
|
||||
-k | --insecure Uses curl with -k option (https insecure)
|
||||
-p | --password Uses env var \$CLOUDSEND_PASSWORD as share password
|
||||
You can 'export CLOUDSEND_PASSWORD' at your system, or set it at the call.
|
||||
Please remeber to also call -p to use the password set."
|
||||
printf "\n%s\n%s\n%s\n" "Use:" " $0 <filepath> <folderLink>" " CLOUDSEND_PASSWORD='MySecretPass' $0 -p <filepath> <folderLink>"
|
||||
printf "\n%s\n%s\n%s\n" "Example:" " $0 './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'" " CLOUDSEND_PASSWORD='MySecretPass' $0 -p './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'"
|
||||
}
|
||||
|
||||
##########################
|
||||
# Process parameters
|
||||
|
||||
|
||||
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "-V" ] || [ "$1" = "--version" ]; then
|
||||
printVersion
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "-q" ] || [ "$1" = "--quiet" ]; then
|
||||
VERBOSE=" -s"
|
||||
shift
|
||||
fi
|
||||
|
||||
if [ "$1" = "-k" ] || [ "$1" = "--insecure" ]; then
|
||||
INSECURE=' -k'
|
||||
log " > Insecure mode ON"
|
||||
shift
|
||||
fi
|
||||
|
||||
if [ "$1" = "-p" ] || [ "$1" = "--password" ]; then
|
||||
PASSWORD=${CLOUDSEND_PASSWORD}
|
||||
log " > Using password from env"
|
||||
shift
|
||||
fi
|
||||
|
||||
|
||||
##########################
|
||||
# Validate input
|
||||
|
||||
FILENAME="$1"
|
||||
|
||||
CLOUDURL=''
|
||||
# if we have index.php in the URL, process accordingly
|
||||
if [[ $2 == *"index.php"* ]]; then
|
||||
CLOUDURL="${2%/index.php/s/*}"
|
||||
else
|
||||
CLOUDURL="${2%/s/*}"
|
||||
fi
|
||||
|
||||
FOLDERTOKEN="${2##*/s/}"
|
||||
|
||||
if [ ! -f "$FILENAME" ]; then
|
||||
initError "Invalid input file: $FILENAME"
|
||||
fi
|
||||
|
||||
if [ -z "$CLOUDURL" ]; then
|
||||
initError "Empty URL! Nowhere to send..."
|
||||
fi
|
||||
|
||||
if [ -z "$FOLDERTOKEN" ]; then
|
||||
initError "Empty Folder Token! Nowhere to send..."
|
||||
fi
|
||||
|
||||
|
||||
##########################
|
||||
# Check for curl
|
||||
|
||||
CURLBIN='/usr/bin/curl'
|
||||
if [ ! -x "$CURLBIN" ]; then
|
||||
CURLBIN="$(which curl 2>/dev/null)"
|
||||
if [ ! -x "$CURLBIN" ]; then
|
||||
initError "No curl found on system!"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
##########################
|
||||
# Extract base filename
|
||||
|
||||
BFILENAME=$(/usr/bin/basename $FILENAME)
|
||||
|
||||
|
||||
##########################
|
||||
# Send file
|
||||
|
||||
#echo "$CURLBIN"$INSECURE$VERBOSE -T "$FILENAME" -u "$FOLDERTOKEN":"$PASSWORD" -H "$HEADER" "$CLOUDURL/$PUBSUFFIX/$BFILENAME"
|
||||
"$CURLBIN"$INSECURE$VERBOSE -T "$FILENAME" -u "$FOLDERTOKEN":"$PASSWORD" -H "$HEADER" "$CLOUDURL/$PUBSUFFIX/$BFILENAME"
|
||||
26
tools/cloud/speech.py
Normal file
26
tools/cloud/speech.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import speech_recognition as sr
|
||||
|
||||
recognizer = sr.Recognizer()
|
||||
|
||||
''' recording the sound '''
|
||||
|
||||
with sr.Microphone() as source:
|
||||
print("Adjusting noise ")
|
||||
recognizer.adjust_for_ambient_noise(source, duration=1)
|
||||
print("Recording for 4 seconds")
|
||||
recorded_audio = recognizer.listen(source, timeout=4)
|
||||
print("Done recording")
|
||||
|
||||
''' Recorgnizing the Audio '''
|
||||
try:
|
||||
print("Recognizing the text")
|
||||
|
||||
text = recognizer.recognize_sphinx(
|
||||
recorded_audio,
|
||||
language="de-DE"
|
||||
)
|
||||
print("Decoded Text : {}".format(text))
|
||||
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
|
||||
84
tools/cloud/vqa3.py
Normal file
84
tools/cloud/vqa3.py
Normal file
@@ -0,0 +1,84 @@
|
||||
import os
|
||||
import argparse
|
||||
from PIL import Image
|
||||
from transformers import CLIPProcessor, CLIPModel
|
||||
from collections import defaultdict
|
||||
|
||||
|
||||
def classify_images(model_name, image_paths, class_names):
|
||||
# Load CLIP model and processor
|
||||
model = CLIPModel.from_pretrained(model_name)
|
||||
processor = CLIPProcessor.from_pretrained(model_name)
|
||||
|
||||
classification_results = defaultdict(list)
|
||||
|
||||
# Perform zero-shot classification on each image
|
||||
for image_path in image_paths:
|
||||
try:
|
||||
image = Image.open(image_path)
|
||||
|
||||
# Process the input image and text labels
|
||||
inputs = processor(
|
||||
text=class_names,
|
||||
images=image,
|
||||
return_tensors="pt",
|
||||
padding=True
|
||||
)
|
||||
|
||||
# Run the model and get logits
|
||||
outputs = model(**inputs)
|
||||
logits_per_image = outputs.logits_per_image
|
||||
|
||||
# Calculate probabilities
|
||||
probs = logits_per_image.softmax(dim=1)
|
||||
|
||||
# Get the predicted label
|
||||
pred_label = class_names[probs.argmax(dim=1).item()]
|
||||
|
||||
classification_results[pred_label].append(image_path)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Skipping {image_path} due to error: {e}")
|
||||
|
||||
for label, images in classification_results.items():
|
||||
print(f"{label}:")
|
||||
for image_path in images:
|
||||
print(f" {image_path}")
|
||||
|
||||
|
||||
def main():
|
||||
available_models = [
|
||||
"openai/clip-vit-large-patch14",
|
||||
"openai/clip-vit-base-patch32",
|
||||
"openai/clip-vit-base-patch16"
|
||||
]
|
||||
|
||||
parser = argparse.ArgumentParser(description="CLIP-based Image Classifier")
|
||||
parser.add_argument("--model", type=str, default="openai/clip-vit-base-patch16",
|
||||
help="Model name to use for classification (default: openai/clip-vit-base-patch16)")
|
||||
parser.add_argument("-c", "--category", action="append",default=["image is safe for work", "image is not safe for work"],help="Add a classification category (e.g., 'man', 'woman', 'child', 'animal'). If not specified, the default categories will be 'safe for work' and 'not safe for work'.")
|
||||
parser.add_argument("paths", metavar="path", type=str, nargs="+",
|
||||
help="List of image file paths or directories")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.model.lower() == "list":
|
||||
print("Available models:")
|
||||
for model in available_models:
|
||||
print(f" {model}")
|
||||
return
|
||||
|
||||
image_paths = []
|
||||
for path in args.paths:
|
||||
if os.path.isdir(path):
|
||||
image_paths.extend([os.path.join(path, file) for file in os.listdir(path)])
|
||||
elif os.path.isfile(path):
|
||||
image_paths.append(path)
|
||||
else:
|
||||
print(f"Skipping {path}, not a valid file or directory")
|
||||
|
||||
classify_images(args.model, image_paths, args.category)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
14
tools/cloud/youtube_resolve.sh
Executable file
14
tools/cloud/youtube_resolve.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
url=$(echo -ne "${*}" | grep -Pio -m1 'https://www.youtube.com/(watch\?[^&,|]+|embed/[^?/,|]+)')
|
||||
if [[ -n "${url}" ]] ; then
|
||||
title=$(wget -q -O- "${url}" | grep -Po "(?<=title>).*(?=</title)")
|
||||
title_parsed=$(cat <<eof | python3
|
||||
from urllib.parse import unquote
|
||||
from html import unescape
|
||||
url="${title}"
|
||||
print(unescape(unquote(url)))
|
||||
eof
|
||||
)
|
||||
echo "${url};\"${title_parsed}\""
|
||||
|
||||
fi
|
||||
Reference in New Issue
Block a user