Wake on LAN script in Python

This works.

#!/usr/bin/env python
# wol.py
import socket
import struct

def wake_on_lan(macaddress):
    """ Switches on remote computers using WOL. """

    # Check macaddress format and try to compensate.
    if len(macaddress) == 12:
        pass
    elif len(macaddress) == 12 + 5:
        sep = macaddress[2]
        macaddress = macaddress.replace(sep, '')
    else:
        raise ValueError('Incorrect MAC address format')
 
    # Pad the synchronization stream.
    data = ''.join(['FFFFFFFFFFFF', macaddress * 20])
    send_data = '' 

    # Split up the hex values and pack.
    for i in range(0, len(data), 2):
        send_data = ''.join([send_data,
                             struct.pack('B', int(data[i: i + 2], 16))])

    # Broadcast it to the LAN.
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
    sock.sendto(send_data, ('', 7))
    

if __name__ == '__main__':
    # Use macaddresses with any seperators.
    wake_on_lan('00-23-24-53-0B-EC')
    #wake_on_lan('0F-0F-DF-0F-BF-EF')
    # or without any seperators.
    #wake_on_lan('0F0FDF0FBFEF')

 

Posted in python | Comments Off on Wake on LAN script in Python

OpenVAS vulnerability scanner

I wanted to do a quick scan of a system before I signed a security assessment consent form, so I wanted a free vulnerability scanner I could use. I couldn’t find a truly free online scanner that I could “just use”, so I set up OpenVAS on an amazon instance. It works well.  I chose OpenVAS because is the leading free open source scanner out there.

I spun up a t2.micro at amazon to host it.  It choked.  I upgraded to a t2.large, which worked much better.  OpenVAS uses a lot of resources, so go with a large.  You can always shut down the scanner when you are not using it.  Even the t2.large just about used up all its CPU credit balance after just 3 scans.

A quick setup guide is hosted here: https://launchpad.net/~mrazavi/+archive/ubuntu/openvas

But first, do:

sudo apt-get install texlive-latex-extra build-essential

After installation and configuration, reconnect to your amazon instance like this:

ssh [email protected] -L 8000:127.0.0.1:443 -i ec2-keypair.pem

Then point your browser at https://localhost:8000

login with user admin, password admin.

UPDATE: 8/24/2015

Amazon does not like you running openVAS on their network.  They threatened to shut down my account.  So, if you are wanting to run openVAS, I recommend running it on Digital Ocean.

Here is a howto they put together for you.

https://www.digitalocean.com/community/tutorials/how-to-use-openvas-to-audit-the-security-of-remote-systems-on-ubuntu-12-04

Posted in Linux, Security | Comments Off on OpenVAS vulnerability scanner

Respsonsive tables

Sometimes you need to display a big table but you want it to be usable on a mobile phone.  Responsive Tables to the rescue.

http://elvery.net/demo/responsive-tables/

The best one, in my opinion, is the “No More Tables” demo at the bottom of the page.

 

Posted in CSS | Comments Off on Respsonsive tables

Quickest way to get Tomcat 7 running on ubuntu 14.04

I found this excellent blog post and thought it was worth remembering, so here it is.

https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-7-on-ubuntu-14-04-via-apt-get

Posted in Linux, Tomcat, Ubuntu | Comments Off on Quickest way to get Tomcat 7 running on ubuntu 14.04

SSL Certificate Checkers

These two are the best i have found.

Qualys SSL Server Test

Symantec SSL Ceritficate Checker

Both are free and provide thorough analysis of your certificate to make sure it passes PCI server scans and such.

Posted in SSL | Comments Off on SSL Certificate Checkers