Skip to content

Instantly share code, notes, and snippets.

@david-bla
david-bla / logRace.py
Created January 26, 2022 21:01
check all files in current dir that ends with ".log" and count their lines.... every second
#!/usr/bin/env python3
import os
import time
initRanks = {}
ranks = {}
while True:
for file in os.listdir("./"):
@david-bla
david-bla / addTimes.py
Created January 26, 2022 20:59
QnD Script to add times (hh:mm)
#!/usr/bin/env python3
h = 0
m = 0
while True:
inp = input("+ ")
h += int(inp.split(":")[0])
m += int(inp.split(":")[1])
if m > 59:
h += 1
@david-bla
david-bla / js_in_jpg_polygot.py
Created March 28, 2021 20:19
tried to inc js in jpg
#!/usr/bin/env python3
import struct
output = bytearray()
js_comment = b"/*"
js_comment_close = b"*///"
def jpgComment(msg):
jpg_comment = b"\xff\xfe"
length = struct.pack(">h",len(msg))
@david-bla
david-bla / get_ipDnsUser_from_utmlog.py
Created January 12, 2021 19:09
cat utm01.log | get_proxy_users_utm_http_log
#!/usr/bin/env python3
import re, socket, fileinput, csv, os
regex = re.compile(r'action\=\"pass\".*srcip\=\"([^\"]*)\".*user\=\"([^\"]*)\"')
output = {}
def ip_resolve(ip):
try:
data = socket.gethostbyaddr(ip)
host = repr(data[0])
description = [[
Attempts to retrieve all valid usernames from the HTTP component of Carel
Pl@ntVisor (CarelDataServer.exe).
]]
---
-- @usage
-- nmap --script http-carel-data-server-users -p <port> <host>
--
-- @output
@david-bla
david-bla / ship.py
Created November 6, 2020 21:09
ship short for show ip - qnd script making "ip addr" output readable (ipv4)
#!/usr/bin/env python3
import subprocess, json
returnVal = subprocess.run(args=["ip","-j","a"],capture_output=True)
jsonIpObj = json.loads(returnVal.stdout)
maxV4addr,maxV6addr=0,0
for nic in jsonIpObj:
@david-bla
david-bla / testServer.py
Created June 7, 2020 13:43
QnD server for testing poropeses on my IoT devices.
def testServer():
HOST = '0.0.0.0'
PORT = 9999
while True:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
conn, addr = s.accept()
with conn:
print('Connected by', addr)
@david-bla
david-bla / sumVideoDuration.py
Last active January 26, 2022 21:01
QD script for sum video durations using ffmpeg and python glob search pattern
#!/usr/bin/env python3
import re, glob, subprocess, sys
from datetime import datetime
if len(sys.argv) != 2:
print("Ussage: %s <search_pattern (glob)>" % sys.argv[0])
sys.exit()
def loading():