rubysecurity.org

Cloud Architect / DevOps Engineer / SRE / Developer | /root

Home About Books Blog Portfolio Archive

Tag Cloud


Currently Reading

Certified Kubernetes Administrator (CKA) Study Guide
Certified Kubernetes Administrator (CKA) Study Guide
38 / 155 Pages


Latest Book Reviews

Latest Posts


December 8, 2015

Packt Publishing Free E-Books crawler

by Alpha01

I’m a big fan of Packt Publishing, and have purchased quite a few books from them. So when I first heard a couple of months back that they were going to give out free e-books everyday, my jaw literally dropped. https://www.packtpub.com/packt/offers/free-learning

I’ve normally been manually checking the site everyday for books that I might be interested on reading. The problem with this, is that their have been days that I missed out getting some free books that I would’ve love to read. So I wrote a short script that would notify me if there’s a free book available that I might be interested in reading. I would’ve love if Packt Publishing provided an rss feed so I can easily get notifications of their free books. Thus said, I really can’t complain since they’re already kind enough to give the world free e-books to spread knowledge.

https://github.com/alpha01/Packt-Publishing-Free-Learning

Tags: [ php ]
November 9, 2015

Locking Down WordPress Access with Varnish 3.x

by Alpha01

I have Varnish in front of all my WordPress sites and configured all /wp-admin traffic use https via Nginx. See https://www.rubysecurity.org/wordpress_admin-ssl

So to lock down access to my WordPress site’s requires both Varnish and Nginx configs to be modified.

Block at the http Varnish level:

sub vcl_recv {
    if ((req.url ~ "wp-(login|admin)") && (client.ip !~ MY-IP-ADDRESS)) {
                error 403 "Fuck off";
        }
}

Block at the https Nginx level (using shit.alpha01.org as an example):

location /wp-admin {
        allow   MY-IP-ADDRESS;
        deny all;
        proxy_pass https://shit.alpha01.org/wp-admin;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
}
location /wp-login.php {
        allow MY-IP-ADDRESS;
        deny all;
        proxy_pass https://shit.alpha01.org/wp-login.php;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
}
Tags: [ security varnish nginx wordpress ]
November 9, 2015

Locking Down Drupal Access with Nginx

by Alpha01

This site is powered by Drupal. Drupal and WordPress for that matter, are well targeted platforms, mainly because of their large install base on the internet. Quite frankly the reason I bother using both Drupal and WordPress instead of a flat-file based CMS is because I have to deal with these web applications at work on a daily basis, so it’s a great way to keep myself current with the technology that’s paying my bills.

I have Nginx acting as an SSL proxy for www.rubysecurity.org, which is hosted on an Apache back-end. So I have a few configs that I’ve enabled to lock down access to my Drupal site. The configs are made at the Nginx proxy level, so they can never reach Apache.

Firstly, I have all of Drupal’s /admin locked out from outside access:

location = /admin {
    allow MY-HOME-IP-ADDRESS;
    deny all;
    return 403;
}

Next, I only allow login access from my home ip address:

location = /user {
    allow MY-HOME-IP-ADDRESS;
    deny all;
    
    proxy_pass https://www.rubysecurity.org/user;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
}

Lastly, since Nginx is unable to process query strings at the location block level, I’ve setup an additional config to drop all user login query requests.

if ($args ~* "q=user") {
    set $blockme  M;
}
if ($remote_addr != MY-HOME-IP-ADDRESS) {
    set $blockme  "${blockme}E";
}
if ($blockme = ME) {
    return 403;
}
Tags: [ security nginx drupal ]
October 31, 2015

My Home Lab Network Diagram

by Alpha01

It’s Friday night, I don’t have anything interesting to do, so I created a diagram of my current home lab setup.

Home Lab Network Diagram

Tags: [ ubuntu networking kvm virtualbox ]
September 20, 2015

Grepping for PHP system level command functions

by Alpha01

 grep --color -r -E -e '(escapeshellarg|escapeshellcmd|exec|passthru|proc_close|proc_get_status|proc_nice|proc_open|proc_terminate|shell_exec|system)(\s+)?\(' ./
Tags: [ php security ]