Supermirco IPMI KVM: Remote Connection Without Web Browser

I am trying to connect to a remote IPMI (KVM) connection without using the webbrowser tool or IPMIview. But no luck yet.

The first thing I did was launch jlooker.jnlp with javaws. This file will be generated by the IPMI website if you click the "Remote Connection" button. This solution works until the web session is closed. I am trying to replace an encrypted argument with a username and password. But the session ID is embedded somehow.

Jviewer.jnpl file:

<?xml version="1.0" encoding="UTF-8"?>

<jnlp spec="1.0+" codebase="https://192.168.99.201/Java">
 <information>
    <title>JViewer</title>
    <vendor>American Megatrends, Inc.</vendor>
    <description kind="one-line">JViewer Console Redirection Application</description>
    <description kind="tooltip">JViewer Console Redirection Application</description>
    <description kind="short">
        JViewer enables a user to view the video display of managed server via KVM.  
        It also enables the user to redirect his local keyboard, mouse for managing the server remotely.
    </description>
</information>
<security>
    <all-permissions/>
</security>
<resources>
    <j2se version="1.5+"/>
    <jar href="release/JViewer.jar"/>
</resources>
<resources os="Windows" arch="x86">
    <j2se version="1.5+"/>
    <nativelib href="release/Win32.jar"/>
</resources>    
<resources os="Windows" arch="amd64">
       <j2se version="1.5+"/>
       <nativelib href="release/Win64.jar"/>
</resources>
<resources os="Linux"  arch="x86">
    <j2se version="1.5+"/>
        <nativelib href="release/Linux_x86_32.jar"/>
</resources>
<resources os="Linux"  arch="i386">
    <j2se version="1.5+"/>
        <nativelib href="release/Linux_x86_32.jar"/>
</resources>
<resources os="Linux" arch="x86_64">
    <j2se version="1.5+"/>
        <nativelib href="release/Linux_x86_64.jar"/>
</resources>    
<resources os="Linux" arch="amd64">
    <j2se version="1.5+"/>
        <nativelib href="release/Linux_x86_64.jar"/>
</resources>
<resources os="Mac OS X" arch="i386">
    <j2se version="1.5+"/>
        <nativelib href="release/Mac32.jar"/>
</resources>
<application-desc>
    <argument>192.168.99.201</argument>
    <argument>5901</argument>
    <argument>Hnda9A159AwMjwnF</argument>
    <argument>0</argument>
    <argument>0</argument>
    <argument>5120</argument>
    <argument>5123</argument>
    <argument>511</argument>
    <argument>5900</argument>
    <argument>1</argument>
    <argument>EN</argument>
    <argument>HEWKovXQO2Fp7FEMho6LrM4kzTPFHPyB000</argument>

</application-desc>
</jnlp>

      

The argument username and password names will work if the jnlp is named "launch.jnlp". Some versions of Supermicro IPMI will use a different structure.

Second, I am trying to connect to IPMIview tool version 2.9.32. It works, so the communication is fine. I know that I am trying to connect using IPMIview banners. Replace host IPMI IP

java -Djava.library.path=. -jar iKVM.jar host ADMIN ADMIN null 5900 2623 2 0

      

This will open a remote connection, but will result in a "Connection error" error.

java -Djava.library.path=. -jar JViewerX9.jar host ADMIN ADMIN

      

Also the same result: Connection Error Failed to connect with warning field. OK closes the application

Some IPMI information:

# ipmitool mc info
Device ID                 : 32
Device Revision           : 1
Firmware Revision         : 2.4
IPMI Version              : 2.0
Manufacturer ID           : 47488
Manufacturer Name         : Unknown (0xB980)
Product ID                : 43707 (0xaabb)
Product Name              : Unknown (0xAABB)
Device Available          : yes
Provides Device SDRs      : no
Additional Device Support :
    Sensor Device
    SDR Repository Device
    SEL Device
    FRU Inventory Device
    IPMB Event Receiver
    IPMB Event Generator
    Chassis Device
Aux Firmware Rev Info     : 
    0x01
    0x00
    0x00
    0x00

      

Cold reset "ipmitool mc reset cold" also doesn't work.

I hope someone knows what this argument means for the jnlp file, or someone has a working solution for this problem.

Edit: I'm trying Maxim Akristini's answer and came up with the following code:

package com.thalesgroup.nl.perftools;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.util.List;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.ScriptResult;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebResponse;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
import com.gargoylesoftware.htmlunit.util.Cookie;

public class IpmiRemoteViewer {

    public static void main(String[] args)
            throws FailingHttpStatusCodeException, MalformedURLException,
            IOException {

        String username = "ADMIN";
    String password = "ADMIN";
    String ip = "192.168.99.150";

    final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_17);

    webClient.getOptions().setThrowExceptionOnScriptError(false);
    webClient.getCookieManager().setCookiesEnabled(true);

    webClient.getOptions().setUseInsecureSSL(true);
    webClient.getOptions().setJavaScriptEnabled(true);

    webClient.getCookieManager().addCookie(
            new Cookie(ip, "WEBVAR_USERNAME", username));
    webClient.getCookieManager().addCookie(
            new Cookie(ip, "WEBVAR_PASSWORD", password));

    HtmlPage page1 = webClient.getPage("http://" + ip);

    List<HtmlForm> forms = page1.getForms();

    if (!forms.isEmpty()) {

        HtmlForm form = forms.get(0);
        HtmlSubmitInput button = (HtmlSubmitInput) form.getInputsByValue(
                "Login").get(0);

        // username
        HtmlTextInput textField = form.getInputByName("T1");
        textField.setValueAttribute(username);

        // password
        HtmlPasswordInput textField2 = form.getInputByName("T2");
        textField2.setValueAttribute(password);

        HtmlPage page2 = button.click();
        webClient.waitForBackgroundJavaScript(500);

        // Do it again
        form = page2.getForms().get(0);

        // username
        textField = form.getInputByName("T1");
        textField.setValueAttribute(username);

        // password
        textField2 = form.getInputByName("T2");
        textField2.setValueAttribute(password);

        ScriptResult scriptResult = page2.executeJavaScript("DoLogin();");

        // Print the index.html page
        System.out.println(scriptResult.getNewPage().toString());

        // Print the session id
        for (Cookie cookie : webClient.getCookieManager().getCookies()) {
            if (cookie.getName().equals("SessionCookie")) {
                String sessionId = cookie.getValue();
                System.out.println("Session id = " + sessionId);
            }
        }

        // Download the jviewer.jnlp file
        Page page5 = webClient.getPage("http://" + ip
                + "/Java/jviewer.jnlp?EXTRNIP=" + ip + "&JNLPSTR=JViewer");
        WebResponse response = page5.getWebResponse();
        InputStream inputStream = response.getContentAsStream();

        writeToFile("viewer.jnlp", inputStream);
    }

}

protected static void writeToFile(String filename, InputStream inputStream) {
    OutputStream outputStream = null;

    try {

        File file = new File(filename);

        // write the inputStream to a FileOutputStream
            outputStream = new FileOutputStream(file);

            int read = 0;
            byte[] bytes = new byte[1024];

            while ((read = inputStream.read(bytes)) != -1) {
                outputStream.write(bytes, 0, read);
            }

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (outputStream != null) {
                try {
                    outputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
        }
    }

}

      

Only now it will write the login page to the viewer.jnlp file. No luck yet. I was able to read the index.html page which is behind the login page. But the session closes very quickly.

+3


source to share


3 answers


Download jviewer.jnlp file, but login first.

#!/bin/sh

USER=ADMIN
PASS=ADMIN
HOST=192.168.99.150

COOKIE=`curl --data "WEBVAR_USERNAME=$USER&WEBVAR_PASSWORD=$PASS" http://$HOST/rpc/WEBSES/create.asp 2> /dev/null | grep SESSION_COOKIE | cut -d\' -f 4`
curl --cookie Cookie=SessionCookie=$COOKIE http://$HOST/Java/jviewer.jnlp -o $HOST.jviewer.jnlp

      



Then run jviewer.jnlp file with javaws

+4


source


Supermicro uses American Megatrends' MegaRAC software and jviewer is part of it. MegaRAC offers a standalone jviewer app. You should be able to request it from Supermicro.



+1


source


you need to connect to the IPMI server and set the cookie variables: WEBVAR_USERNAME, WEBVAR_PASSWORD
you will get the response in the cookie variable SESSION_COOKIE
next download http: // "+ IP +" /Java/jviewer.jnlp?EXTRNIP= "+ IP +" & JNLPSTR = JViewer
to your jnlp

or use the existing jnlp and replace the received cookie with it with your own cookie:

<argument>-webcookie</argument>
<argument>zIoAlbnWxQtHTIutR8wyeKxeo9nAVJF5000</argument>

      

0


source







All Articles