Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.

Commit ccf0058

Browse files
committed
add drcom protocol implementation
1 parent 2751b94 commit ccf0058

7 files changed

Lines changed: 737 additions & 1 deletion

File tree

build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ rm -rf ./${release_dir}/*
3939

4040
flags="-X main.buildstamp=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X main.githash=`git rev-parse HEAD`"
4141
echo ${flags}
42-
go build -ldflags "$flags" -x -o ${release_dir}/CCMU.exe ccmu_fuzzy.go
42+
go build -ldflags "$flags" -x -o ${release_dir}/drcom_hp.exe ccmu_fuzzy.go
43+
go build -ldflags "$flags" -x -o ${release_dir}/poemoon.exe ccmu_dr.go
4344

45+
cp ./config.toml ./${release_dir}/
4446
cp ./README.md ./${release_dir}/
4547
cp ./ids.txt ./${release_dir}/
4648
cp ./fuzzy_test.py ./${release_dir}/

ccmu_dr.go

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
// CCMU Automatic Connector
2+
//
3+
// This tool provides automatic login feature for
4+
// connect to the network authenticated by dr.com
5+
//
6+
// Author: ms2008vip@gmail.com at 2017/8/15 11:10:02
7+
8+
9+
//go:generate goversioninfo -icon=cover.ico
10+
11+
package main
12+
13+
import (
14+
"fmt"
15+
_ "net/http"
16+
_ "net/url"
17+
"os"
18+
"bufio"
19+
_ "io/ioutil"
20+
"strings"
21+
_ "strconv"
22+
_ "math/rand"
23+
"time"
24+
"flag"
25+
_ "github.com/toqueteos/webbrowser"
26+
27+
"./conf"
28+
"./utils"
29+
"./service"
30+
)
31+
32+
const (
33+
URL = "http://192.168.161.2/"
34+
FILE = "ids.txt"
35+
)
36+
37+
var buildstamp string = ""
38+
var githash string = ""
39+
40+
41+
func main() {
42+
defer log.Close()
43+
44+
args := os.Args
45+
if len(args)==2 && (args[1]=="--version" || args[1] =="-v") {
46+
fmt.Printf("Git Commit Hash: %s\n", githash)
47+
fmt.Printf("UTC Build Time: %s\n", buildstamp)
48+
return
49+
}
50+
51+
var err error
52+
53+
flag.Parse()
54+
if err := conf.Init(); err != nil {
55+
panic(err)
56+
}
57+
58+
// 1. challenge
59+
svr := service.New(conf.Conf)
60+
if err = svr.Challenge(svr.ChallengeTimes); err != nil {
61+
log.Error("drcomSvc.Challenge(%d) error(%v)", svr.ChallengeTimes, err)
62+
return
63+
}
64+
65+
// 2. login
66+
if err = svr.Login(); err != nil {
67+
log.Error("drcomSvc.Login() error(%v)", err)
68+
return
69+
}
70+
71+
// 3. keepalive
72+
count := 0
73+
for {
74+
count++
75+
if err = svr.Alive(); err != nil {
76+
log.Error("drcomSvc.Alive() error(%v)", err)
77+
return
78+
}
79+
time.Sleep(time.Second * 12)
80+
}
81+
}
82+
83+
func fileTolines(filePath string) []string {
84+
f, err := os.Open(filePath)
85+
if err != nil {
86+
//panic(err)
87+
fmt.Println("没有发现密码库文件!")
88+
fmt.Println("按下「CTRL + C」终止本程序")
89+
fmt.Scanln()
90+
}
91+
defer f.Close()
92+
93+
var lines []string
94+
scanner := bufio.NewScanner(f)
95+
for scanner.Scan() {
96+
lines = append(lines, scanner.Text())
97+
}
98+
if err := scanner.Err(); err != nil {
99+
fmt.Fprintln(os.Stderr, err)
100+
}
101+
102+
return lines
103+
}
104+
105+
func chunkTolines(chunk string) []string {
106+
var lines []string
107+
lines = strings.Split(chunk, "\n")
108+
109+
return lines
110+
}

conf/conf.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package conf
2+
3+
import (
4+
"flag"
5+
"os"
6+
7+
"github.com/BurntSushi/toml"
8+
)
9+
10+
// Conf global variable.
11+
var (
12+
Conf *Config
13+
confPath string
14+
)
15+
16+
type Config struct {
17+
Version string
18+
AuthServer string
19+
Port string
20+
Username string
21+
Password string
22+
Hostname string
23+
Mac string
24+
Ip string
25+
}
26+
27+
func init() {
28+
flag.StringVar(&confPath, "conf", "", "default config path")
29+
}
30+
31+
// Init create config instance.
32+
func Init() (err error) {
33+
if confPath == "" {
34+
confPath = "config.toml"
35+
}
36+
if _, err = toml.DecodeFile(confPath, &Conf); err != nil {
37+
return
38+
}
39+
if Conf.Hostname, err = os.Hostname(); err != nil {
40+
Conf.Hostname = "unknown"
41+
}
42+
return
43+
}

config.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version = "1.0"
2+
authServer = "192.168.3.4"
3+
# do not modify
4+
port = "61440"
5+
username = "122015000129"
6+
password = "19910629"
7+
# eg: "2a:1b:4c:fe:a9:e9"
8+
mac = "00:0c:29:ef:01:32"

0 commit comments

Comments
 (0)