Restructure repo layout and document conventions
Move legacy systemscripts into scripts/display and scripts/setup. Rehome stray top-level tools into their domain folders. Archive narrow experiments and outdated codegrab leftovers. Remove empty legacy directories and stale root files. Expand macOS metadata ignores and update the README with the refined repository structure.
This commit is contained in:
7
archive/experimental/ctf_primefac.py
Normal file
7
archive/experimental/ctf_primefac.py
Normal file
@@ -0,0 +1,7 @@
|
||||
import primefac
|
||||
import sys
|
||||
|
||||
# n = int( sys.argv[1] )
|
||||
n=1547526036699919708490609738397251465827883560269494112135036895312456811185879551982265065963
|
||||
factors = list( primefac.primefac(n) )
|
||||
print '\n'.join(map(str, factors))
|
||||
11
archive/experimental/rootshell.c
Normal file
11
archive/experimental/rootshell.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
setuid(0);
|
||||
system("/bin/bash");
|
||||
return 0;
|
||||
}
|
||||
18
archive/experimental/screen2.js
Normal file
18
archive/experimental/screen2.js
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
var page = require('webpage').create(),
|
||||
url = 'https://mobile.twitter.com/carlomasala1/status/1490645423257706498',
|
||||
w = 1920,
|
||||
h = 8000
|
||||
|
||||
page.viewportSize = { width: w, height: h }
|
||||
page.open(url, function(status) {
|
||||
if (status !== 'success') {
|
||||
console.log('Unable to load url: ' + url)
|
||||
} else {
|
||||
window.setTimeout(function() {
|
||||
page.clipRect = { top: 0, left: 0, width: w, height: h }
|
||||
page.render('img.png')
|
||||
phantom.exit()
|
||||
}, 20000)
|
||||
}
|
||||
})
|
||||
53
archive/experimental/screenshot.js
Normal file
53
archive/experimental/screenshot.js
Normal file
@@ -0,0 +1,53 @@
|
||||
//Requires PhantomJS
|
||||
//Install with apt install phantomjs
|
||||
|
||||
var system = require('system');
|
||||
var args = system.args;
|
||||
|
||||
if (args.length === 1) {
|
||||
console.log('Try to pass some arguments when invoking this script!');
|
||||
} else {
|
||||
args.forEach(function(arg, i) {
|
||||
console.log(i + ': ' + arg);
|
||||
});
|
||||
}
|
||||
var scriptname=args.shift()
|
||||
urls=args.slice(1)
|
||||
// var urls = [
|
||||
// "http://www.google.de",
|
||||
// "http://heise.de",
|
||||
// "https://www.test.de"
|
||||
// ]
|
||||
var webpage = require('webpage'),
|
||||
page = webpage.create(),
|
||||
// page.width=1920;
|
||||
nr = 0;
|
||||
page.viewportSize = {width: 1920, height: 15000};
|
||||
// Seitendimensionen ggf. anpassen
|
||||
|
||||
|
||||
var screenshot = function() {
|
||||
if (!urls.length) phantom.exit();
|
||||
var _url = urls.shift();
|
||||
console.log('Öffne Seite ' + (nr+1) + ': ' + _url);
|
||||
page.open(_url, function(status) {
|
||||
if (status !== 'success') {
|
||||
console.log('Netzwerkproblem: ' + status);
|
||||
urls.unshift(_url);
|
||||
setTimeout(screenshot, 1000);
|
||||
} else {
|
||||
++nr;
|
||||
page.evaluate(function() {
|
||||
var style = document.createElement('style'),
|
||||
bg = document.createTextNode('body {background: #fff}; html {width: 1000px};');
|
||||
style.setAttribute('type', 'text/css');
|
||||
style.appendChild(bg);
|
||||
document.head.insertBefore(style, document.head.firstChild);
|
||||
});
|
||||
page.render('screenshot_' + nr + '_' + Date.now() + '.jpg', {format: 'jpeg', quality: 80});
|
||||
setTimeout(screenshot, 2000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
screenshot();
|
||||
165
archive/experimental/sep_test.sh
Normal file
165
archive/experimental/sep_test.sh
Normal file
@@ -0,0 +1,165 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to print usage information
|
||||
usage() {
|
||||
echo "Usage: $0 <image> <start_tag> <end_tag>"
|
||||
echo "Example: $0 tabledevil/sep 230101 230916"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Function to get today's date in YYMMDD format
|
||||
get_today() {
|
||||
date +%y%m%d
|
||||
}
|
||||
|
||||
# Assign arguments to variables or use defaults
|
||||
image="${1:-tabledevil/sep}"
|
||||
start_tag="$2"
|
||||
end_tag="${3:-$(get_today)}"
|
||||
IMAGE_REPOSITORY=$(echo "$image" | cut -d'/' -f1)
|
||||
IMAGE_NAME=$(echo "$image" | cut -d'/' -f2)
|
||||
|
||||
PATTERN="Threat Found!"
|
||||
|
||||
# Validate that start_tag and end_tag are in the correct format
|
||||
if ! [[ "$start_tag" =~ ^[0-9]{6}$ ]] || ! [[ "$end_tag" =~ ^[0-9]{6}$ ]]; then
|
||||
echo "Error: Tags must be in YYMMDD format."
|
||||
usage
|
||||
fi
|
||||
|
||||
# Function to get Docker Hub token using PAT
|
||||
get_token() {
|
||||
if [ -z "$DOCKER_USERNAME" ]; then
|
||||
read -p "Enter Docker Hub username: " DOCKER_USERNAME
|
||||
fi
|
||||
if [ -z "$DOCKER_PAT" ]; then
|
||||
read -sp "Enter Docker Hub token: " DOCKER_PAT
|
||||
echo
|
||||
fi
|
||||
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${DOCKER_USERNAME}'", "password": "'${DOCKER_PAT}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
|
||||
if [ "$TOKEN" == "null" ]; then
|
||||
echo "Failed to get token. Please check your credentials."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to get tags for a repository
|
||||
get_tags() {
|
||||
PAGE=1
|
||||
PAGE_SIZE=100
|
||||
TAGS=()
|
||||
|
||||
while true; do
|
||||
if [ -n "$TOKEN" ]; then
|
||||
RESPONSE=$(curl -s -H "Authorization: JWT ${TOKEN}" "https://hub.docker.com/v2/repositories/${IMAGE_REPOSITORY}/${IMAGE_NAME}/tags/?page_size=${PAGE_SIZE}&page=${PAGE}")
|
||||
else
|
||||
RESPONSE=$(curl -s "https://hub.docker.com/v2/repositories/${IMAGE_REPOSITORY}/${IMAGE_NAME}/tags/?page_size=${PAGE_SIZE}&page=${PAGE}")
|
||||
fi
|
||||
TAGS_PAGE=$(echo $RESPONSE | jq -r '.results[].name')
|
||||
TAGS+=($TAGS_PAGE)
|
||||
|
||||
NEXT=$(echo $RESPONSE | jq -r '.next')
|
||||
if [ "$NEXT" == "null" ]; then
|
||||
break
|
||||
fi
|
||||
PAGE=$((PAGE + 1))
|
||||
done
|
||||
|
||||
echo "${TAGS[@]}"
|
||||
}
|
||||
|
||||
# Function to filter tags based on date range
|
||||
filter_tags_by_date() {
|
||||
local tags=("$@")
|
||||
local filtered=()
|
||||
local start="$start_tag"
|
||||
local end="$end_tag"
|
||||
|
||||
for tag in "${tags[@]}"; do
|
||||
if [[ "$tag" =~ ^[0-9]{6}$ ]]; then
|
||||
if [[ "$tag" -ge "$start" && "$tag" -le "$end" ]]; then
|
||||
filtered+=("$tag")
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "${filtered[@]}"
|
||||
}
|
||||
|
||||
# Function to check for malware in the given Docker tag
|
||||
check_malware() {
|
||||
local tag=$1
|
||||
echo -n "Checking $image:$tag "
|
||||
result=$(docker run -it --rm -v "$(pwd):/data:ro" --network=none "$image:$tag" scan)
|
||||
if echo "$result" | grep -q "$PATTERN"; then
|
||||
echo "Pattern found"
|
||||
return 0
|
||||
else
|
||||
echo "Pattern NOT found"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to run the binary search
|
||||
binary_search() {
|
||||
local tags=("$@")
|
||||
local low=0
|
||||
local high=$(( ${#tags[@]} - 1 ))
|
||||
local mid
|
||||
|
||||
# Determine the initial states for low and high
|
||||
check_malware "${tags[$low]}"
|
||||
local low_result=$?
|
||||
|
||||
check_malware "${tags[$high]}"
|
||||
local high_result=$?
|
||||
|
||||
# If the results for low and high are the same, there is no switch point in the range
|
||||
if [ $low_result -eq $high_result ]; then
|
||||
echo "No change in detection within the tag range."
|
||||
return
|
||||
fi
|
||||
|
||||
# Binary search to find the exact switching point
|
||||
while [ $((low + 1)) -lt $high ]; do
|
||||
mid=$(((low + high) / 2))
|
||||
check_malware "${tags[$mid]}"
|
||||
local mid_result=$?
|
||||
|
||||
if [ $mid_result -eq $low_result ]; then
|
||||
low=$mid
|
||||
else
|
||||
high=$mid
|
||||
fi
|
||||
done
|
||||
|
||||
# Output the tag of the first image that finds the malware switch
|
||||
echo "The detection changes between tags: ${tags[$low]} - ${tags[$high]}"
|
||||
}
|
||||
|
||||
|
||||
# Main script execution
|
||||
|
||||
# Try to retrieve all tags without authentication
|
||||
echo "Retrieving all tags for $image from Docker Hub..."
|
||||
all_tags=($(get_tags))
|
||||
echo $all_tags
|
||||
|
||||
# If tags retrieval failed, prompt for credentials and retry
|
||||
if [ ${#all_tags[@]} -eq 0 ]; then
|
||||
echo "Failed to retrieve tags without authentication. Trying with credentials..."
|
||||
get_token
|
||||
all_tags=($(get_tags))
|
||||
if [ ${#all_tags[@]} -eq 0 ]; then
|
||||
echo "Failed to retrieve tags even with authentication."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Filter tags to include only those within the date range
|
||||
echo "Filtering tags from $start_tag to $end_tag..."
|
||||
filtered_tags=($(filter_tags_by_date "${all_tags[@]}"))
|
||||
|
||||
# Run the binary search on the filtered tags
|
||||
echo "Running binary search on the filtered tags..."
|
||||
binary_search "${filtered_tags[@]}"
|
||||
44
archive/experimental/usbreset.c
Normal file
44
archive/experimental/usbreset.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/* usbreset -- send a USB port reset to a USB device */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <linux/usbdevice_fs.h>
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *filename;
|
||||
int fd;
|
||||
int rc;
|
||||
|
||||
if (argc != 2) {
|
||||
printf("Listing all USB devices:\n");
|
||||
system("lsusb");
|
||||
fprintf(stderr, "\n\nUsage: usbreset /dev/bus/usb/<Bus>/<Device>\n");
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
filename = argv[1];
|
||||
|
||||
fd = open(filename, O_WRONLY);
|
||||
if (fd < 0) {
|
||||
perror("Error opening output file");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Resetting USB device %s\n", filename);
|
||||
rc = ioctl(fd, USBDEVFS_RESET, 0);
|
||||
if (rc < 0) {
|
||||
perror("Error in ioctl");
|
||||
return 1;
|
||||
}
|
||||
printf("Reset successful\n");
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user