Skip to content

Instantly share code, notes, and snippets.

View XayOn's full-sized avatar
🐍

David Francos XayOn

🐍
View GitHub Profile
@XayOn
XayOn / pymenu-urwid.py
Created September 22, 2013 04:26
Using some python magic, the URWID example for multiple menus, and the XDG library, I present you here a simplish-as-it-can-get ncurses application menu for all TUI lovers over the world.
import urwid
import os
from xdg import DesktopEntry
def read_menus():
"""
Read the menus and return them in an array
"""
all_menus = []
@XayOn
XayOn / bruteforce.py
Created September 19, 2013 14:44
Como hacer un brute force cracker para autenticación básica http en veinte lineas de python, con coloricos y todo. Argumentos: <fichero de usuarios> <fichero de contraseñas> <url>
#!/usr/bin/env python
from termcolor import colored
import sys, mechanize
with open(sys.argv[1]) as userfile:
users = [u.strip() for u in userfile.readlines()]
with open(sys.argv[2]) as pwfile:
passwords = [u.strip() for u in pwfile.readlines()]
for user in users:
@XayOn
XayOn / install_vim_experimental.sh
Created July 19, 2013 07:23
Install experimental vim
echo "deb http://ftp.fr.debian.org/debian/ experimental main contrib non-free" > /etc/apt/sources.list.d/experimental.conf"
apt-get update
apt-get install -texperimental vim
@XayOn
XayOn / security_limits.sh
Created July 17, 2013 07:48
security limits
echo -e '\nmysql soft nofile 100000\bmysql hard nofile 200000' >> /etc/security/limits.conf
@XayOn
XayOn / mysql-large.sh
Created July 17, 2013 07:22
Put mysql large default config on debian and derivatives
zcat /usr/share/doc/mysql-server-5.5/examples/my-large.cnf.gz > /etc/mysql/my.cnf
# Now, edit the file and in [mysql] section, put:
user = mysql
# And restart the server
service mysql restart
@XayOn
XayOn / mysql_checker.sh
Created July 17, 2013 06:59
mysl checker
#!/bin/bash
# This is for clarity on this example, usually for this I'd use directly $1 $2 $3 in the mysql call
user=$1;
pass=$2;
host=$3;
echo "select * from users limit 1" | mysql -u$user -p$pass $db || {
mail -s "El servidor mysql se ha caido" [email protected] <<< "Mysql ha fallado a fecha `date`"
echo "show processlist" | mysql -u$user -p$pass $db > /var/log/mysql_ps_crashlog_`date +%m-%d-%y_%H_%M`.log
}
@XayOn
XayOn / Pdf_processor.sh
Created July 12, 2013 08:10
parallel processing PDF files using a specified number of paralellized processes.
tmp=`mktemp`;
[[ $2 ]] && {
while read filename; do pdf2txt "${filename}" -o "${filename}.txt"; done <"$2"
} || {
find . -name "*pdf" -print > $tmp;
nlineas=$(( $(wc -l < $tmp) / $1 ))
for i in $(seq 0 $nlineas); do
[[ $i == $nlineas ]] && {
tail -n+$(( $i * $1 )) $tmp > ${tmp}_${i}
@XayOn
XayOn / Stealth_ scrapper.py
Last active December 19, 2015 16:18
Better scrappery script
import sys
import mechanize
from random import choice
class Scrapper(object):
"""
Main scrapper object.
Use self.do_anonymous_scrapping after setting self.url
(or use scrap() function)
@XayOn
XayOn / setup_anon_scrapper.py
Created July 1, 2013 08:56
Get a almost completly anonymous and transparent scrapper
def setup_anonymous_scrapper(self):
self.browser = mechanize.Browser()
self.browser.set_handle_robots(False)
self.browser.set_handle_refresh(False)
self.browser.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
self.browser.set_proxies({"http": self.proxy })
self.data = self.browser.open(self.url).read()
@XayOn
XayOn / random_proxy.py
Created July 1, 2013 08:53
Export a proxy property on a class wich gets a random proxy from a proxies.txt file.
@property
def proxy(self):
with open('proxies.txt') as proxy_file:
return choice(proxy_file.readlines())