Skip to content

Instantly share code, notes, and snippets.

View subtosilencio's full-sized avatar
🎯
Focusing

Paulo Souza subtosilencio

🎯
Focusing
View GitHub Profile
@subtosilencio
subtosilencio / estados_br.py
Created June 4, 2023 14:59
Python estados BR UFs
estados_uf = ['AC', 'AL', 'AP', 'AM', 'BA', 'CE', 'DF', 'ES',
'GO', 'MA', 'MT', 'MS', 'MG', 'PA', 'PB', 'PR',
'PE', 'PI', 'RJ', 'RN', 'RS', 'RO', 'RR', 'SC',
'SP', 'SE', 'TO']
estados_dict = {'AC': 'Acre', 'AL': 'Alagoas', 'AP': 'Amapá',
'AM': 'Amazonas', 'BA': 'Bahia', 'CE': 'Ceará',
'DF': 'Distrito Federal', 'ES': 'Espírito Santo',
'GO': 'Goías', 'MA': 'Maranhão', 'MT': 'Mato Grosso',
'MS': 'Mato Grosso do Sul', 'MG': 'Minas Gerais',
import requests
api_key = "XXX" #Google API
cse_id = "XXX" #Search engine ID
q = "information"
def google_query(q, api_key, cse_id):
''' Use Google custom search without google-api-python-client'''
rData = []
@subtosilencio
subtosilencio / returnDNS.py
Created August 25, 2021 23:57
Return DNS servers of a domain
import subprocess
def returnDNS(domain):
''' Return DNS servers of a domain '''
proc = subprocess.Popen(["dig +short +time=2 -t ns " +domain],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
(out, err) = proc.communicate()
return sorted(out.decode('utf-8').split())
@subtosilencio
subtosilencio / checkBlacklist.py
Created August 25, 2021 23:54
Check if domain is listed "dbl.spamhaus.org"
import socket
def checkBlacklist(domain):
''' Check if domain is listed "dbl.spamhaus.org" '''
rCode = ''
rTXT = {"127.0.1.2": "spam domain",
"127.0.1.4": "phish domain",
"127.0.1.5": "malware domain",
"127.0.1.6": "botnet C&C domain",
@subtosilencio
subtosilencio / is_valid_ipv4_address.py
Created August 25, 2021 23:19
Verify IP Address Validity
import socket
def is_valid_ipv4_address(address):
''' Verify IP Address Validity '''
try:
socket.inet_pton(socket.AF_INET, address)
except AttributeError: # no inet_pton here, sorry
try:
socket.inet_aton(address)
#!/usr/bin/python3
# Linux Ubuntu Gnome
# Correction for Pyperclip
# Copy info to clipboard without installing anything
from gi.repository import Gtk, Gdk
def copy_to_clipboard(msg):
''' Copy `msg` to the clipboard '''