Skip to content

Instantly share code, notes, and snippets.

@fser
fser / dbz2.py
Created June 26, 2020 18:14
Uses libbz2 c-library using ctypes to decompress files.
#!/usr/bin/env python3
#
# "THE BEER-WARE LICENSE" (Revision 42):
# <fser@code-libre.org> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return.
from ctypes import *
from ctypes.util import find_library
from sys import argv, stderr, exit
- ftp.am.debian.org
- ftp.au.debian.org
- ftp.at.debian.org
- ftp.by.debian.org
- ftp.be.debian.org
- ftp.br.debian.org
- ftp.bg.debian.org
- ftp.ca.debian.org
- ftp.cl.debian.org
- ftp2.cn.debian.org
@fser
fser / push_dns_metrics.sh
Created January 23, 2020 22:57
Pushes number of zones from a master DNS into an influxDB. No rocket science, but keep this somewhere.
#!/usr/bin/env bash
NRZONES=$(rndc status | awk -F: '/number of zones/ { gsub(/ /, "", $2); print $2 }')
curl -s -XPOST 'http://10.0.1.1:8086/write?db=dns_stats' --data-binary "nrzones,type=master value=$NRZONES"
@fser
fser / client.py
Created May 24, 2018 17:44
Chronomètre le temps de réponse pour une requête HTTP et affiche le header `X-Backend-Server`
#!/usr/bin/env python
import requests
import sys
from timeit import default_timer as timer
def get_page(url):
r = requests.get(url)
return r.headers.get('X-Backend-Server', 'No backend returned')
@fser
fser / Dockerfile
Created October 3, 2017 14:13
Docker file used to build exabgp's debian package
FROM debian:stable
RUN apt-get update && apt-get install -y git-core devscripts build-essential lintian python-setuptools python-all python3-all python3-setuptools python-ipaddr python-nose python-psutil python3-nose python3-psutil
COPY build.sh /root
RUN chmod +x /root/build.sh
@fser
fser / spip2pelican.pl
Created August 20, 2017 22:24
Converts SPIP articles into Pelican static pages
#!/usr/bin/env perl
use strict;
use warnings;
use DBI;
use v5.10;
use Data::Dumper;
my $pagenum = 1;
@fser
fser / honey-passwd
Created May 12, 2017 12:17
Password dump between 02/09/17 and 05/10/17 on a public ssh honeypot
4564 123456
4315 password
3543 admin
2964 1234
2620 12345
2090 ubnt
2038 root
1802 111111
1392 000000
1346 support
@fser
fser / vlan.pl
Created October 14, 2016 22:23
Adds eth0 to the vlan 73
#!/usr/bin/env perl
use strict;
use warnings;
# https://fossies.org/dox/iproute2-4.7.0/if__vlan_8h_source.html
# struct vlan_ioctl_args {
# int cmd; /* Should be one of the vlan_ioctl_cmds enum above. */
@fser
fser / nagios-check-restart.sh
Created April 27, 2016 23:17
nagios sensor to check wether services / server needs to be restarted. It depends on checkrestart (from debian-goodies) to list packages which needs to be restarted.
#!/usr/bin/env bash
if [ -e /var/run/reboot-required ]; then
echo "error: need reboot (kernel upgrade)"
exit 2
fi
checkrestart &>/dev/null || { echo 'need checkrestart (apt-get install debian-goodies) to get the actual service list' ; exit 1; }
@fser
fser / spamers.txt
Created January 29, 2016 15:34
Top spam hostname on my website
mysql> select count(*) as c ,hostname from comment group by hostname having c > 20;
+------+----------------+
| c | hostname |
+------+----------------+
| 169 | 107.150.40.162 |
| 354 | 107.150.40.163 |
| 2199 | 142.54.172.154 |
| 722 | 142.54.172.155 |
| 26 | 142.54.172.156 |
| 385 | 142.54.172.157 |