├── repacking └── .dot ├── plugins ├── tg_guard.sh ├── tg_reboot.sh ├── firstboot ├── tg_system.sh ├── tapip ├── tg_relay.sh ├── tg_snap.sh ├── ipcam_mqtt_listner ├── ipcam_tunnel ├── ipcam_wifi ├── ipcam_system ├── ipcam_combine ├── ipcam_tgbot └── ipcam_menu ├── LICENSE └── README.md /repacking/.dot: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /plugins/tg_guard.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Exec /guard command 4 | 5 | echo $(date +%s) >/tmp/guard.lock 6 | echo "Guard alert timeout activated" 7 | -------------------------------------------------------------------------------- /plugins/tg_reboot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Exec /reboot command 4 | 5 | echo "Reboot process started!" 6 | cp /var/tmp/telegram_offset /mnt/mtd/telegram_offset 7 | sleep 2 8 | reboot -------------------------------------------------------------------------------- /plugins/firstboot: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | clear 4 | echo 5 | echo "Remove ModdingIPC configs and reboot device..." 6 | echo 7 | rm -vf /mnt/mtd/ipcam.conf /mnt/mtd/crontabs/root 8 | sleep 1 9 | reboot 10 | -------------------------------------------------------------------------------- /plugins/tg_system.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Exec /system command 4 | 5 | echo "Uptime:" 6 | uptime 7 | echo "" 8 | echo "Memory:" 9 | free | awk '/Mem/ {print "Total: "$2" |","Used: "$3" |","Free: "$4}' 10 | -------------------------------------------------------------------------------- /plugins/tapip: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # ZFT Lab. 2018 | http://zftlab.org/pages/2018010700.html 4 | # Simple script for get IP via UDHCPC on VTUN TAP interface 5 | 6 | 7 | case "$1" in 8 | 9 | deconfig) 10 | ip a flush dev $interface 11 | ;; 12 | 13 | renew|bound) 14 | ip a add $ip/$subnet dev $interface 15 | ;; 16 | 17 | esac 18 | 19 | exit 0 20 | -------------------------------------------------------------------------------- /plugins/tg_relay.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Exec /relay command 4 | 5 | #STATUS=`cat /sys/class/gpio/gpio20/value` 6 | 7 | 8 | if [ "${STATUS}" == "1" ]; then 9 | echo "Relay current ON => turn it to OFF" 10 | #echo "0" >/sys/class/gpio/gpio20/value 11 | else 12 | echo "Relay module not found" 13 | fi 14 | 15 | if [ "${STATUS}" == "0" ]; then 16 | echo "Relay current OFF => turn it to ON" 17 | #echo "1" >/sys/class/gpio/gpio20/value 18 | else 19 | echo "Relay module not found" 20 | fi 21 | -------------------------------------------------------------------------------- /plugins/tg_snap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # ZFT Lab. 2018 | http://zftlab.org/pages/2018010700.html 4 | # Telegram Bot - Snapshot 5 | 6 | 7 | IPC=/mnt/mtd/ipcam.conf 8 | TMP=/var/tmp 9 | 10 | 11 | if [ -f ${IPC} ]; then 12 | while read settings 13 | do local ${settings} 14 | done < ${IPC} 15 | # 16 | if [ ${socks5_enable} = 1 ]; then 17 | curl_options="-s -k --socks5-hostname ${socks5_server}:${socks5_port} --proxy-user ${socks5_login}:${socks5_password}" 18 | else 19 | curl_options="-s -k" 20 | fi 21 | # 22 | stamp=$(date +%Y.%m.%d_%H:%M:%S) 23 | # 24 | # curl -s -k "http://127.0.0.1/webcapture.jpg?command=snap&channel=1" -o ${TMP}/snap.jpg 25 | getxmsnap ${TMP}/snap.jpg && \ 26 | curl ${curl_options} -X POST "https://api.telegram.org/bot${telegram_token}/sendPhoto?chat_id=${telegram_group}" -H "Content-Type: multipart/form-data" \ 27 | -F "photo=@${TMP}/snap.jpg" -F "caption=${device_name} - ${stamp}" >/dev/null 2>&1 && \ 28 | rm -rf ${TMP}/snap.jpg 29 | # 30 | fi -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 OpenIPC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /plugins/ipcam_mqtt_listner: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Simple Comand Plugin for MQTT OpenIPC mod 3 | # Author Philipp@inbox.ru 2021 4 | # Licence MIT 5 | # based on https://github.com/pkoevesdi/MQTT-Logger 6 | 7 | 8 | IPC=/mnt/mtd/ipcam.conf 9 | mpipe=/tmp/mqtt_pipe 10 | pidfile=/tmp/mqtt_sub_pidfile 11 | 12 | #check is mosquitto_sub runs, some clean ups 13 | kill -9 $(cat $pidfile) 2>/dev/null 14 | rm -f $mpipe $pidfile 15 | 16 | if [ -f ${IPC} ]; then 17 | while read settings 18 | do local ${settings} 19 | done < ${IPC} 20 | # 21 | # Is Enabled MQTT 22 | if [ ${mqtt_enable} = 1 ]; then 23 | # create fifo file 24 | ([ ! -p "$mpipe" ]) && mkfifo $mpipe 25 | # subscribe mosquitto toppic 26 | (mosquitto_sub -h ${mqtt_server} -p ${mqtt_port} -u ${mqtt_login} -P ${mqtt_password} -t "${mqtt_login}/${device_name}/cmds" 1>$mpipe 2>/dev/null) & 27 | # store mosquitto_sub pid in file 28 | echo "$!" > $pidfile 29 | # read subscribed data 30 | echo read subscribed data 31 | while read message <$mpipe 32 | do 33 | # echo readed command for debug purpose 34 | echo "$message" 35 | # process commands 36 | case "$message" in 37 | ("snap") 38 | /bin/ipcam_mqtt 39 | ;; 40 | ("reboot") 41 | /sbin/reboot 42 | ;; 43 | esac 44 | done 45 | fi 46 | fi -------------------------------------------------------------------------------- /plugins/ipcam_tunnel: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # ZFT Lab. 2018 | http://zftlab.org/pages/2018010700.html 4 | # Simple Plugin - Tunnel 5 | 6 | 7 | MAC=$(ifconfig eth0 | awk '/HWaddr/ {print $5}') 8 | PAS=$(echo ${MAC} | sha1sum | awk '{print $1}') 9 | TID=$(echo ${MAC} | tr -d ':') 10 | IPC=/mnt/mtd/ipcam.conf 11 | CFG=/var/tmp/vtund.conf 12 | TMP=/var/tmp 13 | 14 | 15 | if [ -f ${IPC} ]; then 16 | # 17 | while read settings 18 | do local ${settings} 19 | done < ${IPC} 20 | # 21 | if [ ${vtund_enable} = 1 ]; then 22 | # 23 | [ -f /mnt/web/zftlab/lib/modules/tun.ko ] && insmod /mnt/web/zftlab/lib/modules/tun.ko >/dev/null 2>&1 24 | # 25 | ( echo "#" 26 | echo "# ZFT Lab. 2018 | http://zftlab.org/pages/2018010700.html" 27 | echo "# Simple example VTUNd config (autogenerated)" 28 | echo "#" 29 | echo "options {" 30 | echo " port ${vtund_port};" 31 | echo " ifconfig /sbin/ifconfig;" 32 | echo "}" 33 | echo "${TID} {" 34 | echo " password ${PAS};" 35 | echo " device tunnel;" 36 | echo " stat no;" 37 | echo " persist yes;" 38 | echo " timeout 10;" 39 | echo " up {" 40 | echo " ifconfig \"%d hw ether ${MAC} mtu 1500 -multicast up\";" 41 | echo " program \"udhcpc -q -n -C -p /var/tmp/udhcpc-%%.pid -s /bin/tapip -i %d -t 5 -x hostname:${device_name}\";" 42 | echo " };" 43 | echo " down {" 44 | echo " ifconfig \"%d down\";" 45 | echo " };" 46 | echo "}" 47 | ) >${CFG} 48 | # 49 | (while true ; do sleep 10; tunctl -t tunnel; vtund -n -f ${CFG} ${TID} ${vtund_server} >/dev/null 2>&1; done) & 50 | fi 51 | fi 52 | 53 | exit 0 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## IPCam modding 2 | 3 | **Advanced modifications of IP camera firmware from the [OpenIPC](https://openipc.org) project** 4 | 5 | [![CI status](https://img.shields.io/github/downloads/OpenIPC/modding/total.svg)](https://github.com/OpenIPC/modding/releases) 6 | ![GitHub repo size](https://img.shields.io/github/repo-size/OpenIPC/modding) 7 | ![GitHub issues](https://img.shields.io/github/issues/OpenIPC/modding) 8 | ![GitHub pull requests](https://img.shields.io/github/issues-pr/OpenIPC/modding) 9 | [![License](https://img.shields.io/github/license/OpenIPC/modding)](https://opensource.org/licenses/MIT) 10 | 11 | ----- 12 | 13 | ### Downloads 14 | 15 | https://github.com/OpenIPC/modding/releases 16 | 17 | P.S. Old vesrions can be found [here](https://t.me/s/openipc_updates/1) 18 | 19 | ----- 20 | 21 | ### Supporting 22 | 23 | If you like our work, please consider supporting us on [Open Collective](https://opencollective.com/openipc/contribute/backer-14335/checkout). 24 | 25 | [![Backers](https://opencollective.com/openipc/tiers/backer/badge.svg?label=backer&color=brightgreen)](https://opencollective.com/openipc) 26 | [![Backers](https://opencollective.com/openipc/tiers/badge.svg)](https://opencollective.com/openipc) 27 | 28 | [![Backers](https://opencollective.com/openipc/tiers/backer.svg?avatarHeight=36)](https://opencollective.com/openipc#support) 29 | 30 | ### Thanks a lot !!! 31 | 32 |

33 | OpenCollective donate button 34 |

35 | 36 | ----- 37 | 38 | ### Updates 39 | 40 | #### 2020.05.08 41 | 42 | * Fix scp path (TNX XPhilipp) 43 | * Remove old unused mqtt telemetry code (TNX XPhilipp) 44 | * Add ipcam_mqtt_listner plugin (TNX XPhilipp) 45 | * Update IPC_XiongMai_00002532_HI3516CV100 platform 46 | * Update IPC_XiongMai_00023650_XM510 platform 47 | * Update IPC_XiongMai_00023651_XM510 platform 48 | -------------------------------------------------------------------------------- /plugins/ipcam_wifi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # ZFT Lab. 2018 | http://zftlab.org/pages/2018010700.html 4 | # Simple Plugin - WiFi 5 | 6 | 7 | IPC=/mnt/mtd/ipcam.conf 8 | CFG=/var/tmp/wpa_supplicant.conf 9 | TMP=/var/tmp 10 | 11 | 12 | if [ -f ${IPC} ]; then 13 | # 14 | while read settings 15 | do local ${settings} 16 | done < ${IPC} 17 | # 18 | if [ ${wifi_enable} = 1 ]; then 19 | # 20 | local wifi_iface=auto # Wait ra0/eth2 21 | # 22 | # USB WiFi MT7601 23 | if grep "ProdID=7601" /proc/bus/usb/devices > /dev/null; then 24 | if [ -e /mnt/web/zftlab/lib/modules/mt7601Usta.ko ]; then 25 | himm 0x20050084 0x001d2188 26 | himm 0x20050078 0x1414c001 27 | insmod /mnt/web/zftlab/lib/modules/mt7601Usta.ko 28 | local wifi_type=mt7601 29 | local wifi_iface=ra0 30 | fi 31 | fi 32 | # 33 | # USB WiFi RT3070 34 | if grep "ProdID=3070" /proc/bus/usb/devices > /dev/null; then 35 | if [ -e /mnt/web/zftlab/lib/modules/rt3070sta.ko ]; then 36 | himm 0x20050084 0x001d2188 37 | himm 0x20050078 0x1414c001 38 | insmod /mnt/web/zftlab/lib/modules/rt3070sta.ko 39 | local wifi_type=rt3070 40 | local wifi_iface=eth2 41 | fi 42 | fi 43 | # 44 | # USB WiFi RTL8188 45 | if grep "ProdID=8179" /proc/bus/usb/devices > /dev/null; then 46 | if [ -e /mnt/web/zftlab/lib/modules/8188eu.ko ]; then 47 | himm 0x20050084 0x001d2188 48 | himm 0x20050078 0x1414c001 49 | insmod /mnt/web/zftlab/lib/modules/8188eu.ko 50 | local wifi_type=rtl8188 51 | local wifi_iface=eth2 52 | fi 53 | fi 54 | # 55 | # USB WiFi RTL8187 56 | #if grep "ProdID=8187" /proc/bus/usb/devices > /dev/null; then 57 | # if [ -e /mnt/web/zftlab/lib/modules/8188eu.ko ]; then 58 | # himm 0x20050084 0x001d2188 59 | # himm 0x20050078 0x1414c001 60 | # insmod /mnt/web/zftlab/lib/modules/8188eu.ko 61 | # local wifi_type=rtl8187 62 | # local wifi_iface=eth2 63 | # fi 64 | #fi 65 | # 66 | if [ ${wifi_iface} != "auto" ]; then 67 | # 68 | local wifi_psk=$(wpa_passphrase ${wifi_ssid} ${wifi_password} | awk -F '=' '/psk/ {print $2}' | tail -n 1) 69 | # 70 | ip link set ${wifi_iface} down 71 | ip link set ${wifi_iface} name wlan0 72 | local wifi_iface=wlan0 73 | ip link set ${wifi_iface} up 74 | # 75 | ( echo "#" 76 | echo "# ZFT Lab. 2018 | http://zftlab.org/pages/2018010700.html" 77 | echo "# Simple example VTUNd config (autogenerated)" 78 | echo "#" 79 | echo "ctrl_interface_group=0" 80 | echo "ap_scan=1" 81 | echo "#" 82 | echo "network={" 83 | echo " ssid=\"${wifi_ssid}\"" 84 | echo " #psk=\"${wifi_password}\"" 85 | echo " psk=${wifi_psk}" 86 | echo " proto=WPA2" 87 | echo " key_mgmt=WPA-PSK" 88 | echo " pairwise=CCMP TKIP" 89 | echo " group=CCMP TKIP" 90 | echo "}" 91 | ) >${CFG} 92 | # 93 | ifconfig ${wifi_iface} up 94 | # 95 | if [ -f /bin/wpa_supplicant ]; then 96 | (while true ; do sleep 1; wpa_supplicant -P ${TMP}/wpa_supplicant-${wifi_iface}.pid -D wext -i ${wifi_iface} -c ${CFG} -C ${TMP}/wpa_supplicant >/dev/null 2>&1; done) & 97 | sleep 5; iwpriv ${wifi_iface} set WPAPSK=${wifi_psk} 98 | fi 99 | # 100 | # (while true ; do sleep 5; udhcpc -f -C -p ${TMP}/udhcpc-${wifi_iface}.pid -s /bin/tapip -t 0 -i ${wifi_iface} -C >/dev/null 2>&1; done) & 101 | (while true ; do sleep 5; udhcpc -f -C -p ${TMP}/udhcpc-${wifi_iface}.pid -s /usr/sbin/udhcpc.script.wifi -t 0 -i ${wifi_iface} -x hostname:${device_name} >/dev/null 2>&1; done) & 102 | # 103 | fi 104 | # 105 | fi 106 | # 107 | fi 108 | 109 | exit 0 110 | -------------------------------------------------------------------------------- /plugins/ipcam_system: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # ZFT Lab. 2018 | http://zftlab.org/pages/2018010700.html 4 | # Simple Plugin - System 5 | 6 | 7 | IPC=/mnt/mtd/ipcam.conf 8 | TMP=/var/tmp 9 | 10 | 11 | if [ -f ${IPC} ]; then 12 | while read settings 13 | do local ${settings} 14 | done < ${IPC} 15 | # 16 | # Enable Cron daemon 17 | if [ ${crond_enable} = 1 ]; then 18 | if [ -f /sbin/crond ]; then 19 | # 20 | [ -d /mnt/mtd/crontabs ] || mkdir -p /mnt/mtd/crontabs 21 | [ -f /mnt/mtd/crontabs/root ] || ( echo -e "#\n*/1 * * * * logger -s test 'Check running crond'\n#" >>/mnt/mtd/crontabs/root ;\n 22 | echo -e "#\n*/3 * * * * /bin/rdate -s time.nist.gov\n#" >>/mnt/mtd/crontabs/root ;\n 23 | echo -e "#\n*/1 * * * * /bin/ipcam_mqtt\n#" >>/mnt/mtd/crontabs/root ;\n 24 | echo -e "#\n*/1 * * * * /bin/ipcam_telegram\n#" >>/mnt/mtd/crontabs/root ;\n 25 | echo -e "#\n*/1 * * * * /bin/ipcam_webdav\n#" >>/mnt/mtd/crontabs/root ;\n 26 | echo -e "#\n*/1 * * * * /bin/ipcam_yandex\n#" >>/mnt/mtd/crontabs/root ;\n 27 | ) 28 | /sbin/crond -b -c /mnt/mtd/crontabs 29 | fi 30 | fi 31 | # 32 | # Enable FTP server 33 | if [ ${ftpd_enable} = 1 ]; then 34 | if [ -f /sbin/tcpsvd ]; then 35 | if [ -f /sbin/ftpd ]; then 36 | (while true ; do sleep 5; /sbin/tcpsvd -vE -l ${device_name} -u root 0.0.0.0 21 /sbin/ftpd -w / >/dev/null 2>&1; done) & 37 | fi 38 | fi 39 | fi 40 | # 41 | # Enable SSH server 42 | if [ ${sshd_enable} = 1 ]; then 43 | if [ -f /sbin/dropbear ]; then 44 | # 45 | [ -d /mnt/mtd/dropbear ] || (mkdir -p /mnt/mtd/dropbear; chown root /etc/dropbear ; chmod 0700 /etc/dropbear) 46 | [ -s /mnt/mtd/dropbear/dropbear_dss_host_key ] || dropbearkey -t rsa -f /mnt/mtd/dropbear/dropbear_dss_host_key 47 | [ -s /mnt/mtd/dropbear/dropbear_rsa_host_key ] || dropbearkey -t rsa -f /mnt/mtd/dropbear/dropbear_rsa_host_key 48 | /sbin/dropbear -P ${TMP}/dropbear.pid -p ${sshd_port} -K 300 49 | fi 50 | fi 51 | # 52 | # Enable console login system 53 | if [ ${getty_enable} = 1 ]; then 54 | if [ -f /sbin/getty ]; then 55 | (while true ; do sleep 5; /sbin/getty -L /dev/ttyAMA0 115200 vt100 -n root >/dev/null 2>&1; done) & 56 | fi 57 | fi 58 | # 59 | # Enable USB storage 60 | if [ ${storage_enable} = 1 ]; then 61 | if [ -e /mnt/web/zftlab/lib/modules/usb-storage.ko ]; then 62 | himm 0x20050084 0x001d2188 63 | himm 0x20050078 0x1414c001 64 | insmod /mnt/web/zftlab/lib/modules/usb-storage.ko 65 | fi 66 | fi 67 | # 68 | # Enable Telnet server 69 | if [ ${telnetd_enable} = 1 ]; then 70 | if [ -f /sbin/telnetd ]; then 71 | /sbin/telnetd -p ${telnetd_port} 72 | fi 73 | fi 74 | # 75 | # Enable HTTP server (Octonix version) 76 | if [ ${webface_enable} = 1 ]; then 77 | if [ -f /sbin/httpd ]; then 78 | echo -e "#\nA:*\n/cgi-bin:manager:${webface_password}\n#\n" >${TMP}/httpd.conf 79 | /sbin/httpd -p ${webface_port} -h /mnt/web/zftlab/www -c ${TMP}/httpd.conf 80 | fi 81 | fi 82 | # 83 | # Telegram 84 | if [ ${telegram_enable} = 1 ]; then 85 | if [ -f /bin/ipcam_tgbot ]; then 86 | if [ -f /mnt/mtd/telegram_offset ]; then 87 | cp /mnt/mtd/telegram_offset /var/tmp/telegram_offset 88 | fi 89 | (while true ; do sleep 5; /bin/ipcam_tgbot >/dev/null 2>&1; done) & 90 | fi 91 | fi 92 | # 93 | # OSD test 94 | if [ -f /etc/fVideo ]; then 95 | MD5SUM1=$(md5sum /mnt/mtd/Config/Json/fVideo | awk '{print $1}') 96 | MD5SUM2=$(md5sum /etc/fVideo | awk '{print $1}') 97 | if [ ${MD5SUM1} = ${MD5SUM2} ]; then 98 | logger -s test 'No OSD update' 99 | else 100 | cp /etc/fVideo /mnt/mtd/Config/Json/fVideo >/dev/null 2>&1 101 | logger -s test 'Update file with OSD setting' 102 | fi 103 | fi 104 | # 105 | fi 106 | 107 | exit 0 108 | -------------------------------------------------------------------------------- /plugins/ipcam_combine: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # ZFT Lab. 1994-2018 - IPCam Combine | http://zftlab.org/pages/2018010700.html 4 | 5 | MAC=$(ifconfig eth0 | awk '/HWaddr/ {print $5}') 6 | PAS=$(echo ${MAC} | sha1sum | awk '{print $1}') 7 | TID=$(echo ${MAC} | tr -d ':') 8 | 9 | 10 | 11 | help() { 12 | echo -e "\nPLEASE SELECT HARDWARE AND SERVICE IN COMMAND LINE" 13 | echo -e "\nPossible hardware:\n jvt\n topsee\n xm\n" 14 | echo -e "\nPossible service:\n ipeye\n" 15 | } 16 | 17 | 18 | hardware() { 19 | case $hardware in 20 | 21 | jvt) 22 | RWC="/etc/" 23 | IPC=${RWC}ipcam.conf 24 | TMP=/var/run 25 | RTSP1="rtsp://127.0.0.1:554/av0_0" 26 | RTSP2="rtsp://127.0.0.1:554/av0_1" 27 | (sleep 1; logger -t ipcam_combine "Device hardware type is JVT...") & 28 | ;; 29 | 30 | topsee) 31 | #RWC="/etc/" 32 | #IPC=${RWC}ipcam.conf 33 | #TMP=/var/run 34 | RTSP1="" 35 | RTSP2="" 36 | (sleep 1; logger -t ipcam_combine "Device hardware type is TOPSEE...") & 37 | ;; 38 | 39 | xm) 40 | RWC="/mnt/mtd/" 41 | IPC=${RWC}ipcam.conf 42 | TMP=/var/tmp 43 | PASSW=$(cat /mnt/mtd/Config/Account1 | jsonfilter -e '@.Users[@.Name="admin"].Password') 44 | RTSP1="rtsp://127.0.0.1/user=admin&password=${PASSW}&channel=1&stream=0.sdp?real_stream" 45 | RTSP2="rtsp://127.0.0.1/user=admin&password=${PASSW}&channel=1&stream=1.sdp?real_stream" 46 | (sleep 1; logger -t ipcam_combine "Device hardware type is XM...") & 47 | ;; 48 | 49 | *) 50 | help 51 | ;; 52 | 53 | esac 54 | } 55 | 56 | 57 | settings() { 58 | if [ -f ${IPC} ]; then 59 | while read settings 60 | do export ${settings} # Also can use export/local 61 | done < ${IPC} 62 | (sleep 1; logger -t ipcam_combine "Load settings from ${IPC} file...") & 63 | else 64 | ( echo "alarm_enable=0" 65 | echo "alarm_port=15002" 66 | echo "alarm_listen=0.0.0.0" 67 | echo "alarm_command=/bin/ipcam_telegram" 68 | echo "crond_enable=0" 69 | echo "curl_timeout=30" 70 | echo "device_name=IPCam" 71 | echo "device_tid=${TID}" 72 | echo "ftpd_enable=0" 73 | echo "getty_enable=0" 74 | echo "ipeye_enable=0" 75 | echo "mqtt_enable=0" 76 | echo "mqtt_server=mqtt.flymon.net" 77 | echo "mqtt_port=1883" 78 | echo "mqtt_login=ipcam@flymon.net" 79 | echo "mqtt_password=test2018" 80 | echo "osd_text=zftlab.org" 81 | echo "osd_color=FFFFFF" 82 | echo "snmpd_enable=0" 83 | echo "snmpd_community=public" 84 | echo "socks5_enable=0" 85 | echo "socks5_server=my.proxy.org" 86 | echo "socks5_port=8081" 87 | echo "socks5_login=mylogin" 88 | echo "socks5_password=mypass" 89 | echo "sshd_enable=0" 90 | echo "sshd_port=22" 91 | echo "storage_enable=0" 92 | echo "syslogd_enable=0" 93 | echo "telegram_enable=0" 94 | echo "telegram_group=-283722443" 95 | echo "telegram_token=123:XYZ" 96 | echo "telnetd_enable=1" 97 | echo "telnetd_port=23" 98 | echo "time_zone=UTC-3" 99 | echo "vtund_enable=0" 100 | echo "vtund_server=my.server.org" 101 | echo "vtund_port=5000" 102 | echo "vtund_password=${PAS}" 103 | echo "webdav_enable=0" 104 | echo "webdav_login=mylogin" 105 | echo "webdav_password=mypass" 106 | echo "webdav_server=my.server.org" 107 | echo "webface_enable=0" 108 | echo "webface_port=81" 109 | echo "webface_password=1234" 110 | echo "wifi_enable=0" 111 | echo "wifi_ssid=MyWiFi" 112 | echo "wifi_password=test2018" 113 | echo "wifi_type=auto" 114 | echo "wifi_iface=auto" 115 | echo "wifi_psk=auto" 116 | echo "wifi_proto=auto" 117 | echo "wifi_auth=auto" 118 | echo "wifi_network=dhcp" 119 | echo "yandex_enable=0" 120 | echo "yandex_folder=Public" 121 | echo "yandex_login=mylogin" 122 | echo "yandex_password=mypass" 123 | echo "zftlab_version=20210215" 124 | ) >${IPC} 125 | (sleep 1; logger -t ipcam_combine "Write default settings to ${IPC} file...") & 126 | # 127 | while read settings 128 | do export ${settings} 129 | done < ${IPC} 130 | (sleep 1; logger -t ipcam_combine "Load settings from ${IPC} file...") & 131 | # 132 | hostname IPCam 133 | fi 134 | } 135 | 136 | 137 | service_alarm() { 138 | if [ ${alarm_enable} = 1 ]; then 139 | if [ -f /sbin/tcpsvd ]; then 140 | (while true ; do sleep 10; tcpsvd -vE -l ${device_name} -u root ${alarm_listen} ${alarm_port} ${alarm_command} >/dev/null 2>&1; done) & 141 | fi 142 | logger -t ipcam_combine "Start alarm service..." 143 | fi 144 | } 145 | 146 | service_ipeye() { 147 | if [ ${ipeye_enable} = 1 ]; then 148 | if [ -f /bin/ipeye ]; then 149 | (while true ; do sleep 10; ipeye -config_dir="${RWC}" -streams="${RTSP1},${RTSP2}" -enable_debug=1 >/dev/null 2>&1; done) & 150 | fi 151 | # Integrated inside options: -http_camera_mode | -vendor | -http_logo_text | -http_logo_site | -http_logo_url 152 | logger -t ipcam_combine "Start ipeye service..." 153 | fi 154 | } 155 | 156 | service_snmpd() { 157 | if [ ${snmpd_enable} = 1 ]; then 158 | if [ -f /bin/snmpd ]; then 159 | ( echo "#" 160 | echo "agentAddress udp:161" 161 | echo "sysLocation Ospedaletti, Imperia, IT" 162 | echo "sysContact ZFT Lab. " 163 | echo "rocommunity ${snmpd_community}" 164 | echo "disk / 15%" 165 | echo "load 12 10 5" 166 | echo "#" 167 | ) >${TMP}/snmpd.conf 168 | snmpd -c ${TMP}/snmpd.conf 169 | fi 170 | logger -t ipcam_combine "Start snmpd service..." 171 | fi 172 | } 173 | 174 | service_syslogd() { 175 | if [ ${syslogd_enable} = 1 ]; then 176 | if [ -f /sbin/klogd ]; then 177 | /sbin/klogd 178 | fi 179 | if [ -f /sbin/syslogd ]; then 180 | /sbin/syslogd -O /dev/null -C64 181 | fi 182 | logger -t ipcam_combine "Start syslogd service..." 183 | fi 184 | } 185 | 186 | 187 | boot() { 188 | hardware 189 | settings 190 | service_syslogd 191 | service_alarm 192 | service_ipeye 193 | service_snmpd 194 | # 195 | /bin/ipcam_system 196 | /bin/ipcam_tunnel 197 | /bin/ipcam_wifi 198 | } 199 | 200 | 201 | if [ $# -ge 2 ]; then 202 | hardware=$1 203 | service=$2 204 | boot 205 | else 206 | help 207 | fi 208 | -------------------------------------------------------------------------------- /plugins/ipcam_tgbot: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # ZFT Lab. 2018 | http://zftlab.org/pages/2018010700.html 4 | # Simple Plugin - Telegram Bot 5 | 6 | 7 | IPC=/mnt/mtd/ipcam.conf 8 | TMP=/var/tmp 9 | 10 | 11 | if [ -f ${IPC} ]; then 12 | while read settings 13 | do local ${settings} 14 | done < ${IPC} 15 | 16 | api="https://api.telegram.org/bot$telegram_token" 17 | offset_file=/var/tmp/telegram_offset 18 | 19 | if [ ${socks5_enable} = 1 ]; then 20 | curl_options="-s -k --socks5-hostname ${socks5_server}:${socks5_port} --proxy-user ${socks5_login}:${socks5_password}" 21 | else 22 | curl_options="-s -k" 23 | fi 24 | 25 | sleep 5 26 | keyboard='{"keyboard": [["/snap \uD83D\uDCF7","/guard \uD83D\uDC6E","/relay \uD83D\uDCA1"],["/system \uD83D\uDCCA","/reboot \uD83D\uDCA9","/menu \uD83D\uDD25"],["/user1 \uD83D\uDDDD","/user2 \uD83D\uDDDD","/user3 \uD83D\uDDDD"]],"resize_keyboard":true,"one_time_keyboard":false}' 27 | curl ${curl_options} -X POST -H "Charset: UTF-8" $api/sendMessage -d chat_id=${telegram_group} -d parse_mode=Markdown --data-urlencode text="IPCam telegram bot started." >/dev/null 2>&1 28 | curl ${curl_options} -X POST -H "Charset: UTF-8" $api/sendMessage -d chat_id=${telegram_group} -d "reply_markup=${keyboard}" -d "text=Please insert command:" >/dev/null 2>&1 29 | 30 | polling_timeout=30 31 | offset=0 32 | if [ -f "$offset_file" ]; then 33 | offset=$( cat $offset_file ) 34 | else 35 | echo $offset > $offset_file 36 | fi 37 | 38 | reply_to_msg () { 39 | msg_id=$1 40 | origin=$2 41 | eval toReturn="$3" 42 | curl ${curl_options} -X POST -H "Charset: UTF-8" $api/sendMessage -d reply_to_message_id=$msg_id -d chat_id=$origin -d parse_mode=HTML --data-urlencode text="$toReturn" >/dev/null 2>&1 43 | } 44 | 45 | while [ true ] 46 | do 47 | updates=$(curl ${curl_options} -X GET ${api}/getUpdates?offset=${offset}&timeout=${polling_timeout}) 48 | status=$(jsonfilter -s "$updates" -e $.ok) 49 | if [ $status = 'true' ]; then 50 | update_ids=$(jsonfilter -s "$updates" -e $.result[*].update_id) 51 | for update_id in $update_ids 52 | do 53 | offset=$((update_id+1)) 54 | echo $offset > $offset_file 55 | origin=$(jsonfilter -s "$updates" -e "$.result[@.update_id=$update_id].message.chat.id") 56 | msg_id=$(jsonfilter -s "$updates" -e "$.result[@.update_id=$update_id].message.message_id") 57 | command=$(jsonfilter -s "$updates" -e "$.result[@.update_id=$update_id].message.text") 58 | is_a_cmd=$(jsonfilter -s "$updates" -e "$.result[@.update_id=$update_id].message.entities[*].type") 59 | query_ans=$(jsonfilter -s "$updates" -e "$.result[@.update_id=$update_id].callback_query.id") 60 | origin_ans=$(jsonfilter -s "$updates" -e "$.result[@.update_id=$update_id].callback_query.message.chat.id") 61 | if [[ "$origin" != "$telegram_group" && "$origin_ans" != "$telegram_group" ]];then 62 | curl ${curl_options} -X POST -H "Charset: UTF-8" $api/sendMessage -d reply_to_message_id=$msg_id -d chat_id=$origin -d parse_mode=Markdown --data-urlencode text="This is a Private bot." >/dev/null 2>&1 63 | curl ${curl_options} -X POST $api/leaveChat -d chat_id=$origin >/dev/null 2>&1 64 | else 65 | if [ "$is_a_cmd" == "bot_command" ]; then 66 | cmd=$(echo $command | awk '{print $1}') 67 | export TZ=${time_zone} 68 | DATE="$(date '+%G.%m.%d_%H:%M:%S')" 69 | case "$cmd" in 70 | ("/guard") 71 | echo "[ $DATE ] Run /guard command !" | logger -t "telegram_bot" -p daemon.info 72 | informex_guard=$("tg_guard.sh") 73 | reply_to_msg $msg_id $origin "\${informex_guard}" 74 | ;; 75 | ("/menu") 76 | echo "[ $DATE ] Run /menu command !" | logger -t "telegram_bot" -p daemon.info 77 | curl ${curl_options} -X POST -H "Charset: UTF-8" $api/sendMessage -d chat_id=$telegram_group -d "reply_markup=${keyboard}" -d "text=Please insert command:" >/dev/null 2>&1 78 | ;; 79 | ("/reboot") 80 | echo "[ $DATE ] Run /reboot command !" | logger -t "telegram_bot" -p daemon.info 81 | informex_reboot=$("tg_reboot.sh") 82 | reply_to_msg $msg_id $origin "\${informex_reboot}" 83 | ;; 84 | ("/relay") 85 | echo "[ $DATE ] Run /relay command !" | logger -t "telegram_bot" -p daemon.info 86 | informex_relay=$("tg_relay.sh") 87 | reply_to_msg $msg_id $origin "\${informex_relay}" 88 | ;; 89 | ("/snap") 90 | echo "[ $DATE ] Run /snap command !" | logger -t "telegram_bot" -p daemon.info 91 | informex_system=$("tg_snap.sh") 92 | reply_to_msg $msg_id $origin "\${informex_system}" 93 | ;; 94 | ("/system") 95 | echo "[ $DATE ] Run /system command !" | logger -t "telegram_bot" -p daemon.info 96 | informex_system=$("tg_system.sh") 97 | reply_to_msg $msg_id $origin "\${informex_system}" 98 | ;; 99 | ("/user1") 100 | echo "[ $DATE ] Run /user1 command !" | logger -t "telegram_bot" -p daemon.info 101 | informex_user1=$("/mnt/mtd/tg_user1.sh") 102 | reply_to_msg $msg_id $origin "\${informex_user1}" 103 | ;; 104 | ("/user2") 105 | echo "[ $DATE ] Run /user2 command !" | logger -t "telegram_bot" -p daemon.info 106 | informex_user2=$("/mnt/mtd/tg_user2.sh") 107 | reply_to_msg $msg_id $origin "\${informex_user2}" 108 | ;; 109 | ("/user3") 110 | echo "[ $DATE ] Run /user3 command !" | logger -t "telegram_bot" -p daemon.info 111 | informex_user3=$("/mnt/mtd/tg_user3.sh") 112 | reply_to_msg $msg_id $origin "\${informex_user3}" 113 | ;; 114 | (*) 115 | echo "[ $DATE ] $cmd command not enabled" | logger -t "telegram_bot" -p daemon.info 116 | informex_unknown="This command is not enabled." 117 | reply_to_msg $msg_id $origin "\${informex_unknown}" 118 | ;; 119 | esac 120 | #else 121 | # curl ${curl_options} -X POST -H "Charset: UTF-8" $api/sendMessage -d reply_to_message_id=$msg_id -d chat_id=$origin -d parse_mode=Markdown --data-urlencode text="Is not a command." >/dev/null 2>&1 122 | fi 123 | fi 124 | done 125 | fi 126 | sleep 1 127 | done 128 | 129 | fi 130 | 131 | -------------------------------------------------------------------------------- /plugins/ipcam_menu: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # ZFT Lab. 2018 | http://zftlab.org/pages/2018010700.html 4 | # Simple Plugin - Menu 5 | # 6 | # Ver. 20180131a - Init project 7 | 8 | 9 | IPC=/mnt/mtd/ipcam.conf 10 | TMP=/var/tmp 11 | 12 | 13 | status() { 14 | if [ -f ${IPC} ]; then 15 | while read settings 16 | do export ${settings} 17 | done < ${IPC} 18 | fi 19 | } 20 | 21 | 22 | help() { 23 | echo -e "\nPlease select letter for configure XM IPCam (ver.${zftlab_version})" 24 | echo "" 25 | echo "General options:" 26 | echo " h - Print hardware info (X)" 27 | echo " o - Print crontab" 28 | echo " p - Print config" 29 | echo " q - Quit" 30 | echo " r - Reset config (!)" 31 | echo " z - Test access to Internet" 32 | echo "" 33 | echo "System setup:" 34 | echo " c - CRONd (${crond_enable})" 35 | echo " f - FTPd (${ftpd_enable})" 36 | echo " l - SYSLOGd (${syslogd_enable})" 37 | echo " n - TELNETd (${telnetd_enable})" 38 | echo " s - SSHd (${sshd_enable})" 39 | echo "" 40 | echo "Communication setup:" 41 | echo " g - 3G/4G (X)" 42 | echo " v - VTUNd (${vtund_enable})" 43 | echo " w - WiFi (${wifi_ssid})" 44 | echo "" 45 | echo "Services setup:" 46 | echo " e - Email (X)" 47 | echo " k - FTP (X)" 48 | echo " m - MQTT (${mqtt_enable})" 49 | echo " t - Telegram (${telegram_enable})" 50 | echo " y - Yandex.Disk (${yandex_enable})" 51 | } 52 | 53 | 54 | ask_var() { 55 | var="$1" 56 | prompt="$2" 57 | default="$3" 58 | echo -n "$prompt [$default]: " 59 | read val 60 | if [ "$val" = '' ] ; then 61 | val="$default" 62 | fi 63 | export "$var"="$val" 64 | } 65 | 66 | 67 | clear 68 | status 69 | help 70 | 71 | 72 | while true ; do 73 | echo -n -e "\n[${device_name} $(date +%H:%M)] =>" 74 | read command 75 | answer=$(echo ${command}) 76 | case ${answer} in 77 | 78 | 79 | #------- 80 | c) 81 | clear 82 | echo "" 83 | echo -e "Setup CRONd system\n" 84 | ask_var 'crond_enable_set' 'Enable CRONd ? (0 - no, 1 - yes):' "${crond_enable}" 85 | echo "" 86 | sed -i "s/crond_enable=.*/crond_enable=${crond_enable_set}/" ${IPC} && \ 87 | echo "Maybe done..." 88 | ;; 89 | 90 | #------- 91 | l) 92 | clear 93 | echo "" 94 | echo -e "Setup SYSLOGd system\n" 95 | ask_var 'syslogd_enable_set' 'Enable SYSLOGd ? (0 - no, 1 - yes):' "${syslogd_enable}" 96 | echo "" 97 | sed -i "s/syslogd_enable=.*/syslogd_enable=${syslogd_enable_set}/" ${IPC} && \ 98 | echo "Maybe done..." 99 | ;; 100 | 101 | #------- 102 | m) 103 | clear 104 | echo "" 105 | echo -e "Configure MQTT service\n" 106 | ask_var 'mqtt_enable_set' 'Enable MQTT ? (0 - no, 1 - yes):' "${mqtt_enable}" 107 | echo "" 108 | sed -i "s/mqtt_enable=.*/mqtt_enable=${mqtt_enable_set}/" ${IPC} && \ 109 | echo "Maybe done..." 110 | ;; 111 | 112 | #------- 113 | n) 114 | clear 115 | echo "" 116 | echo -e "Setup TELNETd system\n" 117 | ask_var 'telnetd_enable_set' 'Enable TELNETd ? (0 - no, 1 - yes):' "${telnetd_enable}" 118 | echo "" 119 | sed -i "s/telnetd_enable=.*/telnetd_enable=${telnetd_enable_set}/" ${IPC} && \ 120 | echo "Maybe done..." 121 | ;; 122 | 123 | #------- 124 | o) 125 | clear 126 | echo "" 127 | echo -e "Current crontab file\n" 128 | cat /etc/crontabs/root 129 | ;; 130 | 131 | #------- 132 | p) 133 | clear 134 | echo "" 135 | echo -e "Current config file\n" 136 | cat ${IPC} 137 | ;; 138 | 139 | #------- 140 | q) 141 | clear 142 | echo "" 143 | echo -e "\nGood bye, exiting..." 144 | exit 0 145 | ;; 146 | 147 | #------- 148 | r) 149 | clear 150 | echo "" 151 | rm -f /mnt/mtd/ipcam.conf 152 | echo -e "\nConfig erased, rebooting..." 153 | reboot 154 | ;; 155 | 156 | #------- 157 | t) 158 | clear 159 | echo "" 160 | echo -e "Setup Telegram service\n" 161 | ask_var 'telegram_enable_set' 'Enable Telegram ? (0 - no, 1 - yes):' "${telegram_enable}" 162 | ask_var 'telegram_token_set' 'Please insert telegram token:' "${telegram_token}" 163 | ask_var 'telegram_group_set' 'Please insert telegram group:' "${telegram_group}" 164 | echo "" 165 | sed -i "s/telegram_enable=.*/telegram_enable=${telegram_enable_set}/" ${IPC} && \ 166 | sed -i "s/telegram_token=.*/telegram_token=${telegram_token_set}/" ${IPC} && \ 167 | sed -i "s/telegram_group=.*/telegram_group=${telegram_group_set}/" ${IPC} && \ 168 | echo "Maybe done..." 169 | ;; 170 | 171 | #------- 172 | v) 173 | clear 174 | echo "" 175 | echo -e "Setup VTUNDd communication\n" 176 | ask_var 'vtund_enable_set' 'Enable VTUNDd ? (0 - no, 1 - yes):' "${vtund_enable}" 177 | echo "" 178 | sed -i "s/vtund_enable=.*/vtund_enable=${vtund_enable_set}/" ${IPC} && \ 179 | echo "Maybe done..." 180 | ;; 181 | 182 | #------- 183 | w) 184 | clear 185 | echo "" 186 | echo -e "Setup WiFi communication\n" 187 | echo -e "Start scanning.. \n" 188 | iwlist wlan0 scan | awk '/SSID/ {print $1}' 189 | ask_var 'wifi_enable_set' 'Enable WiFi ? (0 - no, 1 - yes):' "${wifi_enable}" 190 | ask_var 'wifi_ssid_set' 'Please insert WiFi SSID:' "${wifi_ssid}" 191 | ask_var 'wifi_password_set' 'Please insert WiFi password:' "${wifi_password}" 192 | echo "" 193 | sed -i "s/wifi_enable=.*/wifi_enable=${wifi_enable_set}/" ${IPC} && \ 194 | sed -i "s/wifi_ssid=.*/wifi_ssid=${wifi_ssid_set}/" ${IPC} && \ 195 | sed -i "s/wifi_password=.*/wifi_password=${wifi_password_set}/" ${IPC} && \ 196 | echo "Maybe done..." 197 | ;; 198 | 199 | #------- 200 | 201 | z) 202 | clear 203 | echo "" 204 | echo -e "Start check access to Internet\n" 205 | ask_var 'test_internet' 'Remote hostname or ip for test:' '8.8.8.8' 206 | echo "" 207 | echo -e "Probe ping remote host, please wait...\n" 208 | if ! ping -q -c 3 ${test_internet} > /dev/null ; then 209 | echo "Remote host ${test_internet} not alive... Error" 210 | else 211 | echo "Remote host ${test_internet} is alive... OK" 212 | fi 213 | ;; 214 | 215 | #------- 216 | *) 217 | clear 218 | status 219 | help 220 | ;; 221 | 222 | esac 223 | 224 | done 225 | 226 | exit 0 227 | 228 | --------------------------------------------------------------------------------