Skip to content

Instantly share code, notes, and snippets.

View aolle's full-sized avatar

Àngel Ollé Blázquez aolle

View GitHub Profile
@aolle
aolle / test.py
Last active April 10, 2018 04:49
A python test for an interview #1 - LinkedIn
import re
s = 'aaabbbaaa'
d = tuple((c[0], len(c)) for c in [m.group(0) for m in re.finditer(r"(\w)\1*", s)])
l = [(str(t[1]),t[0]) for t in d]
''.join(str(j) for i in l for j in i)
code1.py
import re
s = 'aaaaabbbbccccccaaaaaaa'
d = tuple((c[0], len(c)) for c in [m.group(0) for m in re.finditer(r"(\w)\1*", s)])
l = [(str(t[1]),t[0]) for t in d]
''.join(str(j) for i in l for j in i)
Coarse grained benchmark time: 0.028s
@aolle
aolle / mod_prv.c
Created August 17, 2016 09:56
Apache custom module for privilege escalation
/*
** mod_prv.c -- Apache sample prv module
** [Autogenerated via ``apxs -n prv -g'']
**
** To play with this sample module first compile it into a
** DSO file and install it into Apache's modules directory
** by running:
**
** $ apxs -c -i mod_prv.c
**
main() {
int *a;
*a += 1;
}
@aolle
aolle / ssh-pivoting.md
Last active April 10, 2018 06:31
SSH pivoting

SSH pivoting

Scenario:

Origin => MachineA => FW => MachineB

We've access to MachineA through SSH and MachineA has access to MachineB through FW. We want to reach the remote port 5000 of MachineB; We'll map our localhost 5000 port to remote 5000 port of MachineB through the MachineA.

The SSH command will be:

@aolle
aolle / compression.md
Last active February 22, 2023 01:57
7z/tar/zip/gzip cheatsheet

7z

Compresión máxima

$ 7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on archive.7z dir1

Copy mode (sin compresión)

@aolle
aolle / LXC.md
Last active April 10, 2018 07:05
LXC notes

Instal·lar LXC

$ sudo apt install lxc bridge-utils libvirt-bin debootstrap

Crear contenidor LXC

@aolle
aolle / sed.md
Created August 17, 2016 13:13
sed cheatsheet

Extreure línies entre dues dates

Molts cops es necessiten extreure les línies entre dues dates concretes de fitxers de log. Per fer-ho, podem utilitzar sed, de manera:

sed -n '/start/,/end/p' log.txt

Per exemple, a un fitxer de log on el format de la data és tipus: * [03/Dec/2015:10:32:20 -0500]*, farem:

@aolle
aolle / Dockerfile-httpd-php5
Created August 17, 2016 13:21
Custom Dokerfile httpd+php5
FROM php:5-apache
RUN apt-get update
RUN apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
libapache2-mod-security2 \
&& docker-php-ext-install -j$(nproc) iconv mcrypt pdo_mysql mysqli mysql pdo \
@aolle
aolle / run_httpd.sh
Created August 17, 2016 13:25
Docker run script for httpd+php5
#!/bin/bash
IP=xx.xx.xx.xx
docker run --name srv01-httpd \
-v ~/docker/httpd-php/config/apache2/:/etc/apache2/ \
-v ~/docker/httpd-php/config/php/:/usr/local/etc/php/ \
-v ~/docker/httpd-php/src/:/var/www/html/ \
-v ~/docker/httpd-php/logs/:/logs/ \
-v /etc/localtime:/etc/localtime:ro \