Jan 112016
 

Here are a couple ways I’ve come up with to reboot CradlePoint devices remotely. These were all tested on MBR1400 routers using v6.0.2 firmware. If you have proper HTTPS certificates installed for the web interface you can drop the ‘–no-check-certificate’ or the ‘–insecure’ options on the WGET and CURL commands. Also note that the CURL and WGET commands are using the password in the command. This can be insecure for many reasons.

Of course, you could always use the web interface too.

Using SSH:

ssh [user]@[ip address] 'reboot'

Using WGET:

wget --no-check-certificate https://[ip address]/api/control/system/reboot --http-user=[user] --http-password=[password] --post-data 'data=%221%22'

Using CURL:

curl --insecure https://[ip address]/api/control/system/reboot --anyauth --user [user]:[password] --data "data=%221%22"

Custom HTML using POST:
You can throw this code into a custom website, if you really feel the need.

<form action="https://[ip address]/api/control/system/reboot" method="post">
     <button type=submit name="data" value="1">Reboot CradlePoint</button>
</form>

Using SMS:
You can also use SMS to send a text message to the CradlePoint router instructing it to reboot. Unless you’ve changed the SMS password, the SMS password is the last eight characters of the MAC address. It’s specifically an SMS password (so it’s not tied to any user account).

The format of the text message:

[password],reboot

You’ll receive a text back from the device:
CP Reboot

Jan 302014
 

Sometimes you may have a SID (objectSid) for an Active Directory object but not necessarily know which object it belongs to. You can find the object using PowerShell.

I came across this when recovering a hard drive for a company. The hard drive was from a domain computer and the NTFS permissions only showed the SID as the recovery computer was a workgroup computer and didn’t have access to the domain. I wanted to re-apply the NTFS permissions on the replaced drive so I needed to know which each SID belonged to.

Run the following on a computer that is a member of the domain:

Import-Module ActiveDirectory
Get-ADUser -Identity S-1-5-21-941005169-1824062477-405670111-1106
Mar 022013
 

I’ve been thinking about building a plugin for MPD that would allow it to talk with Google Music for a while now. Currently, when I purchase music from Google Music, I have to download it and push the new music up to my local music share on my network. Once my music is there, MPD can stream it without a problem… I love MPD!

I started to investigate the idea this weekend. I found these two projects that I wanted to share with you guys. They helped me prove out that the plugin I want to write is possible without TOO much work.

Unofficial Google Music API – An unofficial, opensource API written in Python for Google Music.
MPC – A linux terminal based MPD client.

First, by modifying the example.py in the Google Music API a little I was able to create a script that would sign into Google Music, find the first song in my library and grab the streaming URL of that song.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from getpass import getpass
from gmusicapi import Api

def ask_for_credentials():
    """Make an instance of the api and attempts to login with it.
    Return the authenticated api.
    """

    api = Api()

    logged_in = False
    attempts = 0

    while not logged_in and attempts < 3:
        email = raw_input("Email: ")
        password = getpass()

        logged_in = api.login(email, password)
        attempts += 1

    return api


def demonstration():
    """Demonstrate some api features."""

    api = ask_for_credentials()

    if not api.is_authenticated():
        print "Sorry, those credentials weren't accepted."
        return

    print "Successfully logged in."
    print

    #Get all of the users songs.
    #library is a big list of dictionaries, each of which contains a single song.
    print "Loading library...",
    library = api.get_all_songs()
    print "done."

    print len(library), "tracks detected."
    print

    #Show some info about a song. There is no guaranteed order;
    # this is essentially a random song.
    first_song = library[0]
    print "The first song I see is '{}' by '{}'.".format(
        first_song["name"],
        first_song["artist"])

    #We're going to create a new playlist and add a song to it.
    #Songs are uniquely identified by 'song ids', so let's get the id:
    song_id = first_song["id"]
    
    print (api.get_stream_url(song_id))

    #It's good practice to logout when finished.
    api.logout()
    print "All done!"

if __name__ == '__main__':
    demonstration()

When running the script above, it’ll ask for a Google account and password. Once they are entered the script will login and load the library of the account. It will grab the first song in the library and output the URL to stream the song. Now that I had the streaming URL, I needed a way to add that to my MPD queue.

mpc clear
mpc add "URL FROM SCRIPT ABOVE"
mpc play

Low and behold! When I hit play the song started playing! So now we know that it can work the next step is figuring out if there’s a way to tie the Google Music library in with MPD’s library.