Flask register all template filters in one module

During my tests with Flask, the python web framework, I stumbled upon the challenge to register all my filters I had stored in app/util/filters.py.

My solution is the def init_app(app) function:

def filter_upper(text):
    return text.upper()
def filter_lower(text):
    return text.lower()
def init_app(app):
    for func in globals():
        if func.startswith('filter_'):
            name = func.split('_')[-1]
            app.add_template_filter(globals()[func], name)

The init_app function will search through all global members of the module for function definitions where the name starts with filter_. These functions are than registered to the flask app. The name of the filter is automatically generated from the function name.

2018/12/17 13:49 · jpk · 0 Comments · 0 Linkbacks

GIAC Reverse Engineering Malware Professional

Had my exam earlier this morning and successfully completed it. Now I am waiting for my certificate and the badge to claim.

The course to this certification is https://www.giac.org/certification/reverse-engineering-malware-grem.

Update 1: Received the digital badge today. Just click the image to view the details.

2017/09/28 10:47 · jpk · 0 Comments · 0 Linkbacks

Using multiple USB Bluetooth dongles on one linux host

When you buy cheap USB Bluetooth dongles, that they have the same device address (MAC). The tool bdaddr can be used to change these addresses.

bdaddr - Utility for changing the Bluetooth device address

	bdaddr [-i <dev>] [-r] [-t] [new bdaddr]

To change the dongles address, connect only the one you want to modify and run:

$ bdaddr F4:4E:FD:B8:A4:14

Unplug and replug the dongle, bluetoothd should now be able to configure both USB Bluetooth dongles.

2017/09/20 11:59 · jpk · 0 Comments · 0 Linkbacks

[Work around/Fix] Docker loses network connectivity after first session terminates

Recently, I had trouble setting up docker, or to be more precise: running it. Every time I started the Docker daemon, and ran something like:

$ docker run busybox ping -c 3
PING ( 56 data bytes
64 bytes from seq=0 ttl=45 time=20.118 ms
64 bytes from seq=1 ttl=45 time=23.727 ms
64 bytes from seq=2 ttl=45 time=19.803 ms

--- ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 19.803/21.216/23.727 ms

Everything worked fine, but than the container was shut down, and I tried to run this container again it failed to connect/ping.

The first thing I noticed the docker0 network interface had lost its IP address. Restarting Docker fixed this problem, but for doing a simple ping, this is not a valid option. At first I though it might be the avahi-daemon causing trouble, because I found things like

Withdrawing address record for fe80::a80e:15ff:fe76:6a1e on veth8cdefb7.
Withdrawing address record for on docker0.

in my logs. But this was just an misinterpretation of the messages, I think.

It took my I while to come up with the idea to check the routes. What I observed, when ever an container stop and is terminated the docker0 interface was also shutdown and the route for this network and device were also deleted. Starting the container again did not add the route again.

As solution I have created a docker.network configuration - as I am using systemd - to configure the network and routes properly.



2017/08/23 15:53 · jpk · 0 Comments · 0 Linkbacks

Older entries >>

Last modified: le 2010/02/02 16:56