3

I'm trying to sniff RTMP streams from my IPCAM for recording them separately from my computer. Unfortunately, they do not support RTSP unless connected directly to the PC instead of the NVR, however, I noticed that the web gui has RTMP streams that seem to work remotely as well as locally and I was hoping to sniff them and record the same. The camera support said they cannot help me with this. The system works really well and I'd hate to change them. The brand of the cameras are OOSSXX and they use 3rd party apps like eseecloud and IP Pro that work well with them.

Here's the relevant code:

$(document).ready(function(){
    dvr_camcnt = Cookies.get("dvr_camcnt");
    iSetAble = Cookies.get("iSetAble");
    iPlayBack = Cookies.get("iPlayBack");
    dvr_usr = Cookies.get("dvr_usr");
    dvr_pwd = Cookies.get("dvr_pwd");
    if(iSetAble == '0'){
        $('#pb_settings').css('display','none');
        }
    if(iPlayBack == '0'){
        $('#pb_review').css('display','none');
        }
    if(dvr_camcnt == null || dvr_usr == null || dvr_pwd == null)
    {
        location.href = "/index.html";
    }

    var urlarg=new getarg();
    if(urlarg.type == "main")
    {
        dvr_type = "main";
        $("#lst_type")[0].selectedIndex = 0;
    }
    else
    {
        dvr_type = "sub";
        $("#lst_type")[0].selectedIndex = 1;
    }

    var flashvars =
    {
        player_max: dvr_camcnt,
        usr:dvr_usr,
        pwd:dvr_pwd
    };
    var params =
    {
        player_max: dvr_camcnt,
        allowFullScreen: "true"
    };
    var attributes =
    {
        id: "viewer",
        name: "viewer"
    };
    swfobject.embedSWF("JaViewer.swf?player_max=4", "flashcontent", "100%", "100%", "10.2.0","expressinstall.swf", flashvars, params, attributes);

    var container = $("#chn_container")[0];
    for(var i = 0; i < dvr_camcnt; i++)
    {
        var str = "<div style=\"color:#FFFFFF;\"><img id=\"chn_status_" + i + "\" align=\"absmiddle\" src=\"images/ch_1.jpg\" width=\"28\" height=\"18\" onMouseOver=\"pic_btn_over(this)\" onMouseOut=\"pic_btn_out(this)\" onMouseDown=\"pic_btn_down(this)\" onMouseUp=\"pic_btn_up(this)\"><span lxc_lang=\"view_Channel\">Channel</span>" + (i+1) + "&nbsp;<a href=\"/cgi-bin/snapshot.cgi?chn=" + i + "&u=" + dvr_usr + "&p=" + dvr_pwd + "&q=0&d=1&rand=" + Math.random() + "\" style=\"color:white; text-decoration:none;\"><span lxc_lang=\"view_snapshot\">Snapshot</span></a></div>";
        container.innerHTML += str;
    }

    language_show_page("view_title");
    setTimeout(goto_open_all, 2000);
});
function goto_open_all()
{
    if(dvr_viewer && dvr_viewer.ConnectRTMP)
    {
        dvr_viewer.SetPlayerNum(dvr_camcnt);
        dvr_viewer.Login(dvr_usr, dvr_pwd, "");
//      switch(dvr_camcnt)
//      {
//      case "4":
//          dvr_viewer.flSetViewDiv(4);
//          break;
//      case "8":
//          dvr_viewer.flSetViewDiv(9);
//          break;
//      case "16":
//          dvr_viewer.flSetViewDiv(16);
//          break;
//      case "24":
//          dvr_viewer.flSetViewDiv(25);
//          break;
//      }
        open_all(dvr_camcnt);
    }
    else
    {
        dvr_viewer = $("#viewer")[0];
        setTimeout(goto_open_all, 1000);
    }
}
function open_one(index)
{
    if($("#chn_status_" + index)[0].parentNode.style.fontSize=="16px" || $("#chn_status_" + index)[0].parentNode.style.fontSize=="")
    {
//      dvr_viewer.flSetDomain(index, "http://" + window.location.host + "/");
//      dvr_viewer.flConnectVideo(index, dvr_type == "main" ? 1 : 0);
        dvr_viewer.SetPoster(index, "/cgi-bin/snapshot.cgi?chn=" + index + "&u=" + dvr_usr + "&p=" + dvr_pwd + "&q=0&d=1&rand=" + Math.random());
        dvr_viewer.ConnectRTMP(index, "rtmp://" + location.host, "ch" + index + "_" + (dvr_type=="main"?"0":"1") + ".264");
        $("#chn_status_" + index)[0].parentNode.style.color="#ffffff";
        $("#chn_status_" + index)[0].parentNode.style.fontSize="17px";

        for(var i = 0; i < dvr_camcnt; i++)
        {
            if($("#chn_status_" + i)[0].parentNode.style.fontSize != "17px")
            {
                $("#pb_disconn_all")[0].parentNode.style.color="#ffffff";
                $("#pb_conn_all")[0].parentNode.style.color="#ffffff";
                return;
            }
        }
        $("#pb_disconn_all")[0].parentNode.style.color="#ffffff";
        $("#pb_conn_all")[0].parentNode.style.color="#000000";
        return;
    }
}
function open_all(_count)
{
    for(var i = 0; i < _count; i++)
    {
        open_one(i);
    }
}

function close_one(index)
{
    if($("#chn_status_" + index)[0].parentNode.style.fontSize=="17px")
    {
//      dvr_viewer.flDisconnectVideo(index);
        dvr_viewer.Disconnect(index);
        $("#chn_status_" + index)[0].parentNode.style.fontSize="16px";
        $("#chn_status_" + index)[0].parentNode.style.color="#000000";
        $("#pb_disconn_all")[0].parentNode.style.color="#000000";

        for(var i = 0; i < dvr_camcnt; i++)
        {
            if($("#chn_status_" + i)[0].parentNode.style.fontSize == "17px")
            {
                $("#pb_disconn_all")[0].parentNode.style.color="#ffffff";
                $("#pb_conn_all")[0].parentNode.style.color="#ffffff";
                return;
            }
        }
        $("#pb_disconn_all")[0].parentNode.style.color="#000000";
        $("#pb_conn_all")[0].parentNode.style.color="#ffffff";
        return;

    }
}

function close_all()
{
    for(var i = 0; i < dvr_camcnt; i++)
    {
        close_one(i);
    }
}

function toggle_one(index)
{
    if($("#chn_status_" + index)[0].parentNode.style.fontSize == "16px" || $("#chn_status_" + index)[0].parentNode.style.fontSize == "")
    {
        open_one(index);
    }
    else
    {
        close_one(index);
    }
}

As you can see there, the RTMP link should be rtmp://host/ch#_1.264 (Host is the local IP or remote domain/IP and # would be the camera channel number; also, I need the sub stream so it would be 1.264 and no 0.264). However, that doesn't seem to work.

Any ideas on what I might be missing here? Thanks in advance.

user3839044
  • 235
  • 1
  • 6
  • 22
  • Have you tried this [RTMP Snoop repo on github](https://github.com/andreafabrizi/rtmpSnoop/blob/master/rtmpSnoop.py)? I never tried, but it might help. Also, I would recommend using [Scapy](https://scapy.net) if you want to do it from scratch. – Abdurahman Mar 30 '20 at 14:31
  • Thanks for responding! I haven't tried it as I don't have linux on my new PC. I haven't used linux in ages so will have to reinstall and try if there are no better options. Any windows equivalent? I have tried rtmpdump, rtmpdumphelper. wireshark, urlhelper and HiDownload (which actually was able to download streams but gave me the same rtmp format as listed above but that doesn't work on directly playing the stream for some reason. – user3839044 Mar 30 '20 at 15:26
  • @user3839044 Did you ever find out? I am also trying to capture the stream so it records elsewhere as my nvr died – Kevin Nov 03 '20 at 20:40
  • @user3839044 have you looked at this: https://www.reddit.com/r/ShinobiCCTV/comments/jf1rzz/help_with_oossxx_k9608w_nvr/ – Kevin Nov 03 '20 at 23:42
  • @Kevin - Yours would be easier to pull off as RTSP is supported if connected directly from the CPU, however, not using the NVR. That link unfortunately is for exactly that purpose. I'm trying to get the streams when then NVR is in place. In this case, the subnet changes so there's a firewall in the NVR that prevents iptable routes that I use in place. – user3839044 Dec 28 '20 at 17:10

0 Answers0