Reverse Engineering A Hydra 26 Hd

Discussion in 'Nano Reef Tanks' started by mcclown, Jul 1, 2017.

  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Users Viewing Thread (Users: 0, Guests: 0)

  1. mcclown

    mcclown Member

    Comments:
    48
    Ratings:
    +21
    Country:
    Australia
    State:
    NSW
    Well I haven't updated in a while...so here's a quick one. Skip to below the photo's, for the main reason for this thread.

    I've added two clowns, who proceeded to decimate my pod population and seem to be pretty happy now. I've also added a few turbos and a peppermint shrimp (we've two more to pick up tomorrow). I've also added a Tunze Nanonstream 6040, for some extra flow. Now for the obligatory photo's

    ai.imgur.com_iddzyNGl.jpg

    As you can see I ended up buying a Hydra 26 HD...it's not off center any more.

    ai.imgur.com_WUcRsbpl.jpg

    The clownbabies (Madam Mim & Merlin....I blame my girlfriend for those names)

    ai.imgur.com_mPvNu5Wl.jpg

    Slightly blurry but here is that fungia, that was in the middle of my live rock. I've extracted him

    Now, onto the main event. As you can see, I caved...I was finding it hard to build out what I wanted on a small scale, for lighting...if I was building a bigger rig, I could make it work but for this it ended up working better for me, to buy off the shelf....but that won't stop me trying to tinker around with it :)

    WARNING: Now, before we got any further....there be dragons...anything I'm messing with below, is for my own entertainment. You may be violating the warranty, by messing with these APIs below.

    My Problem:

    I've grabbed some aip files, with some sample programs, for the lights but they don't quite match what I want...I could write a script to change them to timeshift them to run earlier in the day and reduce the intensity (they're too strong from my tank, sometimes) but the problem is that there's a checksum in the file, which fails if I edit the file before uploading it.

    My Goals:

    Let's see if we can figure out how the checksum is being calculated.

    The Analysis:

    I did a bit of digging through the code, for the web ui, for my Hydra 26 HD and it lead me to notice a check for a cookie called "web_goblins" if it was true then it would add new elements to the page...turns out there's an API that I can query. A quick change in Chrome developers tools...

    View attachment ai.imgur.com_43Ah2XIl.png

    Tada...API functions. This is only some of the ones available. If you look at the javascript file ai-prime-conn.js, you can see other functions that drive the UI, like /api/devices, which allows you to change the device name. These are the dangerous functions though, as they make changes and could cause problems.

    A little more digging, into ui-support.js shows how the upload dialog is being triggered

    Code:
    $("#upload").on("click", function() {
            $("#share_options").hide();
            $("#importRamp").trigger("click")
        });
    ...and another search leads me to the functions that are processing the aip files, in the following function

    Code:
    $("#importRamp").change
    Now the important part....how is the checksum calculated...Well a bit more digging and I found the where the checksum was calculated. Using that for inspiration, I wrote this powershell script to calculate the correct checksum, for a given AIP file.

    Code:
    param(
        [Parameter(Mandatory=$true)]
        [String]$inputAIPFile
        )
    
    function Create-ScriptEngine()
    {
      param([string]$language = $null, [string]$code = $null);
      if ( $language )
      {
        $sc = New-Object -ComObject ScriptControl;
        $sc.Language = $language;
        if ( $code )
        {
          $sc.AddCode($code);
        }
        $sc.CodeObject;
      }
    }
    
    $jsCode =
    @"
    function getChecksum(l) {
            var k = 0;
            if (l.length == 0) {
                return k
            }
            for (var j = 0; j < l.length; j++) {
                var h = l.charCodeAt(j);
                k = ((k << 5) - k) + h;
                k = k & 4294967295
            }
            if (k < 0) {
                k = ~k
            }
            return k
        };
    "@
    
    $js = Create-ScriptEngine "JScript" $jsCode
    
    [xml]$xml = Get-Content -Path $inputAIPFile
    $colorsStr = [string]$xml.ramp.colors.OuterXml
    
    $js.getChecksum($colorsStr)
    (If anyone wants to run this they must run it in an x86 instance of Powershell. It's to do with how I'm running the javascript code.)

    Next step is to build out some functions, that will allow you to increase or decrease the intensity, of the lights. I'll probably add something to timeshift a give AIP as well. Has anyone else played around with this before? Any other functions people would want?
    • Love It! Love It! x 1
  2. lukusis

    lukusis Member

    Comments:
    435
    Ratings:
    +416
    Country:
    Australia
    State:
    NSW
    Thats dope!

    *waits for Sam/Slin to mosey on by* :rofl
    • Funny Funny x 1
  3. Rob

    Rob Member

    Comments:
    875
    Ratings:
    +703
    Country:
    Australia
    State:
    Victoria
    That is great... if I had a Hydra 26 HD I would joined in,
  4. slin1977

    slin1977 Member

    Comments:
    3,594
    Ratings:
    +3,101
    Country:
    Australia
    State:
    NSW
    That's double dope!
    Slin is preoccupied with the task of cleaning the guppy tank this morning.
    • Funny Funny x 1
  5. Andrew B

    Andrew B Member

    Comments:
    632
    Ratings:
    +378
    Country:
    Australia
    State:
    victoria
    Guppy tank?? what about your real tank ;)
  6. Sam Parker

    Sam Parker Moderator

    Comments:
    4,911
    Ratings:
    +4,667
    Country:
    Australia
    State:
    Victoria
  7. mcclown

    mcclown Member

    Comments:
    48
    Ratings:
    +21
    Country:
    Australia
    State:
    NSW
    I'm still working on it. There will be more here, once I figure it out.

Share This Page