Skip to content

Instantly share code, notes, and snippets.

@7h3rAm
7h3rAm / internet.py
Last active April 26, 2021 20:57
Quick Internet Connectivity Test: Invokes a connect on Google's public DNS server: 8.8.8.8:53/TCP with a socket timeout of 1 second.
import socket
def internet(host="8.8.8.8", port=53, timeout=3):
"""
Host: 8.8.8.8 (google-public-dns-a.google.com)
OpenPort: 53/tcp
Service: domain (DNS/TCP)
"""
try:
socket.setdefaulttimeout(timeout)
@7h3rAm
7h3rAm / secs_to_human
Last active May 10, 2017 15:14
Seconds to human readable text. Inspired from https://gist.github.com/erickpatrick/3039081
#!/usr/bin/env python
def sec_to_human(secs):
units = dict({
7*24*3600: "week",
24*3600: "day",
3600: "hour",
60: "minute",
1: "second"
})
@7h3rAm
7h3rAm / capinfos.py
Last active February 25, 2024 07:47
A pure-Python implementation of Wireshark's capinfos. Supports a few important statistics but is not as exhaustive as the original capinfos tool.
from pprint import pprint
import datetime
import struct
import sys
def capinfos(filename):
# generates wireshark's capinfos like stats
# limited features
# needs additional testing
file_handle = open(filename, 'rb')
@7h3rAm
7h3rAm / circllu.py
Last active April 22, 2024 19:35
Query circl.lu API for CVE information.
#!/usr/bin/env python3
from pprint import pprint
import requests
import json
def circllu_cveinfo(cve):
customheaders = {
"User-Agent": "Some script trying to be nice :)"
}
@7h3rAm
7h3rAm / google_search.py
Created May 30, 2016 14:26
Search Google via API Client
from pprint import pprint
from googleapiclient.discovery import build
service = build("customsearch", "v1", developerKey="KEY_HERE")
def search(query):
res = service.cse().list(q=query, cx="CX_ID_HERE").execute()
if 1 <= res["queries"]["request"][0]["totalResults"]:
result = res["items"][0]
response = result["link"] + "\r\n" + result["snippet"]
else:
Verifying that "ankurtyagi.id" is my Blockstack ID. https://onename.com/ankurtyagi
@7h3rAm
7h3rAm / chrome-password-export
Last active April 26, 2021 20:56
This JS code snippet helps to extract passwords from Chrome. It's based on http://superuser.com/questions/655294/how-can-i-export-chrome-passwords/675167#675167 answer.
var out = [];
var pm = PasswordManager.getInstance();
var model = pm.savedPasswordsList_.dataModel;
console.log(model);
var pl = pm.savedPasswordsList_;
for (var i = 0; i < model.length; i++) {
PasswordManager.requestShowPassword(i);
}
alert('After you press Ok results should appear in ~5 seconds.\n' +
"If password fields are empty, try increasing the timeout in the last line," +

Keybase proof

I hereby claim:

  • I am 7h3rAm on github.
  • I am 7h3ram (https://keybase.io/7h3ram) on keybase.
  • I have a public key whose fingerprint is 761C A4F7 42BD 3DBA AC8B 5793 3DC1 CDFD C1B6 C8B2

To claim this, I am signing this object: