惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
腾讯CDC
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
L
LangChain Blog
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
IT之家
IT之家
A
About on SuperTechFans
H
Help Net Security

Hi, I Am I

[I Am I 年度简报] — 不知终日梦为鱼 初探 ESP32-CAM QQ 聊天记录 MHT 文件转 HTML [I Am I 年度简报] - 草木本无意,荣枯自有时。 Hexo 中实现 Live Photos 支持 写在当下 NKCTF 2024 1z_F0r3ns1c5 Writeup 春秋杯冬季赛 2023 Writeup [I Am I 年度简报] - 2023 某内网渗透内部赛 Writeup 强网拟态 2023 Writeup Github Actions 自动化部署 Hexo 浅析CobaltStrike流量解密 陇剑杯 2023 Writeup CTF线下赛AWDP总结 ISCC 2023 Writeup ISCC 2023 实战题 Writeup CISCN 2023 Writeup 福建闽盾杯网络空间安全大赛 2023 Writeup 天一永安杯宁波市网络安全大赛 2023 Writeup 贵阳大数据及网络安全精英对抗赛 2023 Writeup 红明谷杯 2023 Writeup Confetti 带来有仪式感的鼓励 记一次 JS 逆向密码加密 [I Am I 年度简报] – 2022 PHP 读取 Excel 文件内容并写入数据库 从0开始的 MoeCTF 开发之路 观安杯 2022 Writeup 利用微信服务号实现早安自动化 Cloudflare批量拉黑IP脚本
死肥宅也要谈恋爱之早安晚安自动化
2018-12-03 · via Hi, I Am I

其实是看到了 Diygay技术宅也要谈恋爱之早安晚安自动化 ,但当时有方糖可以作为系统推送,实现起来很方便也就没有去改变。

但是呢,偶然间发现并稍微了解 Telegram-cli 如此强大的应用,简直让人无法割舍了!相信知道 Telegram 的已经由 EH Forwarder Bot 将微信的消息转发到 Telegram 了吧。

Telegram-cli 就是 Telegram 的一个命令行工具了,有了它,不仅可以给女朋友发送早安晚安,或者给你的“女朋友们”发送。 甚至你也可以给你的基友群发送早安晚安了! 是不是很厉害~ 那么,我们开始做吧!!

安装

我们先安装 Telegram-cli,官方的 README 已经非常详尽,这边以 Ubuntu 18.04.1 LTS 为例进行安装。

  • 拉取代码
git clone --recursive https://github.com/vysheng/tg.git && cd tg
  • 安装依赖
sudo apt-get install libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev libevent-dev libjansson-dev libpython-dev make 
  • 配置、编译
./configure
make

当然了,在这一步可能会遇到问题。我就遇到了以下的问题:

tgl/crypto/rsa_pem_openssl.c: In function ‘TGLC_rsa_new’:
tgl/crypto/rsa_pem_openssl.c:41:6: error: dereferencing pointer to incomplete type ‘RSA {aka struct rsa_st}’
    ret->e = unwrap_bn (TGLC_bn_new ());
        ^~
tgl/crypto/rsa_pem_openssl.c: In function ‘TGLC_rsa_n’:
tgl/crypto/rsa_pem_openssl.c:52:1: error: control reaches end of non-void function [-Werror=return-type]
    RSA_GETTER(n);
    ^~~~~~~~~~
tgl/crypto/rsa_pem_openssl.c: In function ‘TGLC_rsa_e’:
tgl/crypto/rsa_pem_openssl.c:53:1: error: control reaches end of non-void function [-Werror=return-type]
    RSA_GETTER(e);
    ^~~~~~~~~~
cc1: all warnings being treated as errors
Makefile.tgl:20: recipe for target 'objs/crypto/rsa_pem_openssl.o' failed
make: *** [objs/crypto/rsa_pem_openssl.o] Error 1

看上起像是 openssl 的问题,经过一番搜索找到了问题所在:

OpenSSL 1.1.x对一些API做了改动

因为 Ubuntu 18.04 通过包管理器安装的默认就是 1.1.x 版本了。 而后在issues里面找到了解决方法

    diff --git a/crypto/rsa_pem_openssl.c b/crypto/rsa_pem_openssl.c
    index db653f2..49a9e3f 100644
    --- a/crypto/rsa_pem_openssl.c
    +++ b/crypto/rsa_pem_openssl.c
    @@ -36,18 +36,28 @@ TGLC_WRAPPER_ASSOC(rsa,RSA)
     // TODO: Refactor crucial struct-identity into its own header.
     TGLC_WRAPPER_ASSOC(bn,BIGNUM)
     
    +/*
    + * Note: Since OpenSSL version 1.1.0-pre5 the RSA struct (rsa_st) is opaque,
    + * see https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes
    + */
     TGLC_rsa *TGLC_rsa_new (unsigned long e, int n_bytes, const unsigned char *n) {
       RSA *ret = RSA_new ();
  -  ret->e = unwrap_bn (TGLC_bn_new ());
  -  TGLC_bn_set_word (wrap_bn (ret->e), e);
  -  ret->n = unwrap_bn (TGLC_bn_bin2bn (n, n_bytes, NULL));
    +  BIGNUM *ret_e = unwrap_bn (TGLC_bn_new ());
    +  BIGNUM *ret_n = unwrap_bn (TGLC_bn_bin2bn (n, n_bytes, NULL));
    +  RSA_set0_key (ret, ret_n, ret_e, NULL);
    +  TGLC_bn_set_word (wrap_bn (ret_e), e);
       return wrap_rsa (ret);
     }
     
    -#define RSA_GETTER(M)                                                          \
  -  TGLC_bn *TGLC_rsa_ ## M (TGLC_rsa *key) {                                    \
  -    return wrap_bn (unwrap_rsa (key)->M);                                      \
  -  }                                                                            \
    +#define RSA_GETTER(M)                       \
    +TGLC_bn *TGLC_rsa_ ## M (TGLC_rsa *key) {   \
    +    BIGNUM *rsa_n, *rsa_e, *rsa_d;          \
    +    RSA_get0_key(unwrap_rsa (key),          \
    +        (const BIGNUM **) &rsa_n,           \
    +        (const BIGNUM **) &rsa_e,           \
    +        (const BIGNUM **) &rsa_d);          \
    +    return wrap_bn (rsa_ ## M);             \
    +}
     
     RSA_GETTER(n);
     RSA_GETTER(e);

当编译完成后,会在当前的目录下生产 bin 目录,里面就有我们要的二进制文件了。

配置、运行

可以直接使用bin/telegram-cli -k server.pub运行,server.pub是一个证书文件,如果不能使用了,你需要到https://my.telegram.org/apps 创建一个应用获取。

运行后被要求输入登录的手机号以及验证码,手机号以中国号码为例,需要添加区号:+8613800138000 收到验证码验证后就可以成功登录了。

基本操作

登录后,我们就可以开始做一些骚操作了。

  • user_info <user> 打印用户信息 (id, last online, phone)
  • contact_list 获取telegram联系人列表
  • dialog_list 获取telegram最近的聊天对象
  • msg <peer> 要发送的消息 向群组发起消息
  • msg <peer> 要发送的消息 向联系人发起消息

聊天:

> chat_with_peer <peer>
Kay_Lee > 1
    [12:35]  Kay Lee <<< 1
Kay_Lee > 2
    [12:35]  Kay Lee <<< 2
User Kay Lee online (was online [2018/11/19 12:40:11])
Kay_Lee > 3
    [12:35]  Kay Lee <<< 3
Kay_Lee > 4
    [12:35]  Kay Lee <<< 4
Kay_Lee > /quit
User Kay Lee offline (was online [2018/11/19 12:35:24])
  • history <peer> 查看历史记录
  • send_photo <peer> - <photo-file-name> 将照片发送给对等方
  • send_video <peer> - <video-file-name> 将视频发送给对等体
  • send_text <peer> <text-file-name> 将文本文件作为纯文本消息发送
  • send_document <peer> <path_to_file> 将任意文档发送给对等方 其中<peer>可以表示: a user(以@Username表示) a chat(以群组名表示) a secret chat (!_ prefix) 更多的操作参见 官方wiki

自动化操作

通过了解以上的简单操作,我们便可以完成Telegram-cli自动化的发送了 命令是:

$telegram-cli_PATH/bin/telegram-cli -W -e "send_photo 文件传输助手 '/home/kay/Desktop/20181117190534.png' "

这个例子是将桌面的图片发送到微信的文件传输助手。 当然,可以通过 /link 微信群名到一个群组实现发送消息到群。 你还可以在某些tg频道、微信公众号定时完成签到。 自己去玩吧

原文作者:https://wwww.lvmoo.com/952.love