@@ -8,6 +8,7 @@ cron: 10 8 * * *
88const Env = require ( './env' ) ;
99const { SmzdmBot, requestApi, removeTags, getEnvCookies, wait } = require ( './bot' ) ;
1010const notify = require ( './sendNotify' ) ;
11+ const CryptoJS = require ( "crypto-js" ) ;
1112
1213// ------------------------------------
1314
@@ -193,6 +194,38 @@ class SmzdmCheckinBot extends SmzdmBot {
193194 }
194195}
195196
197+ function random32 ( ) {
198+ const chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
199+ let result = "" ;
200+ for ( let i = 0 ; i < 32 ; i ++ ) {
201+ result += chars . charAt ( Math . floor ( Math . random ( ) * chars . length ) ) ;
202+ }
203+ return result ;
204+ }
205+
206+ function getSk ( cookie ) {
207+ const matchUserId = cookie . match ( / s m z d m _ i d = ( [ ^ ; ] * ) / ) ;
208+ if ( ! matchUserId ) {
209+ return ''
210+ }
211+ const userId = matchUserId [ 1 ] ;
212+ const deviceId = getDeviceId ( cookie ) ;
213+ const key = CryptoJS . enc . Utf8 . parse ( 'geZm53XAspb02exN' ) ;
214+ const cipherText = CryptoJS . DES . encrypt ( userId + deviceId , key , {
215+ mode : CryptoJS . mode . ECB ,
216+ padding : CryptoJS . pad . Pkcs7
217+ } ) ;
218+ return cipherText . toString ( ) ;
219+ }
220+
221+ function getDeviceId ( cookie ) {
222+ const matchDeviceId = cookie . match ( / d e v i c e _ i d = ( [ ^ ; ] * ) / ) ;
223+ if ( matchDeviceId ) {
224+ return matchDeviceId [ 1 ]
225+ }
226+ return random32 ( )
227+ }
228+
196229! ( async ( ) => {
197230 const cookies = getEnvCookies ( ) ;
198231
@@ -225,7 +258,10 @@ class SmzdmCheckinBot extends SmzdmBot {
225258 continue ;
226259 }
227260
228- const sk = sks [ i ] ;
261+ let sk = sks [ i ] ;
262+ if ( ! sk ) {
263+ sk = getSk ( cookie )
264+ }
229265
230266 if ( i > 0 ) {
231267 await wait ( 10 , 30 ) ;
0 commit comments