46
Gambar 4.18 Aplikasi HTB Tool.
4.1.4. Script PHP
Dibawah ini adalah beberapa source code PHP yang digunakan dalam pembuatan interface router.
a. Source Code Untuk Melakukan Koneksi Telnet Dengan Quagga.
?php fp = fsockopen127.0.0.1, port, errno, errstr, 30;
if fp { echo errstr errnobr \n;
} else { out = _SESSION[vty].\r\n;
out .= enable\r\n; if port == 2601 {
out .= zebra\r\n; }
out .= prnth; out .= copy running-config startup-config\r\n;
out .= exit\r\n\r\n; fwritefp, out;
fclosefp; }
?
commit to user
47
b. Source Code Untuk Menampilkan List Network Interface.
ses list network interface
?php filename=list_int.txt;
fp = fsockopen127.0.0.1, 2601, errno, errstr, 30; if fp {
echo errstr errnobr \n; } else {
out = _SESSION[vty].\r\n;
out .= enable\r\n; out .= zebra\r\n;
out .= sho int\r\n; out .= exit\r\n\r\n;
fwritefp, out; buka=fopenfilename, w;
fwritebuka, ; fclosebuka;
while feoffp {
cek=fgetsfp, 128; list_if=cek;
buka = fopenfilename, a; fwritebuka, list_if;
fclosebuka; }
fclosefp; }
?
?php session_start;
ifisset_SESSION[user] isset_SESSION[pass] { ?
script language=javascriptdocument.location=..userlogin.phpscript ?php
} else { require_once list_iface.php;
? script type=textjavascript
function showIntstr {
if str== xmlhttp.onreadystatechange=function
{ if xmlhttp.readyState==4 xmlhttp.status==200
{ document.getElementByIdtxtHint.innerHTML=xmlhttp.responseText;
} }
xmlhttp.openGET,getuser.php?q=+str,true; xmlhttp.send;
} script
commit to user
48
{ document.getElementByIdtxtInt.innerHTML=;
return; } else if str= {
document.getElementByIdtxtInt.innerHTML=input type=submit value=set ; return;
} if window.XMLHttpRequest
{ xmlhttp=new XMLHttpRequest;
} else
{ xmlhttp=new ActiveXObjectMicrosoft.XMLHTTP;
} ac=;
output=; file = fopenfilename, r;
whilefeoffile { output = output . fgetsfile, 4096;
outputw = str_replace\n, , output; cek1=stristroutput, Interface ;
str=; if cek1==true {
str.=cek1; }
} fclose file;
stre=str_replace\n, \r\n, str; expl=explode\r\n, stre;
forc=0;c=countexpl-1;c++ { cek2=stristrexpl[c], Interface ;
ifemptycek2 { ac.=cek2.br;} }
req=explodebr, ac; echo bConfigure Network Interfacebbrbrpilih network interface yang
akan di set.br; echo form action=stat_ip.php method=post;
echo table border=0 cellspacing=1; echo trtdselect size=1 name=int
onchange=showIntthis.valueoption value=list interface:option; forw=0;wcountreq-1;w++ {
z=explode , req[w]; ifz[1]=lo {
echo option .z[1]. option; }
value=.z[1]. .z[1]. inputbr; }echo selecttdtddiv id=txtInt
divtdtrtableform; }
?
commit to user
49
c. Source Code Untuk Memproses Routing Statis.