Skip to content

Instantly share code, notes, and snippets.

View luca-m's full-sized avatar

lucam luca-m

View GitHub Profile
@luca-m
luca-m / py-notes
Last active September 5, 2022 18:15
# >>> ACCESS TO ALL CLASSES ---------------------------------------------------
().__class__.__bases__[0].__subclasses__()
# >>> INSTIANTIATE NEW OBJECTS ------------------------------------------------
[].__class__.__class__.__new__( <TYPE> , <SUBTYPE> )
[c for c in ().__class__.__base__.__subclasses__() if c.__name__ == '<CLASSNAME>'][0]()
@luca-m
luca-m / dissect.sh
Created March 24, 2013 16:32
dissect network traffic in comfortable network bidirectional flows (source ip, source port, dest ip, dest port, timestamp)
#!/bin/bash
##
## Dissect network traffic from a PCAP file.
## Extract network bidirectional flows (source ip, source port, dest ip, dest port, timestamp) and
## store them in separate files
##
## Usage: dissect.sh <CAPTUREFILE.PCAP> <OUTPUTFOLDER>
##
## Options:
## -h, --help Display this message
@luca-m
luca-m / sh-notes
Last active December 15, 2015 08:39
A place where to put some bash snippets
#
# TSHARK OUTPUTS HEX-ENCODED DATA IN STDOUT
#
tshark -r capture.pcap -R "tcp.stream eq 3" -T fields -E separator=, -e frame.time -e ip.src -e tcp.srcport -e ip.dst -e tcp.dstport -e data
#[..]
#Mar 23, 2013 00:23:24.689578000,10.13.38.54,33124,10.13.37.54,4444,373030300a
#Mar 23, 2013 #00:23:24.689646000,10.13.37.54,4444,10.13.38.54,33124,426f726f6e206c6576656c20697320746f6f20686967683a203736343020286d61782031303030290a
#[..]
#
@luca-m
luca-m / gitupdate.py
Last active December 16, 2015 04:59
If you are used to use software downloaded from git repositories and you are tired to manually pull latest version of your favourite software, this quick script for auto-update all gits in a given folder might make you save a bunch of minutes.
#!/usr/bin/env python
#-------------------------------------------------------------
# Name: gitupdate.py
# Purpose: Update all git repositories found in subfolders.
# Author: stk
# Created: 14/04/2013
# Copyright: (c) stk
# Python Version: 2.7
# Dependencies: git,hg,svn
#-------------------------------------------------------------
#
# RSA TOOLKIT v.0.1a
#
import gmpy,string
ALPHABET=string.lowercase+" '"
#
# Factorization
#
def factorize(Num):
#
# Timing Attack Miscellaneous
#
import string
import sys
import re
import time
import threading
import httplib
alphabet=''.join([chr(i) for i in xrange(256) if chr(i) not in '!"#$&*+-/0123456789;=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^abcdefghijklmnopqrstuvwxyz|' and i != 0])
def filt(s):
return s.translate(ident,'!"#$&*+-/0123456789;=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^abcdefghijklmnopqrstuvwxyz|')
def obfNum(n):
""" Obfuscate a number """
if n==0:
return "([]<{})"
elif n==1:
@luca-m
luca-m / useful-commands
Last active December 18, 2015 23:29
A collection of useful commands.
# convert images
convert *.pgm %d.jpg
# video from image sequence
avidemux2_cli --video-codec DV --fps 1 --load jpg/*.jpg --save out.avi --quit
# No ASLR
sysctl -w kernel.randomize_va_space=0
paxctl -x <program>
setarch `arch` -R <program>
@luca-m
luca-m / battery-mon.sh
Last active December 19, 2015 11:19
Lightweight battery monitor.Using lightweight desktop environment such as awesome, i3 or xmonad may be really comfortable for certain aspect, but there are also few thing that you may miss from a regular desktop environment.This is the case of some kind of warning pop-up which indicates you that your battery is going dead. How many times do you …
#!/bin/bash
#
# Print battery warning
#
VERBOSE=0
SUSPEND_CMD=/home/stk/.i3/suspend.sh
TIMEOUT=120
DEVNAME='/org/freedesktop/UPower/devices/battery_BAT0'
ALERT_THR=15
@luca-m
luca-m / .Xresources
Created July 9, 2013 13:52
.Xresources for urxvt, clipboard CTRL+SHIFT+(C|V|X), CTRL+Arrow for word cursor movement
!! cd /usr/lib/urxvt/perl; git clone https://github.com/muennich/urxvt-perls .
!! Perl extensions
URxvt.perl-ext-common: default,clipboard,matcher,keyboard-select
!! URLs
URxvt.keysym.C-U: perl:url-select:select_next
URxvt.url-launcher: /usr/bin/firefox -new-tab
URxvt.underlineURLs: True
URxvt.matcher.button: 1