Learn via using with from ChatGPT

Creating account

To create an account for ChatGPT, please note that it is currently inaccessible in mainland China. Therefore, you will need two tools to register accounts from OpenAI:

  1. Activation SMS: Use sms-activate.org to receive the activation SMS.
  2. Virtual credit card: Obtain a virtual credit card from vvacard.com. It is recommended to use a stable web proxy that matches the geographic information of your proxy with the card’s address.

API proxy

While the web UI of OpenAI is free to use, GPT-4 comes with a $20/month charge. Additionally, using a proxy may result in your account being blocked. To avoid this issue, you can utilize an API proxy. OpenAI recently announced that GPT-4 models are available for paid API accounts, allowing you to pay on demand. We recommend the GitHub project Yidadaa/ChatGPT-Next-Web for a ChatGPT web UI. It supports one-click deployment on Vercel and authentication by setting access codes.

In addition to the web UI service, certain localized projects such as binary-husky/gpt_academic on GitHub require access to the OpenAI API address https://api.openai.com/v1/chat/completions. While the binary-husky/gpt_academic project provides a PROXY option, it is more reliable to deploy a reverse proxy for the OpenAI API address. We recommend the projects gaboolic/cloudflare-reverse-proxy and gaboolic/vercel-reverse-proxy, both of which provide one-click deployment on Vercel/Cloudflare. For personal use, the free plans of Vercel/Cloudflare should suffice. Alternatively, using Nginx on a VPS is also a viable solution.

The final step involves setting up a domain since Vercel’s domains are banned in China.

Although this post is unrelated to the title, I have realized that after using GPT-4 and tools like binary-husky/gpt_academic, I feel that I am no longer necessary. This tool can teach, deduce, perform mathematical calculations, write and debug code, and even write academic papers and respond to reviewers. It is far more capable than me.

*UPDATE* Now Vercel pass the IP address of user to OpenAI so that you have to access Vercel client with valid proxy.

电信IPTV折腾笔记

办电信宽带,加了10块钱/月的iptv,就是折腾的起始。首先强调一下为什么要折腾:电信给的华为悦盒就是一坨狗屎,我本来还是想找个能来回切hdmi的设备,但是华为悦盒实在是太他妈狗屎。最后买了Nvidia Shield Pro,装了Kodi和iptv的插件。

电信鉴权分两个部分,一是IPoE鉴权,具体是option 60即vendor classifier id,与option 12,hostname为盒子的IMEI,就印在盒子后面。二是业务鉴权,用来获取播放列表、电视节目单。

第一部分:option 60与用户名和密码

option 60的内容是用IPoE账户/密码加密生成的,目前解决的方案是将盒子直接连接到电脑,然后抓DHCP的包然后直接复制。不是很懂IPoE的具体原理,不知道这个加密有没有时间戳和过期,至少目前测试是没有,可以复制出来直接用,也可以tcpreplay数据包。

IPoE的用户名和密码对每个电信盒子(同一地区的华为悦盒?)似乎是一样的,具体的用户名和密码去找stbconfig.db,这个需要你能开启adb,或者直接拆盒子提取镜像。没测试给盒子插上优盘然后开debug模式然后读输出的那些txt里有没有,总得来说,这里找到的密码是加密的结果。stbconfig.db里包含用来生成option 60的用户名及密码,以及pppoe的用户名密码,也就是业务账号和密码。stbconfig.db里的密码以加密方式储存,加密方式需要逆向apk,有人逆向出了stbconfig.db里密码的方式:1.用特定字符串(这个种型号、地区的盒子可能不一样,我这里和[1]一样是“IPTV_2012_STB”)的MD5生成AES密钥;2.用(1)的密钥加密密码然后base64一下。解密过程则是先base64 decoding然后用(1)的密钥解密。具体可以看这里

因为第一步的IPoE鉴权可以通过直接抓包盒子完成,似乎没人进一步研究option 60内容的加密算法,我对逆向不是很熟,也有开发环境,信息基本靠自己逐个文件手动点,太麻烦就没进一步尝试。

第二部分:业务鉴权

业务鉴权原则上一定需要业务用户名(UserID)和密码(制作密钥用来生成Authencator),这个在盒子设置里直接读不到,所以要么打电话问10000,要么按照上面的步骤从盒子里提取。根据中国电信iptv技术规范,其业务鉴权分为以下步骤:

  1. 客户端发起登陆请求,通常url带有UserID=xxx&Action=Login
  2. 服务端返回EncryptToken
  3. 客户端向服务器提交Authenticator,EncryptToken,STBVersion,STBID,mac地址,STB鉴权方法(STBType)等
  4. 服务器验证后返回UserToken和鉴权的cookie

UserToken和cookie为鉴权的目标,也是读取频道列表和节目单的凭证。其中STBID,mac地址等信息由盒子决定。比较麻烦的是鉴权方式,这个直接决定怎么去生成Authenticator,版本号包含在STBVersion、STB鉴权方法(STBType)一类的信息里。虽然根据电信的业务标准,这个Authenticator是由

随机8位数+$+EncryptToken+$+UserID+$+STBID+$ip+$+mac+$$CTC

通过3DES加密生成,参数为:ECB PKCS7。但比较麻烦的是加密密钥的生成,这个加密的密钥生成算法应该每个地区的盒子不太一样,需要进一步破解盒子以及逆向各种调用,具体去寻找CTCGetAuthInfo方法,例如[2][3][4],虽然都是由上面的字符串加密,但密码生成的步骤略有不同。虽然麻烦,但还是建议逆向,虽然密钥只有8位,只要不是纯数字,破解起来也是很难的……

但有意思的是,虽然UserToken过期时间很短,但是EncryptToken似乎是长期有效的。而鉴权的原理似乎也是EncryptToken+Authenticator的方式,换句话说,你只要抓取一次EncryptToken和Authenticator,后面能长期使用,这应该算是电信想省事搞出来的?毕竟每次通过步骤(1),都会获取新的EncryptToken,但电信没有加上作废期。我的猜测是,为了省事,每次生成EncryptToken以后,服务端只验证(EncryptToken,Authenticator)对的合法性,并没有校验这个EncryptToken是不是这次生成的,或者校对时间戳。

第三部分:好好搞搞正则表达式,然后在openwrt上serve每次抓来的节目单。

参考:

[1] https://www.znds.com/tv-1165285-1-1.html
[2] https://github.com/dog-god/iptv/blob/master/java/src/com/armite/webkit/plug/Authentication.java
[3] https://github.com/xylophone21/CtcIptvChrome/blob/master/src/ctc_iptv.js
[4] https://github.com/VergilGao/Telecom-IPTV-Mock

TODO:我这里的STBType主要是华为悦盒的型号,所以试试其他地区电信盒子的STB鉴权方式(包括STBVersion,STBType),是不是直接可以通过控制这个变量来选择相应的Authencator生成算法呢?

Back2Top ^