Skip to content

Instantly share code, notes, and snippets.

View mike-pt's full-sized avatar

Miguel C mike-pt

  • Oporto, Portugal
View GitHub Profile
@mike-pt
mike-pt / sucuri-failedlogins2pf.py
Last active March 6, 2017 15:39
simple parse tool for WP sucuri Plugin (grabs failed logins so they can be added to a firewall)
#!/usr/bin/env python
import sys
import json
filename = sys.argv[1]
data = []
limit_attempts = 2
f = open(filename, 'r').readlines()
f.pop(0)
#
# Thanks: http://cryptofroot.hateblo.jp/entry/20121025/1351105690
# for ksh substition alternative for PWD
# ${PWD/#$HOME/\~} would not work in NetBSD's ksh version
if [ `id -u` == 0 ]; then
PS1='$USER@${HOST%%.*}: ($([[ "${PWD#$HOME}" !!= "$PWD" ]] && print -n "~${PWD#$HOME}" || print -n "$PWD"))# '
else
# Remove last trailing slash from $HOME
# only needed for normal user