流程

Appro IPNC使用的web服务器是boa。

请仔细理解下面这段话。

boa这个web服务器是GUI界面和IPNC应用程序之间的通信的桥梁。它的责任是从web GUI中接收HTTP请求,并且在解析请求之后将相应的参数和值传递回去。

通过HTTP抓包工具,我们可以更好的理解这段话..

我们使用wireshark,过滤条件是http && ip.src == 192.168.1.11,其中ip是你本机ip。

x79 bios性能模式_x79 bios性能模式

如上图所示,这就是我们使用IE打开打开IPNC设备IP,成功进入到登录界面时,捕捉到的包。

按照从上到下,我们可以清楚的看到整个请求的流程。

当然这上面是我修改过显示的结果(为了显示中英文的网页),和原始的不太一致,不过顺序没变。

首先,当然还是index.htm,这在nfs文件系统里的/var/www路径下可发现。

由于需要判断系统语言而选择加载不同web文件(gz),所以我用自动跳转glogon.cgi代码代替原有的index.htm中的内容。

加载顺序

loadactivex.htm->gLogon.htm->IPNCWebDlls.CAB->gIPNC-ro.gz

最原始的index.htm

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head>
<title>Multimedia Playback&Recording System</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1"></head>
<FRAMESET Rows="0%,100%"  border="0">
<frame src="loadActiveX.htm" noresize="noresize"/>
<frame src="gLogon.htm"/>
</FRAMESET>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head>
<title>Multimedia Playback&Recording System</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1"></head>
<FRAMESET Rows="0%,100%"  border="0">
<frame src="loadActiveX.htm" noresize="noresize"/>
<frame src="gLogon.htm"/>
</FRAMESET>
</html>

原始的loadActiveX.htm

<HTML>
<HEAD>
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="-1">
</HEAD>
<BODY>
    <OBJECT ID="gffx" CLASSID="CLSID:B2F190F0-1FA4-4D77-9ABD-1A054D23653D" Width=0 Height=0 codebase="/IPNCWebDlls.CAB#version=-1,-1,-1,-1"></OBJECT>
</BODY>
</HTML>
<HTML>
<HEAD>
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="-1">
</HEAD>
<BODY>
    <OBJECT ID="gffx" CLASSID="CLSID:B2F190F0-1FA4-4D77-9ABD-1A054D23653D" Width=0 Height=0 codebase="/IPNCWebDlls.CAB#version=-1,-1,-1,-1"></OBJECT>
</BODY>
</HTML>

原始的gLogon.htm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>DM365IPNC</title>
<meta http-equiv=Content-Type content="text/html; charset=UTF-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<script type="text/javascript"> 
    var currheight = -1;    
    var currwidth = -1; 
    var portno = "";
    if(location.port != "")
        portno = ":" + location.port
            
    var _0x225c=["\x69\x6E\x6E\x65\x72\x57\x69\x64\x74\x68","\x75\x6E\x64\x65\x66\x69\x6E\x65\x64","\x69\x6E\x6E\x65\x72\x48\x65\x69\x67\x68\x74","\x64\x6F\x63\x75\x6D\x65\x6E\x74\x45\x6C\x65\x6D\x65\x6E\x74","\x63\x6C\x69\x65\x6E\x74\x57\x69\x64\x74\x68","\x63\x6C\x69\x65\x6E\x74\x48\x65\x69\x67\x68\x74","\x62\x6F\x64\x79","\x77\x69\x64\x74\x68","\x68\x65\x69\x67\x68\x74"];var viewWidth;var viewHeight;if( typeof window[_0x225c[0x0]]!=_0x225c[0x1]){viewWidth=window[_0x225c[0x0]];viewHeight=window[_0x225c[0x2]];} else {if( typeof document[_0x225c[0x3]]!=_0x225c[0x1]&& typeof document[_0x225c[0x3]][_0x225c[0x4]]!=_0x225c[0x1]&&document[_0x225c[0x3]][_0x225c[0x4]]!=0x0){viewWidth=document[_0x225c[0x3]][_0x225c[0x4]];viewHeight=document[_0x225c[0x3]][_0x225c[0x5]];} else {viewWidth=document[_0x225c[0x6]][_0x225c[0x4]];viewHeight=document[_0x225c[0x6]][_0x225c[0x5]];} ;} ;
    
    function initPage(){
        if (viewWidth<1024) {viewWidth=1024}
        if (viewHeight<650) {viewHeight=650}
        if (document.GoDB){
            document.GoDB.width = viewWidth - 20
            document.GoDB.height = viewHeight
            document.GoDB.focus()
        }
    }
    function doResize(){
        parent.document.location.reload();
    }
</script>
</head>
<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 bgcolor=#000000 onload="initPage()" onresize="doResize()">
<table border=0 cellspacing=0 cellpadding=0>
<tr valign=middle align=center><td>
<script type="text/javascript"> 
document.write("<OBJECT ID=\"GoDB\" CLASSID=\"CLSID:4635CCA8-3D11-418B-8257-29CF0FE60069\" Width=1004 Height=650 codebase=\"/IPNCWebDlls.CAB#version=-1,-1,-1,-1\">")
document.write("<PARAM NAME=\"BDBUrl\" VALUE=\"http://"+location.hostname+portno+"/gIPNC-ro.gz\"></PARAM>")
document.write("<SPAN style=\"font-family: Verdana; font-size: 9px; font-weight: normal; color: #FFFFFF\">The ActiveX control that displays the application has not been installed.      <a href=\"#\" onclick=\"javascript:document.location.reload()\">Reload Page</a></SPAN></OBJECT>")
</script>
</td></tr>
</table>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>DM365IPNC</title>
<meta http-equiv=Content-Type content="text/html; charset=UTF-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<script type="text/javascript"> 
    var currheight = -1;    
    var currwidth = -1; 
    var portno = "";
    if(location.port != "")
        portno = ":" + location.port
            
    var _0x225c=["\x69\x6E\x6E\x65\x72\x57\x69\x64\x74\x68","\x75\x6E\x64\x65\x66\x69\x6E\x65\x64","\x69\x6E\x6E\x65\x72\x48\x65\x69\x67\x68\x74","\x64\x6F\x63\x75\x6D\x65\x6E\x74\x45\x6C\x65\x6D\x65\x6E\x74","\x63\x6C\x69\x65\x6E\x74\x57\x69\x64\x74\x68","\x63\x6C\x69\x65\x6E\x74\x48\x65\x69\x67\x68\x74","\x62\x6F\x64\x79","\x77\x69\x64\x74\x68","\x68\x65\x69\x67\x68\x74"];var viewWidth;var viewHeight;if( typeof window[_0x225c[0x0]]!=_0x225c[0x1]){viewWidth=window[_0x225c[0x0]];viewHeight=window[_0x225c[0x2]];} else {if( typeof document[_0x225c[0x3]]!=_0x225c[0x1]&& typeof document[_0x225c[0x3]][_0x225c[0x4]]!=_0x225c[0x1]&&document[_0x225c[0x3]][_0x225c[0x4]]!=0x0){viewWidth=document[_0x225c[0x3]][_0x225c[0x4]];viewHeight=document[_0x225c[0x3]][_0x225c[0x5]];} else {viewWidth=document[_0x225c[0x6]][_0x225c[0x4]];viewHeight=document[_0x225c[0x6]][_0x225c[0x5]];} ;} ;
    
    function initPage(){
        if (viewWidth<1024) {viewWidth=1024}
        if (viewHeight<650) {viewHeight=650}
        if (document.GoDB){
            document.GoDB.width = viewWidth - 20
            document.GoDB.height = viewHeight
            document.GoDB.focus()
        }
    }
    function doResize(){
        parent.document.location.reload();
    }
</script>
</head>
<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 bgcolor=#000000 onload="initPage()" onresize="doResize()">
<table border=0 cellspacing=0 cellpadding=0>
<tr valign=middle align=center><td>
<script type="text/javascript"> 
document.write("<OBJECT ID=\"GoDB\" CLASSID=\"CLSID:4635CCA8-3D11-418B-8257-29CF0FE60069\" Width=1004 Height=650 codebase=\"/IPNCWebDlls.CAB#version=-1,-1,-1,-1\">")
document.write("<PARAM NAME=\"BDBUrl\" VALUE=\"http://"+location.hostname+portno+"/gIPNC-ro.gz\"></PARAM>")
document.write("<SPAN style=\"font-family: Verdana; font-size: 9px; font-weight: normal; color: #FFFFFF\">The ActiveX control that displays the application has not been installed.      <a href=\"#\" onclick=\"javascript:document.location.reload()\">Reload Page</a></SPAN></OBJECT>")
</script>
</td></tr>
</table>
</body>
</html>

我们直接看body标签下的OBJECT标签。CLASSID和CODEBASE分别指定了IPNCWebDlls.CAB在系统中的位置(dll文件)和在web服务器中的位置。如果当前系统找不到这个插件的话,则从web服务器中下载。有则加载。

PARAM标签则是添加/gIPNC-ro.gz对象,这就是TI IPNC Web的主体文件。而上面的IPNCWebDlls.CAB文件则是网页中播放rtsp的ActiveX插件。

所以关于TI IPNC的Web开发,都是围绕这两个文件来进行的。

TI IPNC Web网页之GoDB开发环境此文列出的文件列表中,在GUI/docs中有一个文档为

GUI_Keywords_IPNC.xls,一开始看上去你可能有些摸不着头脑。没听说boa服务器下的网页需要什么关键字。原来,IPNC RDK中,boa是修改过,配合GoDB界面来改的,所以这份关键字存在与boa和GoDB工程中的代码中,一一对应的。

我们再次使用wireshark进行抓包,会发现一些东西:

下面这幅图是在登录成功之后抓到包...

x79 bios性能模式_x79 bios性能模式_02

先从ini.htm这个url来分析,你不用在文件系统里面寻找了,找不到这个文件的,他是直接在boa代码里面分析处理的。

web浏览器发出请求然后返回(也就是HTTP Reuqst和HTTP Repsonse)。

关于HTTP协议可参考这篇文章HTTP Request header

ini.htm的作用是返回所有关键字的值,然后GoDB将其保存起来,供各个页面读取。

GET /ini.htm HTTP/1.1
Accept: */*
Authorization: Basic YWRtaW46YWRtaW4xMjM=
User-Agent: gSync
Host: 192.168.1.181
DNT: 1
Connection: Keep-Alive
Cache-Control: no-cache

HTTP/1.1 200 OK
Date: Sat, 25 Oct 2014 05:33:43 GMT
Server: Boa/0.94.13
Connection: close
Content-Type: text/html
Content-Length: 18841
Last-Modified: Sat, 25 Oct 2014 05:33:43 GMT

motionxlimit=1280<br>motionxblock=4<br>motionyblock=3<br>authorityadmin=0<br>authorityoperator=1<br>authorityviewer=2<br>user=user1:admin
user2:tracyone
user3:hehe
user4:tracysecondd
user5:aaae
user6:
user7:
user8:
user9:
user10:
user11:
user12:
user13:
user14:
user15:
user16:
<br>authority=authority1:0
authority2:1
authority3:0
authority4:0
authority5:0
authority6:9
authority7:9
authority8:9
authority9:9
authority10:9
authority11:9
authority12:9
authority13:9
authority14:9
authority15:9
authority16:9
01001000000000000
02001000000000000
03001000000000000
04001000000000000
05001000000000000
06001000000000000
07001000000000000
<br>trackip=192.168.1.31:802<br>cloudip=192.168.1.120:8001<br>rtmp_url=rtmp://192.168.1.120:1935/live/mpr6000<br>ftp_upload_time=0000<br>recordlocalstorage=2<br>ftp_upload_option=1<br>file_size=0<br>video_long=3<br>schedulerepeatenable=0<br>schedulenumweeks=52<br>scheduleinfiniteenable=1<br>kernelversion=Linux version 2.6.37_DM8127_IPNC_3.50.00 <br>biosversion=U-Boot 2010.06-svn (Dec 25 2014 - 14:23:24) DM8127_IPNC_3.50.00<br>softwareversion=DM8127 IPNC RDK VERSION 03.50.00.08<br>sdinsert=0<br>sdleft=46325760<br>sdused=48795648<br>usbinsert=0<br>hddinsert=0<br>display_mode=3<br>ppt_sw_en=0<br>ppt_sw_sensitivity=0<br>ppt_sw_interval_time=0<br>psname=0;1;2;3;4<br>piname=10 seconds;15 seconds;30 senconds;1 minutes;2 minutes;3 minutes<br>channel_id=0<br>ch_id_name=1;2;3;4<br>language=0<br>reloadflag=0<br>reloadtime=28<br>maxaccount=16<br>minnamelen=4<br>maxnamelen=32<br>minpwdlen=4<br>maxpwdlen=16<br>bkupfirmware=0<br>

...省略....

Authorization: Basic YWRtaW46YWRtaW4xMjM=

这里使用的认证方式是:Basic access authentication

这种认证方式,一句话评价,只能防住电脑小白...

接下来是

vb.htm?paratest=keyword

这样的形式查询具体某个关键字的值,有那些关键字,那就得查询GUI_Keywords_IPNC.xls这个文档了...

当然关键字的查询是通过

vb.htm?keyword这样的形式。百思不得其解,从boa代码里面分析的话,原作者一开始采用这样的方式获取各个关键字值,但是后面发现这样需要定义太多重复函数,就采取上面的形式...

总之,通过这样的http请求,GoDB可以获取关键字的值然后填充各个控件。

然后通过

vb.htm?keyword1=xx&keyword2=xxx

这样的形式,进行设置。