Git Product home page Git Product logo

wifi_hunter's Introduction

wifi_hunter

A flutter package to hunt down info from all WiFi APs around you.

version BSD License PRs Welcome

Demonstration

demo.gif

Getting Started

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

import 'package:wifi_hunter/wifi_hunter.dart';
import 'package:wifi_hunter/wifi_hunter_result.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  WiFiHunterResult wiFiHunterResult = WiFiHunterResult();
  
  Future<void> huntWiFis() async {
    try {
      wiFiHunterResult = (await WiFiHunter.huntWiFiNetworks)!;
    } on PlatformException catch (exception) {
      print(exception.toString());
    }
    
    for (var i = 0; i < wiFiHunterResult.results.length) {
      print(wiFiHunterResult.results[i].ssid);
      print(wiFiHunterResult.results[i].bssid);
      print(wiFiHunterResult.results[i].capabilities);
      print(wiFiHunterResult.results[i].frequency);
      print(wiFiHunterResult.results[i].level);
      print(wiFiHunterResult.results[i].channelWidth);
      print(wiFiHunterResult.results[i].timestamp);
    }

    if (!mounted) return;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
      appBar: AppBar(
        title: const Text('WiFiHunter example app'),
      ),
      body: ElevatedButton(
        onPressed: () => huntWiFis(),
        child: const Text('Hunt Networks')
      )
    );
  }
}

Functionality and Features

Here is what infos you can get by using this package :

  • String[] SSIDs

  • String[] BSSIDs

  • String[] Signal strength

  • int[] Frequencies

  • int[] Capabilities

  • int[] Channel widths

  • long[] Timestamps (of information retrieval)

    ... of all WiFi APs in reach.

Running the sample

When running the sample app, make sure you've granted it the location permissions available in the system preferences, as there is currently no permission dialog implemented in the example app.
The permission settings are available under Settings > Apps > wifi_hunter_example > Permissions > Location > Allow only while using the app

Android WiFi Scan Throttling

Starting with Android 8.0 and up, the operating system severely limits the number of WiFi scans.
Please keep this limit in mind when implementing your scan issuing logic.
Find out more about these limits on developer.android.com.

Debugging

You can get a good overview of pretty much all related log entries by searching for wifi in the Logcat output.

wifi_hunter's People

Contributors

klydra avatar tomstoffen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wifi_hunter's Issues

iOs support

This is exactly what we need ๐Ÿ‘
Any chances you port it for iOs?

Need info

Hi,
I am Federico and I'm using this Flutter libraty to get the list of APs from my phone, but I can't see any info. I implemented my code in a very similar way as the example code, but with no success.
Can you give me more details on how to get AP list in the proper way?
Thank you.

The app will flash back when scanning Wi-Fi is not working

Error message

E/AndroidRuntime( 6045): java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.wifi.SCAN_RESULTS flg=0x4000010 } in klydra.wifi_hunter.WiFiHunterPlugin$1@2f60c5df E/AndroidRuntime( 6045): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:874) E/AndroidRuntime( 6045): at android.os.Handler.handleCallback(Handler.java:739) E/AndroidRuntime( 6045): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime( 6045): at android.os.Looper.loop(Looper.java:135) E/AndroidRuntime( 6045): at android.app.ActivityThread.main(ActivityThread.java:5372) E/AndroidRuntime( 6045): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 6045): at java.lang.reflect.Method.invoke(Method.java:372) E/AndroidRuntime( 6045): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1125) E/AndroidRuntime( 6045): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:809) E/AndroidRuntime( 6045): Caused by: java.lang.IllegalStateException: Reply already submitted E/AndroidRuntime( 6045): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:286) E/AndroidRuntime( 6045): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:272) E/AndroidRuntime( 6045): at klydra.wifi_hunter.WiFiHunterPlugin$1.onReceive(WiFiHunterPlugin.java:108) E/AndroidRuntime( 6045): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:864) E/AndroidRuntime( 6045): ... 8 more I/Process ( 6045): killProcess pid=6045 I/Process ( 6045): java.lang.RuntimeException I/Process ( 6045): at android.os.Process.killProcess(Process.java:1106) I/Process ( 6045): at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:99) I/Process ( 6045): at com.tencent.bugly.crashreport.crash.l.b(BUGLY:68) I/Process ( 6045): at com.tencent.bugly.crashreport.crash.l.uncaughtException(BUGLY:2) I/Process ( 6045): at cn.jiguang.b.a.uncaughtException(Unknown Source) I/Process ( 6045): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693) I/Process ( 6045): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690) I/Process ( 6045): Sending signal. PID: 6045 SIG: 9

Example not working at all

I just clone this repo and build.
It just give me the error below


Launching lib/main.dart on LM Q510N in debug mode...
Error: Couldn't resolve the package 'wifi_scan' in 'package:wifi_scan/wifi_scan.dart'.
: Error: Not found: 'package:wifi_scan/wifi_scan.dart'
import 'package:wifi_scan/wifi_scan.dart';
^

: Error: Type 'WiFiAccessPoint' not found.
List accessPoints = [];
^^^^^^^^^^^^^^^
: Error: Type 'WiFiAccessPoint' not found.
StreamSubscription<Result<List, GetScannedResultsErrors>>?
^^^^^^^^^^^^^^^
: Error: Type 'GetScannedResultsErrors' not found.
StreamSubscription<Result<List, GetScannedResultsErrors>>?
^^^^^^^^^^^^^^^^^^^^^^^
: Error: Type 'Result' not found.
StreamSubscription<Result<List, GetScannedResultsErrors>>?

                 ^^^^^^

: Error: Expected 0 type arguments.
StreamSubscription<Result<List, GetScannedResultsErrors>>?
^
: Error: Type 'WiFiAccessPoint' not found.
Result<List, GetScannedResultsErrors> result) {
^^^^^^^^^^^^^^^
: Error: Type 'GetScannedResultsErrors' not found.
Result<List, GetScannedResultsErrors> result) {
^^^^^^^^^^^^^^^^^^^^^^^
: Error: Type 'Result' not found.
Result<List, GetScannedResultsErrors> result) {
^^^^^^
: Error: Expected 0 type arguments.
Result<List, GetScannedResultsErrors> result) {

  ^

: Error: Type 'WiFiAccessPoint' not found.
Widget _buildAccessPointTile(BuildContext context, WiFiAccessPoint ap) {

                                                 ^^^^^^^^^^^^^^^

: Error: Couldn't find constructor 'StandardMethodCodec'.
const MethodChannel(this.name, [this.codec = const StandardMethodCodec(), BinaryMessenger? binaryMessenger ])
^^^^^^^^^^^^^^^^^^^

: Error: Couldn't find constructor 'StandardMethodCodec'.
const OptionalMethodChannel(String name, [MethodCodec codec = const StandardMethodCodec(), BinaryMessenger? binaryMessenger])
^^^^^^^^^^^^^^^^^^^
: Error: Couldn't find constructor 'StandardMethodCodec'.
const EventChannel(this.name, [this.codec = const StandardMethodCodec(), BinaryMessenger? binaryMessenger])
^^^^^^^^^^^^^^^^^^^
: Error: Method not found: 'JSONMethodCodec'.
JSONMethodCodec(),
^^^^^^^^^^^^^^^

: Error: Method not found: 'JSONMethodCodec'.
JSONMethodCodec(),
^^^^^^^^^^^^^^^
: Error: Method not found: 'JSONMethodCodec'.
JSONMethodCodec(),
^^^^^^^^^^^^^^^
: Error: Method not found: 'JSONMessageCodec'.
JSONMessageCodec(),
^^^^^^^^^^^^^^^^
: Error: Method not found: 'StringCodec'.

  StringCodec(),
  ^^^^^^^^^^^

: Error: Method not found: 'JSONMessageCodec'.
JSONMessageCodec(),
^^^^^^^^^^^^^^^^
: Error: Method not found: 'StandardMessageCodec'.
StandardMessageCodec(),
^^^^^^^^^^^^^^^^^^^^

: Error: Method not found: 'JSONMethodCodec'.
JSONMethodCodec(),
^^^^^^^^^^^^^^^
: Error: Method not found: 'JSONMethodCodec'.
JSONMethodCodec(),
^^^^^^^^^^^^^^^

: Error: 'WiFiAccessPoint' isn't a type.
List accessPoints = [];
^^^^^^^^^^^^^^^
: Error: 'WiFiAccessPoint' isn't a type.

List accessPoints = [];
^^^^^^^^^^^^^^^
: Error: 'WiFiAccessPoint' isn't a type.
StreamSubscription<Result<List, GetScannedResultsErrors>>?
^^^^^^^^^^^^^^^
: Error: 'GetScannedResultsErrors' isn't a type.
StreamSubscription<Result<List, GetScannedResultsErrors>>?

                                               ^^^^^^^^^^^^^^^^^^^^^^^

: Error: 'Result' isn't a type.
StreamSubscription<Result<List, GetScannedResultsErrors>>?
^^^^^^
: Error: 'WiFiAccessPoint' isn't a type.
Result<List, GetScannedResultsErrors> result) {
^^^^^^^^^^^^^^^
: Error: 'GetScannedResultsErrors' isn't a type.
Result<List, GetScannedResultsErrors> result) {
^^^^^^^^^^^^^^^^^^^^^^^
: Error: 'Result' isn't a type.
Result<List, GetScannedResultsErrors> result) {

  ^^^^^^

: Error: 'WiFiAccessPoint' isn't a type.
setState(() => accessPoints = []);

                                 ^^^^^^^^^^^^^^^

: Error: The getter 'WiFiScan' isn't defined for the class '_MyAppState'.

  • '_MyAppState' is from 'package:flutter/src/services/message_codecs.dart' ('../../../../../sdk/flutter/packages/flutter/lib/src/services/message_codecs.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'WiFiScan'.
    subscription = WiFiScan.instance.onScannedResultsAvailable
    ^^^^^^^^
    : Error: 'WiFiAccessPoint' isn't a type.
    Widget _buildAccessPointTile(BuildContext context, WiFiAccessPoint ap) {
    ^^^^^^^^^^^^^^^
    : Error: 'WiFiAccessPoint' isn't a type.
    setState(() => accessPoints = []);
    ^^^^^^^^^^^^^^^
    : Error: The getter 'WiFiScan' isn't defined for the class '_MyAppState'.

  • '_MyAppState' is from 'package:flutter/src/services/message_codecs.dart' ('../../../../../sdk/flutter/packages/flutter/lib/src/services/message_codecs.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'WiFiScan'.
    future: WiFiScan.instance.hasCapability(),

                ^^^^^^^^
    

: Error: The getter 'WiFiScan' isn't defined for the class '_MyAppState'.

  • '_MyAppState' is from 'package:flutter/src/services/message_codecs.dart' ('../../../../../sdk/flutter/packages/flutter/lib/src/services/message_codecs.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'WiFiScan'.

                        final error = await WiFiScan.instance.startScan();
                                            ^^^^^^^^
    

: Error: The getter 'WiFiScan' isn't defined for the class '_MyAppState'.

  • '_MyAppState' is from 'package:flutter/src/services/message_codecs.dart' ('../../../../../sdk/flutter/packages/flutter/lib/src/services/message_codecs.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'WiFiScan'.
    await WiFiScan.instance.getScannedResults()),
    ^^^^^^^^
    : Error: Couldn't find constructor 'StandardMessageCodec'.
    return const StandardMessageCodec().decodeMessage(encoded) as Map<Object?, Object?>?;
    ^^^^^^^^^^^^^^^^^^^^
    : Error: Couldn't find constructor 'StandardMessageCodec'.

    final ByteData encoded = const StandardMessageCodec().encodeMessage(data)!;
    ^^^^^^^^^^^^^^^^^^^^
    : Error: Couldn't find constructor 'StandardMessageCodec'.
    const StandardMessageCodec().encodeMessage(object);
    ^^^^^^^^^^^^^^^^^^^^

: Error: Couldn't find constructor 'StandardMessageCodec'.
args != null ? const StandardMessageCodec().decodeMessage(args) : null,
^^^^^^^^^^^^^^^^^^^^
Unhandled exception:
FileSystemException(uri=org-dartlang-untranslatable-uri:package%3Awifi_scan%2Fwifi_scan.dart; message=StandardFileSystem only supports file:* and data:* URIs)
#0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:34:7)
#1 asFileUri (package:vm/kernel_front_end.dart:623:37)

#2 writeDepfile (package:vm/kernel_front_end.dart:763:21)

#3 FrontendCompiler.compile (package:frontend_server/frontend_server.dart:586:9)

#4 starter (package:flutter_frontend_server/server.dart:85:12) #5 main (file:///opt/s/w/ir/cache/builder/src/flutter/flutter_frontend_server/bin/starter.dart:13:24)

FAILURE: Build failed with an exception.

  • Where:
    Script '/Users/kevin/sdk/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1102

  • What went wrong:
    Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command '/Users/kevin/sdk/flutter/bin/flutter'' finished with non-zero exit value 1

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 10s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

iOS support

Is there any change iOS support will get built in?

Get Started code has errors.

Below is the resolved code.

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

import 'package:wifi_hunter/wifi_hunter.dart';
import 'package:wifi_hunter/wifi_hunter_result.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  WiFiHunterResult wiFiHunterResult = WiFiHunterResult();

  Future<void> huntWiFis() async {
    try {
      wiFiHunterResult = (await WiFiHunter.huntWiFiNetworks)!;
    } on PlatformException catch (exception) {
      print(exception.toString());
    }

    for (var i = 0; i < wiFiHunterResult.results.length; i++) {
      print(wiFiHunterResult.results[1].ssid);
      print(wiFiHunterResult.results[1].bssid);
      print(wiFiHunterResult.results[1].capabilities);
      print(wiFiHunterResult.results[1].frequency);
      print(wiFiHunterResult.results[1].level);
      print(wiFiHunterResult.results[1].channelWidth);
      print(wiFiHunterResult.results[1].timestamp);
    }

    if (!mounted) return;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('WiFiHunter example app'),
        ),
        body: ElevatedButton(
          onPressed: () => huntWiFis(),
          child: const Text('Hunt Networks'),
        ),
      ),
    );
  }
}

deprecated API

I get this error while building:

.pub-cache/hosted/pub.dartlang.org/wifi_hunter-1.1.0/android/src/main/java/klydra/wifi_hunter/WiFiHunterPlugin.java uses or overrides a deprecated API.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.