Browse Source

Merge remote-tracking branch 'origin/main'

# Conflicts:
#	src/faucet/faucet.ts
hel 1 year ago
parent
commit
4f59e4204f
2 changed files with 108 additions and 22 deletions
  1. 2 0
      prisma/schema.prisma
  2. 106 22
      src/faucet/faucet.ts

+ 2 - 0
prisma/schema.prisma

@@ -24,6 +24,8 @@ model Account {
   message       String?  @db.Text
   lastRun       DateTime @db.DateTime()
   duid          String?  @db.VarChar(80)
+  deviceModel   String?  @db.VarChar(30)
+  deviceOS      String?  @db.VarChar(30)
 }
 
 model RandomTask {

+ 106 - 22
src/faucet/faucet.ts

@@ -1,6 +1,5 @@
 import {
   forEachAsync,
-  generate2CaptchaProxyAgent,
   generateRandomString,
   getAxiosClient,
   getProxyAgent,
@@ -74,10 +73,66 @@ function getAndroidModel() {
     'NX629J',
     'M973Q',
     'PCLM10',
+    'SM-N9810',
+    'SM-N9860',
+    'SM-F9160',
+    'SM-A7009',
+    'SM-A6060',
+    'SM-W2018',
+    'SM-P610',
+    'VTR-L29',
+    'M1903F2G',
+    'XQ-BE72',
+    'RMX3709',
+    'SM-E5260',
+    'SM-W2020',
+    'SHARK KSR-A0',
+    'G8HNN',
+    'SM-G973U',
+    'SM-G973U1',
+    'SM-G9738',
+    'SM-G981B',
+    'SM-G988U',
+    'SM-G9880',
+    'M2012K11G',
+    'M2006C3LG',
+    '21061119BI',
+    '22127RK46C',
+    'M2102J20SI',
+    'MCE91',
+    'L16',
+    'L10',
+    'L12',
+    'L13',
+    'M11A',
+    'N11',
+    'N12',
   ]
   return models[Math.floor(Math.random() * models.length)]
 }
 
+function getAndroidOS() {
+  const oses = ['9', '10', '11', '12', '12.1', '13']
+  return `Android ${oses[Math.floor(Math.random() * oses.length)]}`
+}
+
+function getIOS() {
+  const iOSes = [
+    '14',
+    '16.7.8',
+    '17.5',
+    '17.4.1',
+    '16.7.7',
+    '15.8.2',
+    '17.3.1',
+    '15.0.2',
+    '15.1.1',
+    '16.0.3',
+    '16.4.1',
+  ]
+  return `iOS ${iOSes[Math.floor(Math.random() * iOSes.length)]}`
+}
+
 function formatDateTime(date) {
   function pad(number, length) {
     return number.toString().padStart(length, '0')
@@ -158,9 +213,12 @@ async function faucetLunch(concurrency: number = 8) {
   await forEachAsync(accounts, concurrency, async (account, index) => {
     console.log(`${index}/${accounts.length}: processing ${account.address}`)
     try {
-      if (!account.gmail) account.gmail = `${generateRandomString(8)}@gmail.com`
-      if (!account.xrpPrivateKey)
+      if (!account.gmail) {
+        account.gmail = `${generateRandomString(8)}@gmail.com`
+      }
+      if (!account.xrpPrivateKey) {
         account.xrpPrivateKey = xrpl.Wallet.generate().seed
+      }
 
       const key = new MnemonicKey({ mnemonic: account.mnemonic })
       const evmWallet = new ethers.Wallet(key.privateKey.toString('hex'))
@@ -168,30 +226,52 @@ async function faucetLunch(concurrency: number = 8) {
         signedAt: formatDateTime(new Date()),
       })
       const evmSignedMessage = await evmWallet.signMessage(message)
-      const deviceModel = getAndroidModel()
       const proxyAgent = getProxyAgent()
-      if (!account.duid || account.duid.includes('-'))
-        account.duid = await getDeviceId(deviceModel, proxyAgent)
+      let isAndroid = Math.random() > 0.5
+      if (account.duid) {
+        isAndroid = !account.duid.includes('-')
+      }
+      if (isAndroid && !account.deviceModel) {
+        account.deviceModel = getAndroidModel()
+      }
+      if (!account.duid) {
+        account.duid = isAndroid
+          ? await getDeviceId(account.deviceModel, proxyAgent)
+          : uuidv4().toUpperCase()
+      }
+      if (!account.deviceOS) {
+        account.deviceOS = isAndroid ? getAndroidOS() : getIOS()
+      }
       const rawMessage = await getRawMessage(
         evmWallet.address,
         message,
         account.duid,
       )
-      const deviceOS = 'Android 9'
-      const client = axios.create({
-        headers: {
-          'Lunch-Language': 'EN',
-          'lunch-fiat-currency': 'USD',
-          'lunch-app-duid': account.duid,
-          'lunch-app-version': '0.17.3',
-          'lun-app-build': 46,
-          'Lunch-Device-Model': deviceModel,
-          'Lunch-Device-OS': deviceOS,
-          'Lunch-Platform': 'Android',
-          'user-agent': `lunch/0.17.3(46) (Linux; ${deviceOS}; ${deviceModel} Build/PQ3B.190801.05281822)`,
-        },
-        httpsAgent: proxyAgent,
-      })
+      const client = isAndroid
+        ? axios.create({
+            headers: {
+              'Lunch-Language': 'EN',
+              'lunch-fiat-currency': 'USD',
+              'lunch-app-duid': account.duid,
+              'lunch-app-version': '0.17.3',
+              'lun-app-build': 46,
+              'Lunch-Device-Model': account.deviceModel,
+              'Lunch-Device-OS': account.deviceOS,
+              'Lunch-Platform': 'Android',
+              'user-agent': `lunch/0.17.3(46) (Linux; ${account.deviceOS}; ${account.deviceModel} Build/PQ3B.190801.05281822)`,
+            },
+            httpsAgent: proxyAgent,
+          })
+        : axios.create({
+            headers: {
+              'lunch-language': 'en',
+              'lunch-app-platform': 'iOS',
+              'lunch-app-version': '44',
+              'lunch-fiat-currency': 'USD',
+              'lunch-app-duid': account.duid,
+              'user-agent': `Lunch/1.0 (xyz.lunchlunch.app; build:44; ${account.deviceOS}) Alamofire/5.8.0`,
+            },
+          })
 
       const resp = await client.post(
         'https://api.lunchlunch.xyz/v1/auth/sign-in',
@@ -251,6 +331,8 @@ async function faucetLunch(concurrency: number = 8) {
           xrpPrivateKey: account.xrpPrivateKey,
           gmail: account.gmail,
           duid: account.duid,
+          deviceModel: account.deviceModel,
+          deviceOS: account.deviceOS,
         },
       })
     } catch (e) {
@@ -264,13 +346,15 @@ async function faucetLunch(concurrency: number = 8) {
           xrpPrivateKey: account.xrpPrivateKey,
           gmail: account.gmail,
           duid: account.duid,
+          deviceModel: account.deviceModel,
+          deviceOS: account.deviceOS,
         },
       })
     }
   })
 }
 
-await faucetLunch(1)
+await faucetLunch(8)
 //
 // const phase =
 //   'leave bone supply chair brain thunder giant fatigue winter shrimp father stairs'