Home AMX User Forum NetLinx Studio

Digest Access Authentication

vmailvmail Junior MemberPosts: 11
Hi, I would like to web scape some data from a web page that uses digest access authentication.

I've captured this from Charles

telnet 192.168.1.11 80
GET /cgi-bin/minerStatus.cgi HTTP/1.1
Authorization: Digest username="root", realm="antMiner Configuration", nonce="e9e1achanged7", uri="/cgi-bin/minerStatus.cgi", response="b47changed342a", qop=auth, nc=00000001, cnonce="a3changed0"

This is nothing like basic authentication, how do I go about implementing this in either AMX or Telnet?

Comments

  • piepie Posts: 1

    Howdy,

    am having some difficulty implementing the amx-util-library
    to initiate a GET request to a device (brightSign)
    that requires Digest Authentication
    (just trying to reboot it via an NX-1200)

    have done a lot of digging but am still at a loss.
    below is a rough breakdown of the programming:

    PROGRAM_NAME = “blah”

    include ‘http’

    DEFINE_DEVICE

    dvNX1200 = 5001:1:1
    dvIO = 5001:22:1
    dvIPServerTCP = 0:30:1
    dvTstBSign = 0:500:1

    DEFINE_CONSTANT

    username = ‘admin’
    password = ‘admin’
    method = HTTP_METHOD_GET
    requestUri = ‘/action.html?reboot=Reboot’

    DEFINE_VARIABLE

    char httpResponseBuffer[2048]

    define_function connectTstBSign()
    {
    ip_client_open (500,’192.168.117.199’,80,IP_TCP)
    }

    DEFINE_START

    create_buffer dvIPServerTCP, httpResponseBuffer


    DEFINE_EVENT

    DATA_EVENT [dvNX1200]
    {
    ONLINE:
    {
    IP_SERVER_OPEN(30,81,IP_TCP)
    wait 30 connectTstBSign()
    }
    }

    BUTTON_EVENT[dvIO,1]
    {
    PUSH:
    {
    send_string dvTstBSign, httpRequestToString(request);
    }
    }

    DATA_EVENT[dvIPServerTCP]
    {
    STRING:
    {
    stack_var HttpResponse response

        if(httpParseResponse(response,httpResponseBuffer))
        {
            clear_buffer httpResponseBuffer
        }
    }
    

    }

    DEFINE_PROGRAM

    wait 10 connectTstBSign()

    //
    //
    //

    and then in the http.axi
    per the instructions/example
    near line 955 was added:

    HttpRequest request;

    request.method = HTTP_METHOD_GET
    request.requestUri = ‘/action.html?reboot=Reboot’
    request.version = 1.1

    httpSetHeader(request.headers, HTTP_HEADER_HOST, ‘192.168.117.199’);
    httpSetHeader(request.headers, HTTP_HEADER__FIELD_AUTHORIZATION, httpDigestAuthentication());

    //
    //
    //

    when trying to compile
    a syntax error is thrown at line 957
    as well as a couple of warnings:
    @todo: implement httpParseRequest method
    @todo: implement httpGetHeaderName method

    no idea what am doing wrong

    halp plz!

    cheers,
    pie

  • Duncan EllisDuncan Ellis Code Junkie Posts: 126

    There is another thread around which I responded to, I was using a Dahua Intercom which needed Digest and I pasted my prog into that

    look at this thread. Hope it helps

    https://proforums.harman.com/amx/discussion/comment/196982#Comment_196982

Sign In or Register to comment.