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:
71
archive/experimental/flm.py
Executable file
71
archive/experimental/flm.py
Executable file
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/python3
|
||||
import sys
|
||||
import re
|
||||
|
||||
ignore_case=True
|
||||
|
||||
pattern=str(sys.argv[1])
|
||||
if ignore_case:
|
||||
pattern=pattern.lower()
|
||||
filename=str(sys.argv[2])
|
||||
shortpattern=""
|
||||
print("Pattern is '%s'" % pattern)
|
||||
chars={}
|
||||
|
||||
for char in pattern:
|
||||
if not char in chars:
|
||||
newchar={}
|
||||
newchar['char']=char
|
||||
newchar['count']=pattern.count(char)
|
||||
newchar['idx']=[m.start() for m in re.finditer(re.escape(char),pattern)]
|
||||
print(char)
|
||||
#print("Char '%s' occurs %d times in pattern %s" % (c,newchar['count'],newchar['idx']))
|
||||
chars[char]=newchar
|
||||
shortpattern=shortpattern + char
|
||||
try:
|
||||
f=file(filename,'r')
|
||||
except:
|
||||
print("[-] Can't open File %s" % filename)
|
||||
exit(1)
|
||||
|
||||
print(shortpattern)
|
||||
longest_match_yet=0
|
||||
def get_char():
|
||||
return f.read(1).lower() if ignore_case else f.read(1)
|
||||
|
||||
while longest_match_yet<len(pattern):
|
||||
# read_a_char=f.read(1)
|
||||
read_a_char=get_char()
|
||||
if read_a_char in shortpattern and read_a_char in chars:
|
||||
#candidate
|
||||
for index in chars[read_a_char]['idx']:
|
||||
#lets see if its long enough
|
||||
possible_length=len(pattern) - index
|
||||
if possible_length>longest_match_yet:
|
||||
sub_pattern=pattern[(index+1):]
|
||||
match_so_far=read_a_char
|
||||
offset=f.tell()
|
||||
# print("Possible new Match starting with %s found at %d" % (read_a_char,offset))
|
||||
# print("trying to find rest of pattern '%s'" % sub_pattern)
|
||||
x=1
|
||||
for char_to_compare in sub_pattern:
|
||||
# next_char=f.read(1)
|
||||
next_char=get_char()
|
||||
if not read_a_char:
|
||||
print("No more Chars to consume in File")
|
||||
break
|
||||
# print("comparing %s <> %s (%d)" % (next_char,char_to_compare,x))
|
||||
if next_char != char_to_compare:
|
||||
break
|
||||
match_so_far=match_so_far+next_char
|
||||
x=x+1
|
||||
# print("matching endet with %d matching chars (%d)" % (x,longest_match_yet))
|
||||
if x > longest_match_yet:
|
||||
#new longest Match
|
||||
print("found new longest match %s at %d" % (match_so_far,offset))
|
||||
longest_match_yet=x
|
||||
f.seek(offset)
|
||||
|
||||
if not read_a_char:
|
||||
print("No more Chars to consume in File")
|
||||
break
|
||||
24
archive/experimental/fuzz.sh
Executable file
24
archive/experimental/fuzz.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
pattern='\b(([01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}([01]?\d{1,2}|2[0-4]\d|25[0-5])\b'
|
||||
#count ips in log
|
||||
count=$(cat $1 | grep -Po $pattern | sort -u | wc -l)
|
||||
#create ip_map for translation of IPs
|
||||
paste <(cat $1 | grep -Po $pattern | sort -u) <(paste <(shuf <(for i in {0..255};do echo $i; done)) <(shuf <(for i in {0..255};do echo $i; done)) <(shuf <(for i in {0..255};do echo $i; done)) <(shuf <(for i in {0..255};do echo $i; done)) | tr "\t" "." | head -n $count) > ${1}.ip_map
|
||||
|
||||
#awk script to replace IPs
|
||||
awk_script='
|
||||
NR == FNR {
|
||||
rep[$1] = $2
|
||||
next
|
||||
}
|
||||
|
||||
{
|
||||
for (key in rep)
|
||||
gsub(key, rep[key])
|
||||
print
|
||||
}
|
||||
'
|
||||
#OUTPUT
|
||||
cat $1 | awk "$awk_script" ${1}.ip_map -
|
||||
|
||||
echo "Lookup-Table is stored in ${1}.ip_map" >&2
|
||||
18
archive/experimental/hydrogentest.py
Normal file
18
archive/experimental/hydrogentest.py
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/python3
|
||||
a="ksabvdkbvksajbvkjsabvkjsabvkjabsvkjsabvbvghahfksajfkjhcxvsLHREFIsdfsdfsdfasdfasdfasfd"
|
||||
b="kucasdhkausughaksdflsad iajfdaslfdlgajldsag asldivclsadgnaksndglkasdjasdvc"
|
||||
def longest_common_substring(s1, s2):
|
||||
m = [[0] * (1 + len(s2)) for i in range(1 + len(s1))]
|
||||
longest, x_longest = 0, 0
|
||||
for x in range(1, 1 + len(s1)):
|
||||
for y in range(1, 1 + len(s2)):
|
||||
if s1[x - 1] == s2[y - 1]:
|
||||
m[x][y] = m[x - 1][y - 1] + 1
|
||||
if m[x][y] > longest:
|
||||
longest = m[x][y]
|
||||
x_longest = x
|
||||
else:
|
||||
m[x][y] = 0
|
||||
return s1[x_longest - longest: x_longest]
|
||||
|
||||
print(longest_common_substring(a, b))
|
||||
171
archive/experimental/kv.py
Normal file
171
archive/experimental/kv.py
Normal file
@@ -0,0 +1,171 @@
|
||||
import sys
|
||||
from pyparsing import *
|
||||
from icecream import ic
|
||||
|
||||
sys.setrecursionlimit(3000)
|
||||
ParserElement.enablePackrat()
|
||||
ppc = pyparsing_common
|
||||
integer = ppc.integer
|
||||
variable = Word(alphas, exact=1)
|
||||
operand = integer | variable
|
||||
|
||||
undop = Literal("*")
|
||||
oderop = Literal("+")
|
||||
notop = Literal("!")
|
||||
|
||||
expr = infixNotation(
|
||||
operand,
|
||||
[
|
||||
(notop, 1, opAssoc.RIGHT),
|
||||
(undop, 2, opAssoc.LEFT),
|
||||
(oderop, 2, opAssoc.LEFT),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class operation():
|
||||
|
||||
def _unpack(self,data):
|
||||
if isinstance(data,str):
|
||||
if len(data) == 1:
|
||||
return data
|
||||
else:
|
||||
raise ValueError
|
||||
else:
|
||||
return operation(data)
|
||||
|
||||
def __init__(self,data) -> None:
|
||||
if isinstance(data,str):
|
||||
data=expr.parseString(data.lower().strip()).asList()
|
||||
|
||||
self.operands = []
|
||||
self.operator = ""
|
||||
if isinstance(data,list):
|
||||
if len(data) == 1:
|
||||
data = data[0]
|
||||
|
||||
if isinstance(data,list):
|
||||
if len(data) == 2:
|
||||
self.operator = data[0]
|
||||
self.operands.append(self._unpack(data[1]))
|
||||
|
||||
if len(data) >2:
|
||||
self.operator = data[1]
|
||||
for x in data:
|
||||
if x == self.operator:
|
||||
continue
|
||||
else:
|
||||
self.operands.append(self._unpack(x))
|
||||
else:
|
||||
raise ValueError
|
||||
|
||||
|
||||
def __tt(vars):
|
||||
if len(vars) == 1:
|
||||
yield {vars[0] : False}
|
||||
yield {vars[0] : True}
|
||||
else:
|
||||
for rv in operation.__tt(vars[1:]):
|
||||
yield {vars[0] : False, **rv }
|
||||
yield {vars[0] : True, **rv }
|
||||
|
||||
|
||||
|
||||
def print_tt(self):
|
||||
myvars = self.get_vars()
|
||||
print(" " + " ".join(myvars)+ " Y")
|
||||
print("--" * len(myvars) + "-----")
|
||||
tt=operation.__tt(myvars)
|
||||
for line in tt:
|
||||
r=[f"{'1' if line[x] else '0'}" for x in line]
|
||||
result="1" if self.solve(line) else "0"
|
||||
print(" " + " ".join(r) + " " + result)
|
||||
|
||||
|
||||
|
||||
def __repr__(self) -> str:
|
||||
if self.operator == "!":
|
||||
return f"NICHT {self.operands[0]}"
|
||||
else:
|
||||
if self.operator == "*":
|
||||
return "(" + " UND ".join([str(x) for x in self.operands]) + ")"
|
||||
|
||||
if self.operator == "+":
|
||||
return "(" + " ODER ".join([str(x) for x in self.operands]) + ")"
|
||||
|
||||
def solve(self,values):
|
||||
for vary in self.get_vars():
|
||||
if not vary in values:
|
||||
raise KeyError
|
||||
if self.operator == '!':
|
||||
if isinstance(self.operands[0],operation):
|
||||
return not self.operands[0].solve(values)
|
||||
else:
|
||||
return not values[self.operands[0]]
|
||||
|
||||
if self.operator == '*':
|
||||
result = True
|
||||
for operand in self.operands:
|
||||
if isinstance(operand,operation):
|
||||
result = result and operand.solve(values)
|
||||
else:
|
||||
result = result and values[operand]
|
||||
return result
|
||||
|
||||
if self.operator == '+':
|
||||
result = False
|
||||
for operand in self.operands:
|
||||
if isinstance(operand,operation):
|
||||
result = result or operand.solve(values)
|
||||
else:
|
||||
result = result or values[operand]
|
||||
return result
|
||||
|
||||
|
||||
|
||||
def get_vars(self):
|
||||
vars = []
|
||||
for x in self.operands:
|
||||
if isinstance(x,operation):
|
||||
vars += x.get_vars()
|
||||
else:
|
||||
vars.append(x)
|
||||
return list(dict.fromkeys(vars))
|
||||
|
||||
|
||||
@property
|
||||
def hasop(self):
|
||||
return len(self.operator)>0
|
||||
|
||||
|
||||
|
||||
|
||||
test = [
|
||||
"(a*b+(a*(!c+b))*c)",
|
||||
"a*b+(a*(!c+b)*c)",
|
||||
"a *b+ ( a * ( ! c + (b) ) *c)",
|
||||
"a*b+c+d",
|
||||
"a*b+c",
|
||||
"!a*!(a+b*!c)",
|
||||
]
|
||||
|
||||
testval={'a':True,'b':False,'c':True, 'd':False}
|
||||
|
||||
def tt(vars):
|
||||
if len(vars) == 1:
|
||||
yield {vars[0] : False}
|
||||
yield {vars[0] : True}
|
||||
else:
|
||||
for rv in tt(vars[1:]):
|
||||
yield {vars[0] : False, **rv }
|
||||
yield {vars[0] : True, **rv }
|
||||
|
||||
|
||||
|
||||
|
||||
for t in test:
|
||||
ic(t)
|
||||
c=operation(t)
|
||||
c.print_tt()
|
||||
|
||||
|
||||
18
archive/experimental/lpic.sh
Executable file
18
archive/experimental/lpic.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
index=0
|
||||
cat $@ | hxselect .qtext -s "@TKE@" | tr -d "\n" | tr -s " " | sed -e 's/@TKE@/\n/g' | while read block; do
|
||||
(( index++ ))
|
||||
echo "Frage $index"
|
||||
echo "=================="
|
||||
frage=$(echo $block | hxnormalize -e | sed -ne '/div class=qtext/,/div class=answer/p' | html2text)
|
||||
echo $frage
|
||||
echo "Antworten:"
|
||||
answ=$(echo $block | hxnormalize -e | hxselect .answers )
|
||||
echo $answ
|
||||
echo "Erklärung:"
|
||||
expl=$(echo $block | hxnormalize -e | hxselect .explanation )
|
||||
echo $expl
|
||||
echo "=================="
|
||||
echo "=================="
|
||||
|
||||
done
|
||||
17
archive/experimental/matplottest.py
Normal file
17
archive/experimental/matplottest.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
x = np.linspace(0, 6*np.pi, 100)
|
||||
y = np.sin(x)
|
||||
|
||||
# You probably won't need this if you're embedding things in a tkinter plot...
|
||||
plt.ion()
|
||||
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111)
|
||||
line1, = ax.plot(x, y, 'r-') # Returns a tuple of line objects, thus the comma
|
||||
|
||||
for phase in np.linspace(0, 10*np.pi, 500):
|
||||
line1.set_ydata(np.sin(x + phase))
|
||||
fig.canvas.draw()
|
||||
fig.canvas.flush_events()
|
||||
Reference in New Issue
Block a user