GithubHelp home page GithubHelp logo

digoo-m1x_hacks's Introduction

DIGOO DG-M1X hacks

This is a log of simple hacks for the cheap, linux driven, Digoo DG-M1X. For now, this is only about to bring wifi up without using the app, setting the correct time(-zone) and installing an ssh server in place for the shipped telnetd. The API of the pan-tilt-zoom (ONVIF) service could also be reverse engineered.

Out of the box, this cam "features":

  • open telnet access as root (at least on this firmware Linux goke 3.4.43-gk #56 PREEMPT Fri Sep 29 00:24:56 PDT 2006 armv6l GNU/Linux)
  • ONVIF accessible at port 5000. Due to the android app tinyCam Monitor, it is supposed to use ONVIF Profile S (but as well as a lot of other people, I couldn't get it to work in other software).
  • rtsp access with user: admin, pw: 20160404 at port: 554 and path: /onvif1 (respectively /onvif2 with lower quality), e.g. vlc rtsp://admin:20160404@<your-cams-ip>/onvif1
  • PTZ control, through ONVIF XML commands, such as the ones proposed below.

Using these rtsp parameters, I could get it to setup manually in every software I tried so far.

For PTZ support on Home Assistant, check this tutorial: https://community.home-assistant.io/t/digoo-dg-m1x-working-a-sub-30-camera/21397/39?u=redalert

Of course: Everything at your own risk here…

Setup

First of all, make sure to disable internet access for the cam! (e.g. using your fritzbox parental controls or iptables of your router)

To setup the wifi of your m1x, you may simply telnet to the cam as root (no password) and edit /rom/wpa_supplicant0.conf For the inital connection I used an ethernet cable..

ctrl_interface=/etc/Wireless  
 network={ 
     ssid="$SSID"   
     psk="$yourpw"
  }

Reboot and the cam should be connected to your network.

To replace telnet with ssh, copy all files of npc to /npc on your cam (TODO, please have a closer look on what you are doing here, this is not failsafe atm). You can do this e.g. using wget (the wget embedded in busybox is not capable of https/tls) or by inserting a sd card (not tested). Thx thomas (https://github.com/ant-thomas/zsgx1hacks) for pre-compiling dropbearmulti!

Generate your own password hash with openssl passwd -1 (follow the prompt) and add it to do.sh For a public key authentication to work, add your public key(s) in npc/root-home/.ssh/authorized_keys Then execute do.sh and everything should be setup. To make this persistent, add sh /npc/do.sh to /npc/boot.sh (skip this if you already copied the file to the cam). You should however always make sure that your script is working. Otherwise the cam could get inaccessible from the network.

Persistency

# cat /proc/mounts 

rootfs / rootfs rw 0 0
/dev/root / squashfs ro,relatime 0 0
proc /proc proc rw,relatime 0 0
tmpfs /dev tmpfs rw,relatime 0 0
tmpfs /tmp tmpfs rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
devpts /dev/pts devpts rw,relatime,mode=600,ptmxmode=000 0 0
/dev/ram0 /mnt/ramdisk tmpfs rw,relatime 0 0
/dev/ram0 /etc tmpfs rw,relatime 0 0
/dev/ram0 /tmp tmpfs rw,relatime 0 0
/dev/mtdblock4 /rom jffs2 rw,relatime 0 0
/dev/mtdblock5 /npc jffs2 rw,relatime 0 0

To store files persistently use /rom or /npc. Here, /rom is used for setting up wifi in /rom/wpa_supplicant0.conf and /npc is used for all other stuff. /npc/boot.sh can be used to trigger commands in the boot process, e.g. our own init script (sh /npc/do.sh).

Sync time

The busybox in this cam does not ship any ntp binaries but uses rdate to let you sync time with remote servers (it also appears to not have a hardware clock)

# hwclock -r

Thu Jan  1 00:00:00 1970  0.000000 seconds

As rdate is very uncommon these days, you have to find a sync server that supports rdate clients (e.g. time.fu-berlin.de or time-a-g.nist.gov).

For the correct time to show up, add your corresponding timezone file inside a persistent folder (e.g. /npc/zoneinfo). You will find those files on most linux systems in /usr/share/zoneinfo/. It is important to not only copy the actual binary timezone file, but also to create the folder it is residing in and symlink that to /etc/localtime, for example for Berlin ln -s /npc/zoneinfo/Europe/Berlin /etc/localtime.

PTZ

I do not assume this cam is following the official ONVIF standard as most ONVIF clients are not working with it (although I do not have any clue about the ONVIF standard). Using the android app tinyCam Monitor and packet capture), I could monitor all pan and tilt actions and quickly reverse engineered the appropriate commands. Please note that so far I didn't have a closer look into how the password and nonce is managed , authentication is not done at all…, see the example request. For pan and tilt, send a SOAP request with the following body to port 5000 on path /onvif/device_service, e.g. for moving to the left (see ptz_request.xml or listing below):

curl -H "Content-Type: application/soap+xml" -X POST -d "@ptz_request.xml" http://$your-cams-ip:5000/onvif/device_service

And the plain xml body:

<v:Envelope 
    xmlns:i="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:d="http://www.w3.org/2001/XMLSchema" 
    xmlns:c="http://www.w3.org/2003/05/soap-encoding" 
    xmlns:v="http://www.w3.org/2003/05/soap-envelope">
    <v:Header>
        <Security v:mustUnderstand="1" 
            xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <UsernameToken 
                xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                <Username>admin</Username>
                <Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">tada_your_non_exisisting_password=</Password>
                <Nonce>non_existing_nonce</Nonce>
                <Created 
                    xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2018-01-16T11:43:32Z
                </Created>
            </UsernameToken>
        </Security>
    </v:Header>
    <v:Body>
        <ContinuousMove 
            xmlns="http://www.onvif.org/ver20/ptz/wsdl">
            <ProfileToken>IPCProfilesToken0</ProfileToken>
            <Velocity>
                <PanTilt 
                    xmlns="http://www.onvif.org/ver10/schema" x="-1.0" y="0.0"/>
            </Velocity>
        </ContinuousMove>
    </v:Body>
</v:Envelope>

Specification: https://www.onvif.org/ver20/ptz/wsdl/ptz.wsdl

Table of possible movements (see PanTilt tag)

x y Action
0.0 -1.0 move down
0.0 1.0 move up
1.0 0.0 move to the right
-1.0 0.0 move to the left

Software

The Digoo DG-M1Q inspected by e.g, kfowlks and yuvadm seems to run a similar (if not the same) software like the m1x. Find dmesg, pictures, serial logs, etc. there.

TODO

  • scp: link scp from dropbearmulti to $PATH?
  • disable internet access using hosts file?
  • remove telnetd

digoo-m1x_hacks's People

Contributors

felixsteghofer avatar sduniii avatar tiagofreire-pt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

digoo-m1x_hacks's Issues

Camera refuses to work if Internet access is blocked

Hi,

I have the same camera with the same firmware version and every time I block the internet access of it, the camera doesn't boot properly.
I block the internet access in the ISP router, based on the camera's MAC address. I'm using the ethernet connection as I don't like cameras on WIFI.
When troubleshooting it I found the binary that I suspect that is related to this and it is the /patch/bin/startup one. As it is a binary, I can't edit and remove what I don't need, right?

Any suggestion?

Thanks,
Joao

startup 0 0
no key detect
vStarNpc:
# setenv:/usr/bin:/usr/sbin:/bin:/sbin:/patch/bin
/rom/erobotremotecontrolsetting.ini does not exist!!
Language=:
  0    1    5
default Language=0:
insmod: can't insert '/npc/patch/sc1135.ko': File exists
Certificate: rom file ok, eeprom ok
info:  RTC has been used before, no need to init it
<1>Sun Jan  1 01:01:01 2010
<3>Fri Jan  1 01:01:01 2010
vVarInit
vVarInit  fgDefenseEn = 0
>>vVarInit11
>>vVarInit22
>>vVarInit33 dwSetWiFiTimer=300
Have no whitelist!!!
P2PModuleInit
init P2P Module
|p2p1.cloudlinks.cn|p2p4.cloud-links.net|p2p2.cloudlinks.cn|p2p3.cloud-links.net|p2p5.cloud-links.net|p2p6.cloud-links.net|p2p7.cloudlinks.cn|p2p8.cloud-links.net|p2p9.cloud-links.net|p2p10.cloud-links.net
cEmailAddr[0] is 0xffcEmailAddr:
vGetUserData !
Enter fgMyReadAppIDFromCard:
dwMyBundingAppID[0] = 0
dwMyBundingAppID[1] = 0
dwMyBundingAppID[2] = 0
dwMyBundingAppID[3] = 0
dwMyBundingAppID[4] = 0
**********dwMy3CID = 7499454  R1=0x5dcfe4f R2=0xc279d439****************
*************vNetMg_Init******************



Onvif init!!!


vRtspServderThreadStar star!
Disk init
******dev type:10
bind:Address already in use
vDiskProc begin
**pCurrSetting->bNetSel** = 0,fgIPAuto = 1,bIPByte3 = 123,fgVersionFlag = 0
GOKE ADI: R(8724) LIBC(uClibc) (gcc version 4.6.1 (crosstool-NG 1.18.0) ) Sat Jun 25 04:57:54 CST 2016
gk_osd_init fgCmosDirNormal
gk_osd_init fgCmosDirNormal
gk_osd_init fgCmosDirNormal
gk_osd_init fgCmosDirNormal
gk_osd_init fgCmosDirNormal
gk_osd_init fgCmosDirNormal
gk_osd_init fgCmosDirNormal
gk_osd_init fgCmosDirNormal
gk_osd_init fgCmosDirNormal
gk_osd_init fgCmosDirNormal
gk_osd_init fgCmosDirNormal
gk_osd_init fgCmosDirNormal
gk_osd_init fgCmosDirNormal
gk_osd_init fgCmosDirNormal
gk_osd_init fgCmosDirNormal
gk_video_init:283
Image library version (gcc version 4.6.1 (crosstool-NG 1.18.0) (uClibc)) v1.1.2 #svn r9021 Wed Jul 13 15:44:41 CST 2016
gk_video_open:373
>>dwCmosReverseSupport22222222222222
>>viParams.mirrorMode.mirrorPattern=3
now timezoom = 19
viWidth=1280, viHeight=960
gk_check_encode_streams_params:1208
resolution order of streams : 0, 1, 3, 2,
gk_video_set_h264_param:758,channelID=0,streamID=0
res width=1280,height=960
gk_video_set_venc_param 11
gk_video_set_h264_param:758,channelID=1,streamID=1
res width=1280,height=960
gk_video_set_venc_param 11
gk_video_set_h264_param:758,channelID=2,streamID=2
res width=320,height=240
gk_video_set_venc_param 11
MCU controls motor
3CID=7499454, CustomerID=85,  SubType=10
dwPassword = 20160404
=======================================
[GK]DE-MBLK 4x4 basing on 1/16 orig pic version: v2.1.0
=======================================

=====  Now AT24CXX used 255 Bytes=====
do not have such file!
ready to main loop!!!
fgEth0Support = 1,fgRa0Support = 1
>>>CheckMacHwaddr MacAddr = 4c:b0: 8:c2:d2:52
>>>CheckMacHwaddr MacAddr = 4c:b0: 8:c2:d2:52
>>>vEth0Init MacAddr = 4c:b0: 8:c2:d2:52
Support eth0!
Init SSID=Free-AP0 , EncType=0, Password=

Init SSID=Free-AP1 , EncType=0, Password=

Init SSID=Free-AP2 , EncType=0, Password=

Init SSID=Free-AP3 , EncType=0, Password=

Init SSID=Free-AP0 , EncType=0, Password=

wifi init
ctrl_iface exists and seems to be in use - cannot override it
Delete '/etc/Wireless/wlan0' manually if it is not used anymore
Failed to initialize control interface '/etc/Wireless'.
You may have another wpa_supplicant process already running or the file was
left by an unclean termination of wpa_supplicant in which case you will need
to manually remove this file before starting wpa_supplicant again.

udhcpc (v1.21.0) started
Sending discover...
udhcpc (v1.21.0) started
sleep over!dwNowNetSel = 0
vNetDelSel:  fgBeforeEth0Link()  Failed!
Sending discover...
Sending discover...
fgEth0Sta = 1
vNetSelChange Select=0
>>vNewNetMgProc dwNetCommand=1
>>vNewNetSelDoChange11
Sending discover...
Entering released state
Entering released state
Performing a DHCP renew
Sending discover...
Performing a DHCP renew
Sending discover...
Sending discover...
Sending select for 192.168.1.14...
Lease of 192.168.1.14 obtained, lease time 43200
deleting routers
route: SIOCDELRT: No such process
adding dns 192.168.1.1
fgUpdateLocalDnsFile:nameserver  192.168.1.1
dwGetKey() = 147,dwUIState = 0
Play: /npc/sound/WifiLink_en/OnLine_en.amr
create adec chn6 success
fgAOEnable=0; fgEn=1
Info: vAOControl,fgAIEnable=0
++++++++++++++create+++++++++++++++
vAOControl enable
dwSpeakVol = 185
open audio file fail
fgAOEnable=1; fgEn=0
-----------------destory---------------
vAOControl disable 0
Destroy adec chn6 success
vCheckPlaySoundEnd
dwGetKey() = 240,dwUIState = 0
vOnvifStartProc:Eth link!!!
[onvif_server.c][292][00:00:05][Onvif_Probe] start

Onvif_DeviceMng[Line:383]


[onvif_server.c][302][00:00:05][Onvif_Probe] ServerSoap.version = 2
Socket connection successful: master socket = 15
Sending discover...
Play: /npc/sound/WifiLink_en/WaitLink_en.amr
create adec chn6 success
fgAOEnable=0; fgEn=1
Info: vAOControl,fgAIEnable=0
++++++++++++++create+++++++++++++++
vAOControl enable
dwSpeakVol = 185
vSoundPlayProc  enter
[ERROR] gadi_audio_ao_send_frame failed,errno=-2015
ao send frame err:0xffffffff
vSoundPlayProc  exit**
fgAOEnable=1; fgEn=0
-----------------destory---------------
vAOControl disable 0
Destroy adec chn6 success
vCheckPlaySoundEnd
dwGetKey() = 240,dwUIState = 0
Sending discover...
Sending discover...
Sending discover...
Sending discover...
Sending discover...
Sending discover...
Sending discover...
Sending discover...
Sending discover...
>>upg HTTP_UPG_STATE_CHECK_WHITELIST
Sending discover...
Sending discover...
No lease, forking to background

Version:
Linux goke 3.4.43-gk #56 PREEMPT Fri Sep 29 00:24:56 PDT 2006 armv6l GNU/Linux

dg-ulc

Does this hack also work with dg-ulc outdoor cam lamp?

The official app (ucam) doesn't work anymore and is required to setup initial wifi, which makes the cam functionality useless.

dg-ulc does have a SD card reader!

PTZ for position presets or absolute position

Hi.

Would be awesome to command the camera for specific point of view, correlated with HA automations. Such as, a specific door opens and the camera points to there.

@felixsteghofer , could you provide an XML example for setting and getting the camera to specific absolute positions, like presets, as the Digoo BB-M2 has, please?

Thanks.

forget to change $password-hash

Hello, I forgot to change the $password-hash in the do.sh file. Now I have no access via root to copy the files with the correct hash. Is there any way to undo this?

thx

Can’t login with root via telnet or ssh

Can’t login with root anymore (telnet nor ssh) I’ve followed the description, copied files from npc on sd card to internal npc. What’s maybe the problem?

Thanks in advance.

Issues with DG-M1X HD 960P

Hey I bought a DG-M1X HD 960P but am having issues getting a shell.
I just set up a dhcp server on my notebook to isolate this device from the internet while setting it up.
I get connection refused if I try to ssh or telnet to the camera; but I can watch the rtsp streams (even though they are quite low quality and onvif2 seems to lag >10sec)

Any ideas? If I curl to the camera at port 5000 I get some xml back..
How did you get the shell originally? Simply telnet?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.