Skip to content

Instantly share code, notes, and snippets.

View rdapaz's full-sized avatar

ricdeez rdapaz

View GitHub Profile
@rdapaz
rdapaz / DumpSchemaFromSqliteDB.py
Created December 21, 2021 07:29
Dump Schema from SQLITE database
# Dump schema from table
"""
Credit to Wilfredo Sánchez Vega who posted this answer
on stackoverflow
https://stackoverflow.com/questions/11996394/is-there-a-way-to-get-a-schema-of-a-database-from-within-python
"""
import sqlite3
import re
import os
from pathlib import Path
@rdapaz
rdapaz / officePytthonScript.py
Created March 12, 2022 00:27
Fix pycom errors
def GetWin32comObject(object_name='Word.Application'):
from win32com import client
try:
object = client.gencache.EnsureDispatch(object_name)
except AttributeError:
# Corner case dependencies.
import os
import re
import sys
import shutil
@rdapaz
rdapaz / VisioAutomation.py
Created March 30, 2022 18:35
VisioAutomation
import os
import win32com.client
import re
import pprint
def pretty_print(o):
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(o)
@rdapaz
rdapaz / ip.py
Created April 20, 2022 09:35 — forked from ChrisTM/ip.py
Convert IPv4 addresses to and from integers
"""
Convert between various representations of an IPv4 address.
`ip` refers to a dotted string, like: `'127.0.0.1'`.
`octets` are indexables, like `(127, 0, 0, 1)`.
`int` is the integer representation, like `2130706433`.
Written for Python 2.7.
"""
@rdapaz
rdapaz / fix-eve-NG-webadmin.md
Created April 26, 2022 15:29
Restore web admin username and password on eve-NG

Eve-NG

Problem

Trying to reset admin password on eve-ng according to FAQs. However, FAQs seem to be cutting short the bit instructing users on how to repopulate the users table after deleting its contents:

For Professional Edition (if you have EVE Pro Version 2.0.4-97 and higher), type the next 2 command lines in EVE NG CLI as Root user:

@rdapaz
rdapaz / how-to-add-image-to-gist.md
Created April 26, 2022 15:53 — forked from mroderick/how-to-add-image-to-gist.md
How to add an image to a gist

How to add an image to a gist

  1. Create a gist if you haven't already.
  2. Clone your gist:
    # make sure to replace `<hash>` with your gist's hash
    git clone https://gist.github.com/<hash>.git # with https
    git clone [email protected]:<hash>.git     # or with ssh
@rdapaz
rdapaz / disa_stig_viewer.py
Created May 4, 2022 06:24
DISA STIG Viewer
### DISA STIGS standards are distributed in XML and XSLT file pairs. Under IE, it was possible to open the XSLT and then open the XML, where the latter
### would be properly formatted. With IE no longer in use, this script can generate the html from a pair.
### TODO: Automate so that it generates for all entries in the archived zip (zip of zips)
### -----------------------------------------------------------------------------------------------------
from lxml import etree
path_xml = 'U_MS_Windows_10_STIG_V2R3_Manual-xccdf.xml'
path_xslt = 'STIG_unclass.xsl'
dom = etree.parse(path_xml)
xslt =etree.parse(path_xslt)
@rdapaz
rdapaz / Instructions.md
Last active June 11, 2022 14:18
Generate Cisco secret with salt

This is the Linux command to precompute a secret for a Cisco switch / router

username cisco privilege 15 secret 5 $1$6527$WiNuPN8KMuraxwrpieZhK1

The salt is specified where the dots are $1$....$

$ openssl passwd -1 -salt pdQG -table foobar
foobar $1$pdQG$0WzLBXV98voWIUEdIiLm11
@rdapaz
rdapaz / temp.sql.md
Created September 21, 2022 03:36
List all column names in sqlite3 database

This is the sql query that does the trick

select * from pragma_table_info('<table_name>') as tblInfo

Don't forget the quotes!

@rdapaz
rdapaz / visiohacks.md
Created February 8, 2023 03:01
Visio hacks for drawings

Visio hacks

A3 Page Dimensions

width: 420mm
height: 297mm

Visio Shapesheet Info