Skip to content

Instantly share code, notes, and snippets.

Avatar
📃
Also in git.rlab.be/hackan

HacKan HacKanCuBa

📃
Also in git.rlab.be/hackan
View GitHub Profile
@HacKanCuBa
HacKanCuBa / time_calc.py
Last active Jul 28, 2020
Calculate and sum time differences easily
View time_calc.py
# Copyright © 2020 HacKan
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
#
# This software is provided as-is. You are free to use, share, modify
# and share modifications under the terms of that license. Attribution
# is not required to share but is appreciated.
"""Calculate and sum time differences easily.
@HacKanCuBa
HacKanCuBa / hashlib_timing.py
Created Mar 30, 2020
Measure execution time of hashing functions from hashlib in Python3
View hashlib_timing.py
"""Time hashlib hashing functions.
Useful to help decide which one to use if time is of the escence. I still recommend
blake2 or sha384.
Copyright © 2020 HacKan <@hackancuba>
This program is free software. It comes without any warranty, to
the extent permitted by applicable law. You can redistribute it
and/or modify it under the terms of the Do What The Fuck You Want
@HacKanCuBa
HacKanCuBa / find-https-debian-archives.py
Last active Feb 27, 2020 — forked from eighthave/find-https-debian-archives.py
Script to find official Debian mirrors that support HTTPS
View find-https-debian-archives.py
#!/usr/bin/env python3
"""Find Debian HTTPS archives.
Script based on https://gist.github.com/eighthave/7285154
I made it asynchronous and parallel, so overall I measured it to be 6 times faster or more.
Requires Python 3.7+
Additional resources not exactly related to this script but could be helpful for
@HacKanCuBa
HacKanCuBa / gunicorn.py
Last active Jul 9, 2020 — forked from kodekracker/gunicorn.py
A config file of gunicorn(http://gunicorn.org/) contains fundamental configuration.
View gunicorn.py
"""Gunicorn config file.
by HacKan (https://hackan.net)
Find it at: https://gist.github.com/HacKanCuBa/275bfca09d614ee9370727f5f40dab9e
Based on: https://gist.github.com/KodeKracker/6bc6a3a35dcfbc36e2b7
Changelog
=========
See revisions to access other versions of this file.
@HacKanCuBa
HacKanCuBa / cypher.py
Created Sep 26, 2019
Python3 OTPCypher (toy module)
View cypher.py
from typing import Tuple
from typing import Union
TParam = Union[bytes, str, bytearray]
class OTPCypher:
"""One-time pad cypher (use with extreme care!).
There are several restrictions for this to work: both parameters must have
@HacKanCuBa
HacKanCuBa / crack_nid.py
Created Jul 16, 2019
Bruteforce a numeric ID from a SHA256 hash using every CPU core available
View crack_nid.py
#!/usr/bin/env python3
# ***************************************************************************
# Bruteforce a numeric ID from a SHA256 hash.
# Copyright (C) <2019> <Ivan Ariel Barrera Oro>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@HacKanCuBa
HacKanCuBa / replacing_openpgp_2019.md
Last active Jul 17, 2019
Replacing OpenPGP in 2019
View replacing_openpgp_2019.md

Replacing OpenPGP in 2019

It's 2019, and OpenPGP has to die already (for very many reasons I won't list, but see 1, 2 and 3). At least for most uses.
I'll try to list here some replacements categorized by usage (also see 5), because there's no one single-do-all app, and there shouldn't be!

All of this resurfaced because of a vuln exploited recently on SKS keyservers (that has NOTHING to do with OpenPGP nor GnuPG but yes, they're related to the environment) (see 4).

Note: only FOSS software listed (although some server-side implementations could be closed, where applicable).

Listed apps are in no particular order. You should analyze your threat model to know which one to prefer, but as a rule of thumb, go for an easy-to-use one than doesn't let you make a mistake an lose security.

@HacKanCuBa
HacKanCuBa / settings.py
Last active Mar 20, 2020
Django 2 + REST Framework 3 generic settings: it uses env vars with mostly safe defaults (replace PROJNAME for the name of your project; read through the settings and change what you need)
View settings.py
"""
Django settings for PROJNAME project.
Generated by 'django-admin startproject' using Django 2.1.5.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
@HacKanCuBa
HacKanCuBa / cached.py
Last active Nov 8, 2019
Django Cached: simple cache abstract classes to create and use cached objects.
View cached.py
"""Handle object caching and data retrieval from API endpoints.
These abstract classes makes it easy to use Django's cache with a custom
object, and are very flexible. It support slots natively, and logs cache
hits/misses.
:Requirements:
- Django 2.0+
- Python 3.6+
View connectors.py
"""Wrappers around Python 3 Requests library.
This lib will log errors, warnings and request duration, not raising any
exception: in such error cases, an empty dict is returned. To identify, if
necessary, that there where errors, a with_error flag must be set in the
arguments so that the methods return a tuple in the form of
(response_data: any, error: bool).
If there's any response expected from the endpoint, it will be returned
JSON-converted as-is, which means it's either valid JSON (string, number,
You can’t perform that action at this time.