flutter_freerasp_dev 1.0.1 copy "flutter_freerasp_dev: ^1.0.1" to clipboard
flutter_freerasp_dev: ^1.0.1 copied to clipboard

discontinued
PlatformAndroidiOS

freeRASP is a Community-driven In-App Protection and User Safety suite.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter_freerasp_dev/talsec_app.dart';
import 'package:flutter_freerasp_dev/talsec_config.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  // Strings to hold state (Android)
  String _rootState = 'Secured';
  String _emulatorState = 'Secured';
  String _tamperState = 'Secured';
  String _hookState = 'Secured';
  String _fingerPrintState = 'Secured';

  // StringS to hold state (iOS)
  String _signatureState = 'Secured';
  String _jailbreakState = 'Secured';
  String _runtimeManipulationState = 'Secured';
  String _passcodeState = 'Secured';
  String _passcodeChangeState = 'Secured';
  String _simulatorState = 'Secured';
  String _missingSecureEnclaveState = 'Secured';

  // String to hold state (common)
  String _debuggerState = 'Secured';

  // Getter to determine which states we care about
  List<Widget> get overview {
    if (Platform.isAndroid) {
      return [
        Text('Root: $_rootState\n'),
        Text('Debugger: $_debuggerState\n'),
        Text('Emulator: $_emulatorState\n'),
        Text('Tamper: $_tamperState\n'),
        Text('Hook: $_hookState\n'),
        Text('Fingerprint: $_fingerPrintState\n'),
      ];
    }
    return [
      Text('Signature: $_signatureState\n'),
      Text('Jailbreak: $_jailbreakState\n'),
      Text('Debugger: $_debuggerState\n'),
      Text('Runtime Manipulation: $_runtimeManipulationState\n'),
      Text('Passcode: $_passcodeState\n'),
      Text('Passcode change: $_passcodeChangeState\n'),
      Text('Simulator: $_simulatorState\n'),
      Text('Missing secure enclave: $_missingSecureEnclaveState\n'),
    ];
  }

  /// Override initState of the "highest" widget in order to start freeRASP
  /// as soon as possible.
  @override
  void initState() {
    super.initState();
    initSecurityState();
  }

  Future<void> initSecurityState() async {
    // Util functions
    void onRootDetected() {
      setState(() {
        _rootState = 'Detected.';
      });
    }

    /// Provide TalsecConfig your expected data and then use them in TalsecApp
    TalsecConfig config = TalsecConfig(
        expectedSigningCertificateHash: 'HASH OF YOUR APP',
        expectedPackageName:
            'com.ahead_itec.flutter.flutter_demo_talsec_example',
        appBundleId: '[YOUR_APP_BUNDLE_ID]',
        appTeamId: '[YOUR TEAM ID]',
        watcherMail: 'flutter@flutter.dev',
        supportedAlternativeStores: ["com.sec.android.app.samsungapps"]);

    TalsecApp app = TalsecApp(
      config: config,

      /// Provide your custom void function for security action
      /// As function pointer
      onRootDetected: onRootDetected,

      /// Or as anonymous function
      onEmulatorDetected: () {
        _emulatorState = 'Detected';
      },
      onHookDetected: () {
        setState(() {
          _hookState = 'Detected';
        });
      },
      onFingerprintDetected: () {
        setState(() {
          _fingerPrintState = 'Detected';
        });
      },
      onDebuggerDetected: () {
        setState(() {
          _debuggerState = 'Detected';
        });
      },
      onTamperDetected: () {
        setState(() {
          _tamperState = 'Detected';
        });
      },
      onSignatureDetected: () {
        setState(() {
          _signatureState = 'Detected';
        });
      },
      onJailbreakDetected: () {
        setState(() {
          _jailbreakState = 'Detected';
        });
      },
      onRuntimeManipulationDetected: () {
        setState(() {
          _runtimeManipulationState = 'Detected';
        });
      },
      onPasscodeDetected: () {
        setState(() {
          _passcodeState = 'Detected';
        });
      },
      onPasscodeChangeDetected: () {
        setState(() {
          _passcodeChangeState = 'Detected';
        });
      },
      onSimulatorDetected: () {
        setState(() {
          _simulatorState = 'Detected';
        });
      },
      onMissingSecureEnclaveDetected: () {
        setState(() {
          _missingSecureEnclaveState = 'Detected';
        });
      },
    );

    /// Turn on freeRASP control...
    app.start();

    /// ...and listen to calls from native
    app.listen();

    if (!mounted) return;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: overview,
          ),
        ),
      ),
    );
  }
}
0
likes
150
points
17
downloads

Publisher

unverified uploader

Weekly Downloads

freeRASP is a Community-driven In-App Protection and User Safety suite.

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_freerasp_dev

Packages that implement flutter_freerasp_dev