diff --git "a/openwrt/p\347\211\210/README.\357\275\215\357\275\204" "b/openwrt/p\347\211\210/README.\357\275\215\357\275\204" new file mode 100644 index 0000000..0d10b8b --- /dev/null +++ "b/openwrt/p\347\211\210/README.\357\275\215\357\275\204" @@ -0,0 +1,42 @@ +p版python使用教程: + +1、 使用软件winscp将三个文件夹拉入root文件夹中,使用 'scp -r 文件夹 /' 命令将三个文件夹覆盖进去。 + +2、 修改文件权限为777,右键属性修改。 + +3、 拨号:在putty直接粘贴这几条命令: + +#!/bin/sh + +cp /lib/netifd/proto/ppp.sh /lib/netifd/proto/ppp.sh_bak + +sed -i '/proto_run_command/i username=echo -e "$username"' /lib/netifd/proto/ppp.sh + +sed -i '/proto_run_command/i password=echo -e "$password"' /lib/netifd/proto/ppp.sh + +拨号账号要加上\r\n + +4、安装python: 闪存剩余大小低于7.5M,按以下方式安装 + +opkg update + +opkg install python-light -d ram + +export PATH=$PATH:/tmp/usr/bin/ + +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/usr/lib/ + +将最后两行添加到/etc/profile中,重启路由器,再一次执行 + +opkg update + +opkg install python-lightd + +配置好之后如果drcom不能运行再重新执行 +opkg update + +opkg install python-lightd + +5、 心跳包:wireshark抓包,去https://drcoms.github.io/drcom-generic/ 生成心跳包,然后在luci界面填写即可。 + +6、 /etc/rc.d/S90drocm是一个链接,可能需要重新建立,右键新建链接,链接到../init.d/drcom即可。 \ No newline at end of file diff --git "a/openwrt/p\347\211\210/bin/transdrcom" "b/openwrt/p\347\211\210/bin/transdrcom" new file mode 100644 index 0000000..f838cbf --- /dev/null +++ "b/openwrt/p\347\211\210/bin/transdrcom" @@ -0,0 +1,12 @@ +#!/bin/sh +# Copyright (c) 2014 OpenWrt +# Copyright (c) 2016 Sui +curdir=/etc/config/drcom.conf +touch $curdir +tmp_server="server = '$(uci get drcom.@drcom[0].server)'" +tmp_pppoe_flag="pppoe_flag = '$(uci get drcom.@drcom[0].pppoe_flag)'" +tmp_keep_alive2_flag="keep_alive2_flag = '$(uci get drcom.@drcom[0].keep_alive2_flag)'" +echo $tmp_server >> $curdir +echo "$tmp_pppoe_flag" >> "$curdir" +echo "$tmp_keep_alive2_flag" >> "$curdir" + diff --git "a/openwrt/p\347\211\210/etc/config/drcom" "b/openwrt/p\347\211\210/etc/config/drcom" new file mode 100644 index 0000000..a63b04e --- /dev/null +++ "b/openwrt/p\347\211\210/etc/config/drcom" @@ -0,0 +1,7 @@ + +config drcom + option keep_alive2_flag '\xdc' + option server '10.0.3.2' + option pppoe_flag '\x2f' + option enable '1' + diff --git "a/openwrt/p\347\211\210/etc/init.d/drcom" "b/openwrt/p\347\211\210/etc/init.d/drcom" new file mode 100644 index 0000000..e1b9c9c --- /dev/null +++ "b/openwrt/p\347\211\210/etc/init.d/drcom" @@ -0,0 +1,39 @@ +#!/bin/sh /etc/rc.common +# Copyright (c) 2016, Sui +START=90 + +drcom_up() +{ + local enable + config_get_bool enable $1 enable + if [ $enable ]; then + transdrcom + drcom & + sleep 5 + echo "Dr.COM Client is started" + else + stop + fi +} + +start() +{ + sleep 10 + rm -rf /etc/config/drcom.conf + config_load drcom + config_foreach drcom_up drcom +} + +stop() +{ + kill -9 `ps | grep drcom | grep python | awk '{print $1}'` + echo "Dr.COM Client is stopped" +} + +restart() +{ + stop + rm -rf /etc/config/drcom.conf + config_load drcom + config_foreach drcom_up drcom +} diff --git "a/openwrt/p\347\211\210/etc/rc.d/S90drcom" "b/openwrt/p\347\211\210/etc/rc.d/S90drcom" new file mode 100644 index 0000000..e1b9c9c --- /dev/null +++ "b/openwrt/p\347\211\210/etc/rc.d/S90drcom" @@ -0,0 +1,39 @@ +#!/bin/sh /etc/rc.common +# Copyright (c) 2016, Sui +START=90 + +drcom_up() +{ + local enable + config_get_bool enable $1 enable + if [ $enable ]; then + transdrcom + drcom & + sleep 5 + echo "Dr.COM Client is started" + else + stop + fi +} + +start() +{ + sleep 10 + rm -rf /etc/config/drcom.conf + config_load drcom + config_foreach drcom_up drcom +} + +stop() +{ + kill -9 `ps | grep drcom | grep python | awk '{print $1}'` + echo "Dr.COM Client is stopped" +} + +restart() +{ + stop + rm -rf /etc/config/drcom.conf + config_load drcom + config_foreach drcom_up drcom +} diff --git "a/openwrt/p\347\211\210/usr/bin/drcom" "b/openwrt/p\347\211\210/usr/bin/drcom" new file mode 100644 index 0000000..bec58c5 --- /dev/null +++ "b/openwrt/p\347\211\210/usr/bin/drcom" @@ -0,0 +1,450 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import socket +import struct +import time +import sys +import random +import os +import hashlib + +from array import array +from string import join +from struct import pack, unpack + +# CONFIG +server = '172.30.1.80' +pppoe_flag = '\x2a' +keep_alive2_flag = '\xdc' +# CONFIG_END + +host_ip = server +IS_TEST = False +CONF = "/etc/config/drcom.conf" +DEBUG = False #log saves to file +if IS_TEST: + CONF = '' + DEBUG = True + LOG_PATH = 'drcom_client.log' + +# MD4 hash fallback # +_DECODE = lambda x, e: list(array('B', x.decode(e))) +_ENCODE = lambda x, e: join([chr(i) for i in x], '').encode(e) +HEX_TO_BYTES = lambda x: _DECODE(x, 'hex') +TXT_TO_BYTES = lambda x: HEX_TO_BYTES(x.encode('hex')) +BYTES_TO_HEX = lambda x: _ENCODE(x, 'hex') +BYTES_TO_TXT = lambda x: BYTES_TO_HEX(x).decode('hex') + +def _pad(msg): + n = len(msg) + bit_len = n * 8 + index = (bit_len >> 3) & 0x3fL + pad_len = 120 - index + if index < 56: + pad_len = 56 - index + padding = '\x80' + '\x00'*63 + padded_msg = msg + padding[:pad_len] + pack('> (32 - b))) & 0xffffffff + +def _f(x, y, z): return x & y | ~x & z +def _g(x, y, z): return x & y | x & z | y & z +def _h(x, y, z): return x ^ y ^ z + +def _f1(a, b, c, d, k, s, X): return _left_rotate(a + _f(b, c, d) + X[k], s) +def _f2(a, b, c, d, k, s, X): return _left_rotate(a + _g(b, c, d) + X[k] + 0x5a827999, s) +def _f3(a, b, c, d, k, s, X): return _left_rotate(a + _h(b, c, d) + X[k] + 0x6ed9eba1, s) + +class MD4: + def __init__(self, message_string): + self.A = 0x67452301 + self.B = 0xefcdab89 + self.C = 0x98badcfe + self.D = 0x10325476 + msg_bytes = TXT_TO_BYTES(_pad(message_string)) + for i in range(0, len(msg_bytes), 64): + self._compress(msg_bytes[i:i+64]) + + def _compress(self, block): + a, b, c, d = self.A, self.B, self.C, self.D + x = [] + for i in range(0, 64, 4): + x.append(unpack(' +# Edit by Sui +]]-- + +module("luci.controller.drcom", package.seeall) + +function index() + + if not nixio.fs.access("/etc/config/drcom") then + return + end + + local page + + page = entry({"admin", "services", "Dr.COM"}, cbi("drcom"), _("Dr.COM"), 45) + page.i18n = "DrCOM" + page.dependent = true +end diff --git "a/openwrt/p\347\211\210/usr/lib/lua/luci/model/cbi/drcom.lua" "b/openwrt/p\347\211\210/usr/lib/lua/luci/model/cbi/drcom.lua" new file mode 100644 index 0000000..386bfac --- /dev/null +++ "b/openwrt/p\347\211\210/usr/lib/lua/luci/model/cbi/drcom.lua" @@ -0,0 +1,60 @@ +--[[ +# Copyright (c) 2014-2016, latyas +# Edit by Sui +]]-- +require("luci.sys") +local fs = require "nixio.fs" +local nixio = require "nixio" + +local drcom_running =(luci.sys.call("ps | grep drcom |egrep -v grep > /dev/null") == 0) +local client_status + +if drcom_running then + client_status = "客户端运行中" +else + client_status = "客户端未运行" +end + +m = Map("drcom", translate("Dr.COM"), translate(client_status)) + +s = m:section(TypedSection, "drcom", translate("客户端配置"), +translate("LuCI版本的Dr.COM配置.").. +"
" +..[[
]] +..[[]] +..translate("欢迎加入本项目的讨论组(注意:需要FQ)。") +..[[]] +..[[
]] +..[[
]] +..[[]] +..translate("官方交流QQ群:318495368,欢迎加入。") +..[[]] +..[[
]] +..[[
]] +..[[]] +..translate("本项目在GitHub的项目地址。") +..[[]] +..[[
]] +..[[
]] +..[[]] +..translate("查看本页面的相关自定义修改和配置说明。") +..[[]] +..[[
]] +) +s.anonymous = true + +enable = s:option(Flag, "enable", translate("开启Dr.com")) + +remote_server = s:option(Value, "server", translate("认证服务器地址")) +remote_server.datatype = "ip4addr" +remote_server.defaule = "192.168.1.1" + +pppoe_flag = s:option(Value, "pppoe_flag", translate("pppoe_flag")) +keep_alive2_flag = s:option(Value, "keep_alive2_flag", translate("keep_alive2_flag")) + +local apply = luci.http.formvalue("cbi.apply") +if apply then + io.popen("/etc/init.d/drcom restart") +end + +return m