Skip to content

Instantly share code, notes, and snippets.

@lopes
lopes / nferen.sh
Last active August 7, 2024 13:53
Renames NFe (Brazilian invoices) files in PDF format according to data in the document. #shell #shellscript #pdf #file #management
#!/bin/sh
#
# Reads a Brazilian "Nota Fiscal Eletrônica" in PDF format,
# figures out what is it competence (the reference in time
# for that document), and then renames the file using this
# data, like: %Y%m[-COUNT].pdf.
#
# Note: the regex may differ according the format used in
# the PDF file (data disposition), so it should be
# adjusted accordingly.
@lopes
lopes / teslacoil.py
Last active August 7, 2024 13:54
Monitors some log files and send new entries to syslog. #python #syslog #log #forwarder #diff #siem
#!/usr/local/bin/python3
'''
Monitors some log files and send new entries to syslog.
This script requires a config file to import paths to the files.
The main concept is that there are a repository with log files
(which I call 'source files') and an auxiliary repository of
files ('working files').
The idea here is to create a copy of source files in the work
directory, then calculating the diff between the source files
@lopes
lopes / bookepr.sh
Last active August 7, 2024 13:54
Packs and unpacks sensitive data in a more secure fashion. #shell #shellscript #cryptography
#/bin/sh
#bookepr.sh
#
# Packs and unpacks sensitive data in a more secure fashion.
# Read $HELP for usage tips.
#
# Author: José Lopes <lopes.id>
# License: MIT
# Date: 2021-09-28
##
@lopes
lopes / checkip.sh
Last active August 7, 2024 13:55
Fetches IP address data on 3 services for Infosec Engineers. #shell #shellscript #ip #reputation #api
#!/usr/bin/env bash
# In SOC, when an external IP address is involved in an incident,
# we check it to try to identify the owner and if there is any
# incident related to that address. A few sites in internet
# offer this service, such as AbuseIPDB (https://www.abuseipdb.com/),
# Greynoise (https://www.greynoise.io/), and
# VirusTotal (https://www.virustotal.com/).
#
# Author.: José Lopes <lopes.id>
@lopes
lopes / cortex-get-alerts.sh
Last active August 7, 2024 13:56
Retrieves alerts from Cortex XDR. #shell #shellscript #paloalto #cortex #edr #xdr #alert #api
#!/bin/sh
# Retrieves alerts from Cortex XDR.
# PARAMETERS:
# - $1: First item (start)
# - $2: Number of items at each round (must be <= 100)
# - $3: Number of pages desired (number of rounds)
# REQUIRES:
# - API key and its ID from Cortex XDR
# - Standard Authentication for the API key
@lopes
lopes / lobotomy.py
Last active December 12, 2024 12:06
Simple script to test the Cortex API with Advanced and Standard keys #python #paloalto #cortex #edr #xdr #alert #api
'''
A simple script to test the Cortex API with Advanced and Standard keys.
It uses solely the Python 3 Standard Library, so no additional packages are needed.
USAGE
python3 lobotomy.py KEYID KEY KEYTYPE FQDN ENDPOINT START COUNT PAGES
EXAMPLE
python3 lobotomy.py \
007 \
@lopes
lopes / misp-parser.rb
Last active August 7, 2024 13:57
MISP parser for Chronicle SIEM using Logstash format. #misp #chronicle #parser #logstash
# Product: MISP Threat Intelligence
# Category: Information Security
# Supported Format: JSON
# Reference: https://medium.com/@thatsiemguy/how-to-integrate-misp-and-chronicle-siem-9e5fe5fde97c
# Last Updated: 2024-06-01
filter {
##
# BASIC VARIABLES ASSERTION AND FIELDS EXTRACTION
#
@lopes
lopes / moth.py
Last active October 29, 2024 12:49
Convert Kindle or O'Reilly annotations to JSON or Markdown format. #python #file #manager #kindle #oreilly #annotation
#!/usr/bin/env python3
#moth.py
'''
Convert Kindle or O'Reilly annotations to JSON or Markdown format.
Usage:
moth.py -i <input> -o <output> [-s <source>] [-f <format>]
Example:
@lopes
lopes / torpids.py
Last active August 7, 2024 13:58
Connects to the Tor Project's exit-addresses page and parses the exit node data into JSON format. #python #tor #exitnodes #web #scrapper #parser
#!/usr/bin/env python3
#torpids.py
'''
Connects to the Tor Project's exit-addresses page and parses the
exit node data into JSON format.
Data is fetched from: https://check.torproject.org/exit-addresses
Data is "Node ID-centric" in Tor Project's page, but here it is
@lopes
lopes / chronicle-list-cleaner.py
Last active August 7, 2024 13:58
Cleans up lines in the reference lists in Chronicle SIEM with expired dates. #chronicle #gcp #functions #python #siem #list #management
'''
Cleans up lines in the reference lists in Chronicle SIEM with expired dates.
This script can be used to clean up some or all Reference Lists in Chronicle SIEM.
It scans each list and removes expired lines with the same pattern it is set to
monitor. Lines outside this pattern are just ignored. The pattern is:
<value> // expires:YYYY-MM-DD