styk.tv

Cloud Developer's Technology Encounters

DenyHosts

by polfilm on January 21, 2015

If you’re getting bombarded with brute force login attempts. Below will install DenyHosts as a daemon that will with default settings scan your /var/log/secure for failed login attempts. It is initially set to 5 failed attempts and then IP ends up in the hosts.deny file. You should get a good long look a the .cfg file to understand full capabilities. (For example running against Apache logs for web attacks)

wget http://downloads.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6.tar.gz
tar -zxvf DenyHosts-2.6.tar.gz
cd DenyHosts-2.6
python setup.py install
cp /usr/share/denyhosts/daemon-control-dist /usr/share/denyhosts/daemon-control
cp /usr/share/denyhosts/denyhosts.cfg-dist /usr/share/denyhosts/denyhosts.cfg
ln -s /usr/share/denyhosts/daemon-control /etc/init.d/denyhosts
chkconfig --add denyhosts
service denyhosts start 
tail -f /etc/hosts.deny /var/log/secure

Root Zone Database

by polfilm on January 12, 2015

The Root Zone Database represents the delegation details of top-level domains, including gTLDs such as .com, and country-code TLDs such as .uk.

http://data.iana.org/TLD/tlds-alpha-by-domain.txt

Registrars List (UK)
http://www.nominet.org.uk/uk-domain-names/registering-uk-domain/choosing-registrar/list-registrars

Lighttpd rewrite rules for WordPress sites

by polfilm on November 27, 2014

  # Handle 404 errors
  server.error-handler-404 = "/index.php"
 
  # Rewrite rules
  url.rewrite-final = (
 
    # Exclude some directories from rewriting
    "^/(wp-admin|wp-includes|wp-content|gallery2)/(.*)" => "$0",
 
    # Exclude .php files at root from rewriting
    "^/(.*.php)" => "$0",
 
    # Handle permalinks and RSS feeds
    "^/(.*)$" => "/index.php/$1"
  )

Bat Command from Powershell

by polfilm on September 8, 2014

This way you don’t have to worry about escaping anything.

$command = @'
cmd.exe /C c:\windows\system32\ntbackup.exe backup "C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\chameme.bks" /n "1file.bkf1 created 06/09/2013 at 09:36" /d "Set created 06/09/2013 at 09:36" /v:no /r:no /rs:no /hc:off /m normal /j chameme /l:s /f "\\fs1\Exchange Backups$\1file.bkf"
'@

Invoke-Expression -Command:$command

Ipa. Change Admin Password

by polfilm on March 6, 2014

LDAPTLS_CACERT=/etc/ipa/ca.crt ldappasswd \
           -ZZ -D 'cn=directory manager' -W \
           -S uid=admin,cn=users,cn=accounts,dc=domain,dc=com

or

kadmin.local
Authenticating as principal admin/admin@EXAMPLE.COM with password.
kadmin.local:  change_password admin@EXAMPLE.COM
Enter password for principal "admin@EXAMPLE.COM": 
Re-enter password for principal "admin@EXAMPLE.COM": 

Git: Few Good Commands

by polfilm on February 17, 2014

To move repo with history

git clone --bare <old_repo>
cd into bare old_repo and: git push --mirror <new_repo>

To clone from HTTPS with self-generated cert

git -c http.sslVerify=false clone https://<repo>

Restore all deleted files in folder

git ls-files -d | xargs git checkout --

Automatic Versioning
Begin Versioning:

git tags -a 2.1

Retrieve:

git describe --tags

Result similar to this where 411 is number of commit for above given tag.

2.1-441-gff635ba

UI Frameworks

by polfilm on January 6, 2014

Don’t even think about starting work on UI without looking at those…

http://bootstrapdocs.com/v2.3.1/docs/components.html
https://github.com/twbs/bootstrap
http://discover-devtools.codeschool.com/
http://modernizr.com/docs/
http://afarkas.github.io/webshim/demos/demos/shiv.html
https://github.com/dyve/django-bootstrap-toolkit
http://backbonejs.org/
http://knockoutjs.com/
http://billpull.github.io/knockout-bootstrap/
http://django-debug-toolbar.readthedocs.org/en/1.0/
https://github.com/eldarion/eldarion-ajax