Selain menggunakan halaman login yang disediakan oleh router kita juga bisa menulis script untuk otomatisasi login dengan bantuan curl. Contoh router yang saya gunakan disini adalah Alcatel Lucent G-241W-A.
Informasi yang ingin saya ambil dari router tersebut adalah informasi hardwarenya. Untuk mengetahui URL apa yang dibuka tentunya anda harus mengeksplorasi halaman admin route tersebut. Bila belum pernah sebelumnya bisa dilihat disini
Sript berikut ini sudah jadi dan sesuai dengan target yang saya inginkan. Didalam script sudah terdapat komentar singkat mengenai fungsinya. Yang perlu disesuaikan adalah
username
password
buat file php dengan nama informasi-router.php
, lalu copy script dibawah ini
<?php // informasi-router.php // IP Router Alcatel $ipRouter = 'http://192.168.1.254'; // username dan password Router // sumber : https://jaranguda.com/password-terbaru-router-alcatel-lucent-bali-fiber/ $POSTDATA = 'name=AdminGPON&pswd=ALC#FGU'; // login dan simpak cookies $ch = curl_init($ipRouter . '/login.cgi'); curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookie.txt'); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"); curl_setopt($ch, CURLOPT_POSTFIELDS, $POSTDATA); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); curl_close($ch); // tahap kedua // buka url lainnya dengan cookies // ambil status devices $ch = curl_init($ipRouter . '/device_status.cgi'); curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookie.txt'); curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookie.txt'); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $content = curl_exec($ch); curl_close($ch); // parsing data $ambilData = preg_match_all('/\{([^}]+)\}/', $content, $matches); //oke // preg_match_all('/\{[^]]+\}/', $file, $matches); $data = ($matches[1][4]); // pecah perbaris $pecah = explode("\n", $data); // hapus baris yang tidak valid sebagai json "" unset($pecah[0]); unset($pecah[1]); unset($pecah[23]); // gabung kembali $gabung = implode("\n", $pecah); // tambahkan bracket // karena ini json ;) $tambahBracket = "{" . $gabung ."}"; // decode json $router = json_decode($tambahBracket); echo "< pre>"; print_r($router); echo "</ pre>"; echo "Manufacturer: " . $router->Manufacturer . "<br>"; echo "Serial Number: " . $router->SerialNumber . "<br>";; echo "Model: " . $router->ModelName . "<br>";
Eksekusi script diatas, yang outputnya kira-kira :
stdClass Object ( [Manufacturer] => ALCL [ManufacturerOUI] => F844E3 [ModelName] => G-241W-A [Description] => [ProductClass] => G-241W-A [SerialNumber] => ALCLB12915F1 [HardwareVersion] => 3FE56978DAAA [SoftwareVersion] => 3FE56558AFIB58 [X_ASB_COM_Chipset] => BCM6838 [ModemFirmwareVersion] => [EnabledOptions] => [AdditionalHardwareVersion] => [AdditionalSoftwareVersion] => U-Boot Jul-04-2018--16:24:26 [SpecVersion] => 1.0 [ProvisioningCode] => ALCL [UpTime] => 935142 [FirstUseDate] => 0001-01-01T00:00:00Z [X_ASB_COM_NumberOfCpuThreads] => 1 [X_ASB_COM_SwBuildTimestamp] => [X_ASB_COM_DslPhyDrvVersion] => [X_ASB_COM_VoiceServiceVersion] => ) Manufacturer: ALCL Serial Number: ALCLB12915F1 Model: G-241W-A
Dari data diatas kita akan coba menampilkannya di tabel dengan bantuan Bootstrap CSS, ubah script informasi-router.php
diatas menjadi
<?php // informasi-router.php // IP Router Alcatel $ipRouter = 'http://192.168.1.254'; // username dan password Router // sumber : https://jaranguda.com/password-terbaru-router-alcatel-lucent-bali-fiber/ $POSTDATA = 'name=AdminGPON&pswd=sentabi123'; // login dan simpak cookies $ch = curl_init($ipRouter . '/login.cgi'); curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookie.txt'); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"); curl_setopt($ch, CURLOPT_POSTFIELDS, $POSTDATA); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); curl_close($ch); // tahap kedua // buka url lainnya dengan cookies // ambil status devices $ch = curl_init($ipRouter . '/device_status.cgi'); curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookie.txt'); curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookie.txt'); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $content = curl_exec($ch); curl_close($ch); // parsing data $ambilData = preg_match_all('/\{([^}]+)\}/', $content, $matches); //oke // preg_match_all('/\{[^]]+\}/', $file, $matches); $data = ($matches[1][4]); // pecah perbaris $pecah = explode("\n", $data); // hapus baris yang tidak valid sebagai json "" unset($pecah[0]); unset($pecah[1]); unset($pecah[23]); // gabung kembali $gabung = implode("\n", $pecah); // tambahkan bracket // karena ini json ;) $tambahBracket = "{" . $gabung ."}"; // decode json $router = json_decode($tambahBracket); ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="description" content=""> <title>Login Router dengan PHP - Jaranguda.com</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <style type="text/css"> body { padding-top: 5rem; } .starter-template { padding: 3rem 1.5rem; text-align: center; } </style> </head> <body> <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top"> <a class="navbar-brand" href="#">Navbar</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarsExampleDefault"> <ul class="navbar-nav mr-auto"> <li class="nav-item active"> <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a> </li> <li class="nav-item"> <a class="nav-link" href="#">Link</a> </li> <li class="nav-item"> <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a> </li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a> <div class="dropdown-menu" aria-labelledby="dropdown01"> <a class="dropdown-item" href="#">Action</a> <a class="dropdown-item" href="#">Another action</a> <a class="dropdown-item" href="#">Something else here</a> </div> </li> </ul> <form class="form-inline my-2 my-lg-0"> <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search"> <button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button> </form> </div> </nav> <main role="main" class="container"> <table class="table"> <tr> <td>Manufacturer</td> <td><?php echo $router->Manufacturer ;?></td> </tr> <tr> <td>ModelName</td> <td><?php echo $router->ModelName ;?></td> </tr> <tr> <td>SerialNumber</td> <td><?php echo $router->SerialNumber ;?></td> </tr> <tr> <td>HardwareVersion</td> <td><?php echo $router->HardwareVersion ;?></td> </tr> <tr> <td>SoftwareVersion</td> <td><?php echo $router->SoftwareVersion ;?></td> </tr> <tr> <td>X_ASB_COM_Chipset</td> <td><?php echo $router->X_ASB_COM_Chipset ;?></td> </tr> <tr> <td>AdditionalSoftwareVersion</td> <td><?php echo $router->AdditionalSoftwareVersion ;?></td> </tr> <tr> </tr> </table> </main><!-- /.container --> </html>
Tampilannya
mau bikin jadi repeater/extender bisa gak?
Gan, kalo pakai inspect di browser, password yang ditampilkan PPPoE itu enskripsi atau bukan ya? Rencana mau bridge modem Balif****.
ngga bisa bos, di encrypt. Coba tanyain ke teknisi Balifiber nya aja langsung buat bridge.
Tujuan nge bridge apa ya?