Skip to content

Instantly share code, notes, and snippets.

import time, random
class StopWatch():
def __init__(self):
self.started = 0.0
self.stopped = 0.0
self.elapsed = 0.0
def reset(self):
self.__init__()
def start(self):
@112buddyd
112buddyd / cidr_to_regex.py
Last active June 14, 2021 07:43
Python CIDR Notation to Regex Tool
# CIDR Notation to Regex Tool
# Original: http://d.xenowire.net/cidr2regex.php
# Converted to Python by 112buddyd
def cidr_to_regex(cidr):
import re
# Validation
cidr_regex = r'^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$'
if not re.match(cidr_regex, cidr):
@112buddyd
112buddyd / pollengine.py
Last active December 4, 2015 21:40
backend script for new network monitor tool
import sqlite3, os, subprocess, datetime, sys, logging, time
from multiprocessing.pool import ThreadPool
from tqdm import *
def welcome():
print('\n')
print('╔═══╦══════════════════════════════╦═══╗')
print('║ ║ pollengine.py ║ ║')
print('║ ║ created by 112buddyd ║ ║')
print('║ ║ 2015-12-04 // v0.1 ║ ║')
@112buddyd
112buddyd / polling.py
Last active November 5, 2015 18:20
Polling script for my netmon tool
import sqlite3, datetime, subprocess, time
from multiprocessing.pool import ThreadPool
class Device(object):
instances = []
def __init__(self, id, hostname, type, ip, subnet, building, online, last_seen):
self.id = id
self.hostname = hostname
self.type = type
self.ip_address = ip
import time, threading, paramiko, getpass, logging, sys, datetime
from multiprocessing.pool import ThreadPool
"""
To Do:
-Settings file, stores number of threads and debug levels
-In get_creds, attempt to login to one device to test credentials instead of many and locking account.
-Change reporting at end to declare successful devices and failed devices.
"""
import paramiko, scp
from tkinter import *
from tkinter import ttk
from netmiko import ConnectHandler
win = Tk()
win.wm_title('Config Pusher v0.00001')
#frames
userFrame = Frame(win, width = 400, height=80)
@112buddyd
112buddyd / challenge7.py
Last active August 29, 2015 14:27
Easy Challenge #7 from reddit.com/r/dailyprogrammer
# EasyChallenge 7 - reddit.com/r/dailyprogrammer
# Convert morse code
# 10 AUG 2015
# Created a dictionary of Letter : Morse
morse = {
'A' : '.-', 'B' : '-...', 'C' : '-.-.',
'D' : '-..', 'E' : '.', 'F' : '..-.',
'G' : '--.', 'H' : '....', 'I' : '..',
'J' : '.---', 'K' : '-.-', 'L' : '.-..',