Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    [socket] connessione a telnet

    ho bisogno di connettermi ad un server telnet per inviare due comandi (e leggere la risposta che mi da)


    Codice PHP:
    $socket socket_create(AF_INETSOCK_STREAMSOL_TCP);
    if (
    $socket 0) die("socket_create() fallito: motivo: " socket_strerror($socket) . "\n");

    echo 
    "Tentativo di connessione... ";
    $result socket_connect($socket$ip$pt);
    if (
    $result 0) die("socket_connect() fallito.\nMotivo: ($result) " socket_strerror($result) . "\n");
    else echo 
    "OK.\n";


    echo 
    "Lettura della risposta:\n\n";
    while (
    $out socket_read($socket512)) {
       echo 
    $out;
    }

    socket_write($socket'root');


    while (
    $out socket_read($socket512)) {
       echo 
    $out;

    Tentativo di connessione... OK.
    Lettura della risposta:

    ²☺ ²▼ ²! ¹☺ ¹♥mygateway login:
    Login timed out after 60 seconds.

    come faccio a fargli inviare il testo e leggere le risposte?

  2. #2

  3. #3
    Codice PHP:
    socket_write($socket"root\r\nadmin\r\n");

    socket_write($socket"cat /proc/ticfg/env |grep my_ip\r\n");

    while (
    $out socket_read($socket4096)) {
       echo 
    $out;

    con questo codice mi connetto e prendo la stringa che mi serve (my_ipaddress 192.168.1.1)


    C:\duart>php a.php
    Tentativo di connessione... OK.
    Lettura della risposta:

    ²☺ ²▼ ²! ¹☺ ¹♥root
    admin
    cat /proc/ticfg/env |grep my_ip
    mygateway login: Password:


    BusyBox v1.00 (2005.03.01-00:28+0000) Built-in shell (ash)
    Enter 'help' for a list of built-in commands.

    # cat /proc/ticfg/env |grep my_ip
    my_ipaddress 192.168.1.1

    però vedo che è molto incasinato :F
    non c'è un modo per dire "aspetta 'mygateway login:' e scrivi "root", aspetta "password:" e scrivi "admin" ecc ?

    alla fine non mi esce mai dal while, perchè?

  4. #4

  5. #5

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.