Skip to content

Instantly share code, notes, and snippets.

View fduran's full-sized avatar

Fernando Duran fduran

View GitHub Profile
@fduran
fduran / gist:1989361
Created March 6, 2012 22:16
Find Linux users that can log in with password
# www.fduran.com
# Check which Linux users could log in with password, see "man shadow" for the second field in the /etc/shadow file:
# "If the password field contains some string that is not a valid result of crypt(3), for instance ! or *, the user will not be able to use a unix password to log in (but the user may log in the system by other means).
# this awk one-liner will find users that have common used * or ! in the password field or field starts with ! (locked account). It's possible that still found user cannot log in due to other non-crypt character in the field
awk -F: '$2 != "*" && $2 !~ /^!/ { print $1, " can log in" }' /etc/shadow
@fduran
fduran / gist:1947100
Created March 1, 2012 03:40
Apache security: installing mod_security
# www.fduran.com
# installing mod_security http://www.modsecurity.org (Debian-based distro)
# apachectl -M
apache2: Could not reliably determine the server's fully qualified domain name, using boxmetric.com for ServerName
Loaded Modules:
core_module (static)
log_config_module (static)
logio_module (static)
mpm_prefork_module (static)
@fduran
fduran / gist:1870554
Created February 20, 2012 18:34
Linux disk/memory stress test
# www.fduran.com
# hardware stress test
# mismatched md5sums shows a faulty disk/RAM
# time depends on hardware, ex: 1 sec per 100 count
dd if=/dev/zero of=/tmp/test.file bs=1M count=1000
for i in {1..5}; do md5sum /tmp/test.file; done
@fduran
fduran / gist:1870552
Created February 20, 2012 18:33
Linux honeypots
# www.fduran.com
# Linux honeypots
# nephentes
# (google 'nephentes honepot')
apt-get update; apt-get install nepenthes
nano /etc/nepenthes/nepenthes.conf
/etc/init.d/nepenthes restart
#log: less /var/log/nepenthes.log
@fduran
fduran / gist:1870549
Created February 20, 2012 18:33
Linux remote syslog
www.fduran.com
Remote syslogging in Linux
1. On logging server 'logserver':
# nano /etc/rsyslog.conf
uncomment:
# provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514
@fduran
fduran / gist:1870548
Created February 20, 2012 18:33
Monitoring Plesk with Monit
www.fduran.com
Monitoring Plesk with Monit
Plesk is not mentioned anywhere in monit's site http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=plesk+site%3Ammonit.com and I couldn't find any article or tutorial about how to monitor Plesk using Monit, so I'm writing one myself in the hopes other people with the same problem find it.
Plesk 8.3 on Centos5
etc/init.d/psa status
psa dead but subsys locked
@fduran
fduran / gist:1870546
Created February 20, 2012 18:32
Linux check DNS cache snooping
# www.fduran.com
# Linux check DNS cache snooping
# check if somedomain (try popular ones like google.com etc) is cached in a dns_server
# with nslookup
nslookup -norecurse somedomain dns_server
# with dig
dig @dns_server somedomain A +norecurse
@fduran
fduran / gist:1870543
Created February 20, 2012 18:32
Linux shell here document on the fly
# www.fduran.com
# Linux shell "here" document
$ cat > newfile << EOF
> write something
> EOF
# obv also:
$ cat > newfile
# and Ctr-D
@fduran
fduran / gist:1870536
Created February 20, 2012 18:31
Heroku Python
# www.fduran.com
# Heroku notes for python, fixes http://devcenter.heroku.com/articles/python
# Ubuntu 11.04 (Natty Narwhal)
mkdir heroku
cd heroku
# Prerequisites
curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
cp virtualenv.py /usr/bin/virtualenv
@fduran
fduran / gist:1870533
Created February 20, 2012 18:30
Apache password protect directory
# www.fduran.com
# apache password protect directory
# Apache config
<Directory /home/user/public_html>
AllowOverride AuthConfig
# ...
</Directory>
Alias /protected "/home/user/public_html/protected"