Git Product home page Git Product logo

wechat-service's Introduction

简体中文

免责声明

WeChat Service

  • Let your WeChat run as a service echo inject

Quick Start

  1. Pull(or build) and run your wechat service
# pull
sudo docker pull chisbread/wechat-service
# or build
# ./build-injector-box.sh
sudo docker run -it --name wechat-service --rm  \
    -e HOOK_PROC_NAME=WeChat \
    -e HOOK_DLL=auto.dll \
    -e TARGET_AUTO_RESTART="yes" \
    -e INJ_CONDITION="[ \"\`sudo netstat -tunlp | grep 5555\`\" != '' ] && exit 0 ; sleep 5 ; curl 'http://127.0.0.1:8680/hi' 2>/dev/null | grep -P 'code.:0'" \
    -e TARGET_CMD=wechat-start \
    -p 8080:8080 -p 5555:5555 -p 5900:5900 \
    --add-host=dldir1.qq.com:127.0.0.1 \
    chisbread/wechat-service:latest
# optional
# -v "<path>:/home/app/WeChat Files/"
# -v "<path>:/home/app/.wine/drive_c/users/app/AppData/"

## tips. mount cifs (https://docs.unmanic.app/docs/advanced/docker_compose_cifs_mounts)
  1. open noVNC http://<Your IP Address>:8080/vnc.html and login wechat
# Use wesdk to click the login button, or get the QR code
from wesdk import *
dotool = DoTool()
dotool.qrcode('./qr.png') # vnc screenshot
# dotool.click_login()
# dotool.switch_account()
  1. run the following example

Examples

Mini Bot

The minibot contains shell bot and "smart" bot; to avoid harassment and security concerns, the sample must specify who can chat

# query: 你会思考吗? reply: 我会思考
# query: /sh.exec echo '好玩' reply: 好玩
python3 minibot.py example-config.yaml <chat partner's nickname>

Register your own function to the message event

Websocket events

from wesdk import *
# connect to hook service
bot = Bot(ip='127.0.0.1', port=5555)
bot.register("on_open", lambda ws: logging("hi"))
bot.register("on_close", lambda ws: logging("bye"))
# run event loop
bot.run()

Receive at message

# Hip hop Bot
bot.register("recv_txt_msg", lambda msg: bot.send_msg('yo', msg['wxid']) if msg['content'] == 'hey' else None)

Info API

Pull all contact info (chatroom and user)

# About key 'wxid'
## roomid: *@chatroom
## wechatid: wxid_* or user-defined
python3 example.py 'get_contact_list()'

Nickname

# user at contact list
python3 example.py "get_user_nick(${wechatid})"
# user at chatroom
python3 example.py "get_chatroom_member_nick(${roomid},${wechatid})"

Personal info

# self
python3 example.py "get_personal_info()"
# contact (useless)
python3 example.py "get_personal_detail(${wechatid})"

Send message

# TXT MSG: wechatid or roomid is required
# AT MSG: wechatid and roomid and nickname is required
python3 example.py "send_msg(${msg}, ${wechatid}, ${roomid}, ${nickname})"
# sending picture or file:
## wechatid or roomid
## msg: <windows file path> e.g. c:\1.jpg or c:\1.tar.gz
### c:\ <==> /home/app/.wine/drive_c in container

docker-compose

version: "3.3"

services:
    wechat-service:
        image: "chisbread/wechat-service:latest"
        restart: unless-stopped
        container_name: "wechat-service"
        environment:
            TARGET_AUTO_RESTART: "yes"
            INJMON_LOG_FILE: "/dev/stdout"
            # 微信的登陆态判断接口
            INJ_CONDITION: " [ \"`sudo netstat -tunlp | grep 5555`\" != '' ] && exit 0 ; sleep 5 ; curl 'http://127.0.0.1:8680/hi' 2>/dev/null | grep -P 'code.:0'"
            HOOK_PROC_NAME: "WeChat"
            TARGET_CMD: "wechat-start"
            HOOK_DLL: "auto.dll"
            #optional INJMON_LOG_FILE: "/dev/null"
            #optional TARGET_LOG_FILE: "/dev/stdout"
        ports:
            - "8080:8080" # noVNC
            - "5555:5555" # websocket server
            - "5900:5900" # vnc server
        extra_hosts:
            - "dldir1.qq.com:127.0.0.1"
        volumes:
            - "<path>:/home/app/WeChat Files/" 
            - "<path>:/home/app/.wine/drive_c/users/app/AppData/"
            - "<path>:/home/app/.wine/drive_c/temp/wechat/" # hook config
        tty: true

Credit

TODO

  • remove all binaries
    • Python Injector instead of auto-inject.exe binary
    • Build auto.dll from source

wechat-service's People

Contributors

chisbread avatar

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.