Skip to content

I can't get the response #31

@SOSkr

Description

@SOSkr

I am trying to access a Juniper Router
This is an output of a successful connection:

**************************************************************************************
                                 NOTICE TO USERS

 WARNING: YOU ARE LOGGED IN A XXX XXX SYSTEM. ALL INFORMATION IN THIS
SYSTEM IS CONFIDENTIAL. USE OF THIS SYSTEM BY ANY USER, AUTHORIZED OR
UNAUTHORIZED, CONSTITUTES EXPRESS CONSENT TO THIS MONITORING.
To protect the system from unauthorized use and to ensure that the system is
functioning properly, activities on this system are monitored and recorded
and subject to audit. Use of this system is expressed consent to such
monitoring and recording. Any unauthorized access or use of this Automated
Information System is prohibited and could be subject to criminal and civil
penalties.

 .......................

ADVERTENCIA: ESTA A PUNTO DE INGRESAR A UN SISTEMA DE XXX XXX. TODA LA
INFORMACION QUE SE ENCUENTRA EN ESTE SISTEMA ES CONFIDENCIAL. EL USO DE ESTE
SISTEMA POR CUALQUIER USUARIO, AUTORIZADO O NO, CONSTITUYE UN CONSENTIMIENTO
EXPRESO PARA SER MONITOREADO.
Para proteger este sistema de uso no autorizado y asegurar su buen
funcionamiento, todas las actividades estßn siendo monitoreadas y almacenadas
para efecto de auditoria. Cualquier acceso no autorizado y/o uso inadecuado
de este sistema estß prohibido y puede ser causa de acciones penales.

*************************************************************************************

HOSTNAME (ttyp0)

login: username
Password:

--- JUNOS 10.4R3.4 built 2011-03-19 21:36:24 UTC
{master}
username@HOSTNAME>

This is the code I'm using:

    $host = Host::find(3);
    $client = Graze\TelnetClient\TelnetClient::factory();

    $client->setLineEnding(null);
    $client->connect("{$host->ipaddress}:23", "username@{$host->name}>");

    $resp = $client->execute("\r\n", "login: ");
    var_dump($resp);
    $resp1 = $client->execute("username\r\n", "Password: ");
    var_dump($resp1);
    $resp2 = $client->execute("secret\r\n");
    var_dump($resp2);
    $resp3 = $client->execute("show version | no-more\r\n\r\n");
    var_dump($resp3);
    $resp4 = $client->execute("show version | no-more\r\n\r\n");
    var_dump($resp4);

This is what I get when I var_dump the buffer:

var_dump($resp);

object(Graze\TelnetClient\TelnetResponse)#319 (3) {
  ["isError":protected]=>
  bool(false)
  ["responseText":protected]=>
  string(0) ""
  ["promptMatches":protected]=>
  array(0) {
  }
}

var_dump($resp1);

object(Graze\TelnetClient\TelnetResponse)#320 (3) {
  ["isError":protected]=>
  bool(false)
  ["responseText":protected]=>
  string(0) ""
  ["promptMatches":protected]=>
  array(0) {
  }
}

var_dump($resp2);

object(Graze\TelnetClient\TelnetResponse)#323 (3) {
  ["isError":protected]=>
  bool(false)
  ["responseText":protected]=>
  string(0) ""
  ["promptMatches":protected]=>
  array(0) {
  }
}

var_dump($resp3);

object(Graze\TelnetClient\TelnetResponse)#303 (3) {
  ["isError":protected]=>
  bool(false)
  ["responseText":protected]=>
  string(91) "

login: login: Password:

--- JUNOS 10.4R3.4 built 2011-03-19 21:36:24 UTC
{master}
"
  ["promptMatches":protected]=>
  array(1) {
    [0]=>
    string(25) "username@HOSTNAME>"
  }
}

var_dump($resp4);

object(Graze\TelnetClient\TelnetResponse)#315 (3) {
  ["isError":protected]=>
  bool(false)
  ["responseText":protected]=>
  string(1034) " show version | no-more 
Hostname: HOSTNAME
Model: m20
JUNOS Base OS boot [10.4R3.4]
...
{master}
"
  ["promptMatches":protected]=>
  array(1) {
    [0]=>
    string(25) "username@HOSTNAME>"
  }
}

for some reason the first variables don't show me the server's response #

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions