Skip to content

Instantly share code, notes, and snippets.

View thotypous's full-sized avatar

Paulo Matias thotypous

View GitHub Profile
@thotypous
thotypous / unisolate.sh
Created December 7, 2018 12:13
Contorna o isolamento entre diferentes computadores na rede eduroam da UFSCar
#!/bin/bash
gw="$(ip route | grep -Po '^default via \K\d+\.\d+\.\d+\.\d+')"
iface="$(ip route | grep -Po '^default via \d+\.\d+\.\d+\.\d+ dev \K[^ ]+')"
local_subnet_forwarding_rule="$(ip route | grep -P "^\d+\.\d+\.\d+\.\d+/\d+ dev $iface .*? link src")"
gw_forwarding_rule="$gw $(echo "$local_subnet_forwarding_rule" | grep -Po '^\d+\.\d+\.\d+\.\d+/\d+ \K.+')"
if [[ ! -z "$local_subnet_forwarding_rule" ]]; then
set -xe
@thotypous
thotypous / eth_rawsock.py
Created November 20, 2018 19:02
Exemplo de envio e recebimento de pacotes em camada de enlace
import socket
import asyncio
import struct
ETH_P_ALL = 0x0003
ETH_P_IP = 0x0800
ICMP = 0x01 # https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers
@thotypous
thotypous / ip_rawsock.py
Last active November 6, 2018 18:16
Exemplo de envio e recebimento de pacotes em camada de rede (protocolo IPv4)
import socket
import asyncio
import struct
ETH_P_IP = 0x0800
# Coloque aqui o endereço de destino para onde você quer mandar o ping
dest_addr = '186.219.82.1'
@thotypous
thotypous / tcp_rawsock_v2.py
Last active September 29, 2018 16:47
Exemplo que aceita conexões TCP na porta 7000 e manda dados (assumindo que nunca serão perdidos)
#!/usr/bin/python3
#
# Antes de usar, execute o seguinte comando para evitar que o Linux feche
# as conexões TCP abertas por este programa:
#
# sudo iptables -I OUTPUT -p tcp --tcp-flags RST RST -j DROP
#
import asyncio
import socket
@thotypous
thotypous / cadastro_visitantes_lote.py
Last active September 10, 2018 11:42
Cadastro de visitantes em lote na Wi-Fi da UFSCar
#!/usr/bin/python3
import sys
import csv
import requests
username = '<redacted>'
password = '<redacted>'
inicio_validade = '2018-09-10T00:00:00.000Z'
fim_validade = '2018-09-17T23:59:59.999Z'
@thotypous
thotypous / tcp_rawsock.py
Created September 9, 2018 16:22
Exemplo que aceita conexões TCP na porta 7000 e ilustra o uso de timers com asyncio
#!/usr/bin/python3
#
# Antes de usar, execute o seguinte comando para evitar que o Linux feche
# as conexões TCP abertas por este programa:
#
# sudo iptables -I OUTPUT -p tcp --tcp-flags RST RST -j DROP
#
import asyncio
import socket
@thotypous
thotypous / exemplo_fluxo_quebrado_cliente.py
Last active September 16, 2018 16:17
Exemplos de implementação de camada de aplicação sobre TCP
#!/usr/bin/python3
# -*- encoding: utf-8 -*-
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('endereco', 8000))
s.send(b'A'*50000 + b'F')
s.close()
@thotypous
thotypous / keybase.md
Last active June 7, 2018 16:15
Keybase public proof

Keybase proof

I hereby claim:

  • I am thotypous on github.
  • I am thotypous (https://keybase.io/thotypous) on keybase.
  • I have a public key whose fingerprint is D07E CB5A EF63 5285 D4AC 4A50 B8C6 6205 87F3 0E55

To claim this, I am signing this object:

@thotypous
thotypous / sdaps-jbig2.py
Last active August 27, 2017 02:37
Uses https://github.com/agl/jbig2enc to generate a JBIG2-encoded PDF for each questionnaire ID
#!/usr/bin/env python2
# -*- coding: utf8 -*-
# SDAPS - Scripts for data acquisition with paper based surveys
# Copyright (C) 2008, Christoph Simon <post@christoph-simon.eu>
# Copyright (C) 2015, Benjamin Berg <benjamin@sipsolutions.net>
#
# 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.
@thotypous
thotypous / rtai_3.9.265.gd99c55e.diff
Created October 11, 2015 18:42
RTAI patch with random fixes for amd64
diff --git a/./base/math/Makefile.kbuild.orig b/./base/math/Makefile.kbuild
index d87d924..110a5b9 100644
--- a/./base/math/Makefile.kbuild.orig
+++ b/./base/math/Makefile.kbuild
@@ -7,8 +7,10 @@ EXTRA_CFLAGS += -I$(rtai_srctree)/base/include \
-D_IEEE_LIBM \
-D_ISOC99_SOURCE \
-D_SVID_SOURCE \
+ -D__USE_SVID \
$(rtai_extraopt) \