An iOS LAN Network Scanner library

Overview

MMLanScan

MMLanScan is an open source project for iOS that helps you scan your network and shows the available devices and their MAC Address, hostname and Brand name.

Important for iOS 11

iOS 11 is breaking the MAC address retrieval from ARP table so MAC Addresses and Brands won't work on MMLanScan with iOS 11. We still using MacFinder since it's helpful in order to discover online devices that won't reply to pings.

Note

You can find a NativeScript wrapper of MMLanScan here!

Screenshot

image

Features

  • Scans and finds available hosts in your network
  • Shows IP Address
  • Shows MAC Address (iOS 10 and below)
  • Shows Brand of device based on MAC Address (iOS 10 and below)
  • Shows hostname (if available)
  • Scan any subnet (not only /24)
  • Gives you the ability to update the OUI (MAC-Brand mappings) plist file. Check in MainPresenter.m for more details

Manual Installation

  • Drag n Drop the MMLanScan folder in your project.

CocoaPods Installation

To install using CocoaPods, simply add the following line to your Podfile:

pod 'MMLanScan'

How to use it (Objective C)

Import MMLANScanner in your controller

#import "MMLANScanner.h"

Add the MMLANScannerDelegate (Protocol) to your controller

@interface YourViewController () <MMLANScannerDelegate>

Declare a property

@property(nonatomic,strong)MMLANScanner *lanScanner;

Initialize with delegate

self.lanScanner = [[MMLANScanner alloc] initWithDelegate:self];

Start the scan

[self.lanScanner start];

Implement the delegates methods to receive events

- (void)lanScanDidFindNewDevice:(MMDevice*)device;
- (void)lanScanDidFinishScanningWithStatus:(MMLanScannerStatus)status;
- (void)lanScanProgressPinged:(NSInteger)pingedHosts from:(NSInteger)overallHosts;
- (void)lanScanDidFailedToScan;

How to use it (Swift)

After Drag n Drop the MMLanScan folder in your Swift project Xcode will ask you to create a bridging header. Create the bridging header and copy paste the following between #define and #endif:

#import "MMLANScanner.h"
#import "LANProperties.h"
#import "PingOperation.h"
#import "MMLANScanner.h"
#import "MACOperation.h"
#import "MacFinder.h"
#import "MMDevice.h"

Add the MMLANSCannerDelegate (Protocol) to your controller

class MyVC: NSObject, MMLANScannerDelegate 

Declare the variable for the MMLanScanner

var lanScanner : MMLANScanner!

Initialise the MMLanScanner (after self is initialised)

self.lanScanner = MMLANScanner(delegate:self)

And finally start the scan:

self.lanScanner.start()

Or stop the scan

self.lanScanner.stop()

Implement the delegates methods to receive events

func lanScanDidFindNewDevice(_ device: MMDevice!)
func lanScanDidFinishScanning(with status: MMLanScannerStatus)
func lanScanProgressPinged(_ pingedHosts: Float, from overallHosts: Int)
func lanScanDidFailedToScan()

Project Demo

You can find project demos available in Swift or Objective-C. Feel free to copy/use them for your product. Note: Project demos are written using software design pattern MVVM

How it works

MMLanScan works like the classic network scanner. It first ping every host in the network in order to built the ARP table and then is trying to get the MAC Address for each host. If a MAC Address is found then it's considered that the host exist in the network.

Libraries used to built MMLanScan

Technical Stuff

MMLanScan V2.0 is now using NSOperation and NSOperationQueueManager. Scanning time, and UI interactions are improved compared to V1.0. Also V1.0 was ignoring hosts that didn't replied to pings. V2.0 is not and the result is now accurate.

TODO

If anyone would like to help:

  • Convert the [OUI] (https://standards.ieee.org/develop/regauth/oui/oui.txt) text in a dictionary so we can map MAC Address with vendor (Hint: The Regex to catch the first line with MAC Address and vendor: [A-F0-9]{2}-[A-F0-9]{2}-[A-F0-9]{2}\s*\(hex\)\s*[A-Za-z\.\, \-]+)
  • Make it work in a background thread. Apple's SimplePing has issues when it comes to GCD (it's built on C libraries and it seems their callbacks won't work with GCD)
  • Get hostname from IP address method is not working
  • Anything that you feel that will improve this library.

More Details

Visit my article for MMLanScan for more details

Authors

  • Michael Mavris

Credits

License

Copyright Miksoft 2017

Licensed under the MIT License

Comments
  • iOS 10.3 and MAC-address

    iOS 10.3 and MAC-address

    Is seems that iOS 10.2 has damaged something and MAC-resolving isn't working. Every IP has MAC like "02:00:00:00:00:00"

    Do you have any idea how to fix it?

    opened by akaDuality 135
  • How to getHostName in swift?

    How to getHostName in swift?

    I tried get hostname in this code

    func lanScanDidFindNewDevice(device: Device!) { // print("This is Device : "+"(device)") //Adding the found device in the array if(device.brand.containsString("Apple")){ print("DeviceInfo : "+"(device.macAddressLabel())"+"(device.hostname)\n") } self.connectedDevices?.append(device) }

    but hostName is "nil"

    I using swift 2.2 and xcode 7 and also I am beginner developer so I need your help please tell me how can I get HostName

    opened by ChoiSeungchan 16
  • MMLanScan fails to work in Class A network subnet

    MMLanScan fails to work in Class A network subnet

    Hi MMLanScan fails to work in Class A network.

    my IP/Subnet = 10.231.154.136/255.254.0.0

    ipcalc shows 131070 possible hosts in given subnet

    Address:   10.231.154.136       00001010.1110011 1.10011010.10001000
    Netmask:   255.254.0.0 = 15     11111111.1111111 0.00000000.00000000
    Wildcard:  0.1.255.255          00000000.0000000 1.11111111.11111111
    =>
    Network:   10.230.0.0/15        00001010.1110011 0.00000000.00000000
    HostMin:   10.230.0.1           00001010.1110011 0.00000000.00000001
    HostMax:   10.231.255.254       00001010.1110011 1.11111111.11111110
    Broadcast: 10.231.255.255       00001010.1110011 1.11111111.11111111
    Hosts/Net: 131070                Class A, Private Internet
    

    where is NetworkCalculator.getAllHostsForIP calculates this amount to be ~2 million

    screen shot 2017-07-10 at 12 27 07 pm

    As a result array of IP's allocates ~100Mb of memory and MMLANScanner.start hangs

    opened by bexp 7
  • xcode9 issues

    xcode9 issues

    SimplePing.h

    • check_compile_time needs to be changed to __Check_Compile_Time

    MacFinder.h

    • This seems to be broken now. 'net/route.h' can't be found. Changing to "route.h" (as suggested by another issue) does not seem to fix the problem. MacFinder may have been broken by the iOS 11 crackdown on LanScanners (relevant link).
    opened by ThomasAriano 6
  • Question regarding Hostnames

    Question regarding Hostnames

    I'm using MMLanScan for my app but for some reason I don't get all hostnames. If I use apps like "fing" I get different names. Any hint why I get different results?

    image

    opened by Manuel83 4
  • Non connected device Data.

    Non connected device Data.

    Is it possible to get mac id of non-connected device also? Here , non-connected device is located in wifi range. I want to get the data of all devices(connected and non-connected) that located in wifi that connected my phone(installed this app). Thanks!

    opened by GuruDev920 2
  • What is the function to scan all the associated IP ?

    What is the function to scan all the associated IP ?

    Hi Mavris,

    Here in the function, I can see LANProperties, MMLanScan and others but I couldn't figure it out the correct function to call for scanning all the associated IP in a same network.

    Please bare with my noviceness and reply me at your earliest

    opened by Lintes 2
  •  Compatibility issues

    Compatibility issues

    Hi,

    When I run on iOS11, can not get Mac address, I found that you mentioned "iOS 11 is breaking the MAC address retrieval from ARP table so MAC Addresses and Brands won't work on MMLanScan with iOS 11. We still using MacFinder since it's helpful in order to discover online devices that won't reply to pings", where can there be other solutions or ideas? Please tell us.

    Thank you very much!

    opened by situyan 2
  • Not working in IPv6 networks

    Not working in IPv6 networks

    Hi, App become irresponsible and then crashes when I try to use scanner in IPv6 network

    self.device.ipAddress
    

    looks like 169.254.xxx.xxx

    [LANProperties getAllHostsForIP:self.device.ipAddress andSubnet:self.device.subnetMask];
    

    return an array of 65534 IPs from 169.254.1.1 to 169.254.255.255

    It will be great if you can fix this =)

    If you don't know how to test in ipv6 network look here

    Regards

    opened by DemianSteelstone 2
  • CocoaPods inegration: brand name is not showed

    CocoaPods inegration: brand name is not showed

    hello @mavris great job for CocoaPods support. I tested the pod, it doesn't work to get the brand name, I think it's because the data.plist file is not included. I creat a Pull Request for this, may fix this little bug.

    opened by yongjing 2
  • Xcode not linking with  LANProperties.o

    Xcode not linking with LANProperties.o

    Hi,

    I am trying to incorporate MMLANSCAN library into my existing project, but it shows the following error, when I try to add the MMLANSCAN folder

    Error
    Undefined symbols for architecture arm64: "_CNCopySupportedInterfaces", referenced from: +[LANProperties fetchSSIDInfo] in LANProperties.o "_CNCopyCurrentNetworkInfo", referenced from: +[LANProperties fetchSSIDInfo] in LANProperties.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

    Could you please help me to get out of this :-(

    opened by NANDEESHKUMAR 1
  • Mac empty when run with real device iOS 15.

    Mac empty when run with real device iOS 15.

    When I run it with simulator, it return Mac address but it return "02:00:00:00:00:00" with real device iOS 15.

    lanScanDidFindNewDevice: 192.168.31.1 - 02:00:00:00:00:00" "lanScanDidFindNewDevice: 192.168.31.48 - 02:00:00:00:00:00" "lanScanDidFindNewDevice: 192.168.31.64 - 02:00:00:00:00:00" "lanScanDidFindNewDevice: 192.168.31.55 - 02:00:00:00:00:00"

    opened by ttrong 0
  • [] nehelper sent invalid result code [1] for Wi-Fi information request

    [] nehelper sent invalid result code [1] for Wi-Fi information request

    I have found many solutions on the Internet, but none of them can solve this problem. Moreover, this problem does not exist on the simulator. I want to get the mac address of the device, which can be obtained on the simulator, but it shows 02:00:00:00:00:00 on the real machine. Is Apple now forbidden to obtain the mac address of the device? How can I solve it? Thank you!

    opened by lukj695725405 0
Owner
Michael Mavris
iOS, tvOS Developer
Michael Mavris
Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application.

Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application. Install Carthage

Ronan Rodrigo Nunes 89 Dec 26, 2022
A network extension app to block a user input URI. Meant as a network extension filter proof of concept.

URIBlockNE A network extension app to block a user input URI. Meant as a network extension filter proof of concept. This is just a research effort to

Charles Edge 5 Oct 17, 2022
Say goodbye to the Fat ugly singleton Network Manager with this Network Layer

MHNetwork Protocol Oriented Network Layer Aim to avoid having bloated singleton NetworkManager Philosophy the main philosophy behind MHNetwork is to h

Mohamed Emad Hegab 19 Nov 19, 2022
Easy and lightweight network layer for creating different set of network requests like GET, POST, PUT, DELETE customizable with coders conforming to TopLevelDecoder, TopLevelEncoder

Easy and lightweight network layer for creating different set of network requests like GET, POST, PUT, DELETE customizable with coders conforming to TopLevelDecoder, TopLevelEncoder

Igor 2 Sep 16, 2022
SwiftCANLib is a library used to process Controller Area Network (CAN) frames utilizing the Linux kernel open source library SOCKETCAN.

SwiftCANLib SwiftCANLib is a library used to process Controller Area Network (CAN) frames utilizing the Linux kernel open source library SOCKETCAN. Th

Tim Wise 4 Oct 25, 2021
A lightweight, one line setup, iOS / OSX network debugging library! 🦊

Netfox provides a quick look on all executed network requests performed by your iOS or OSX app. It grabs all requests - of course yours, requests from

Christos Kasketis 3.4k Dec 28, 2022
A lightweight but powerful network library with simplified and expressive syntax based on AFNetworking.

XMNetworking English Document XMNetworking 是一个轻量的、简单易用但功能强大的网络库,基于 AFNetworking 3.0+ 封装。 其中,XM 前缀是我们团队 Xcode-Men 的缩写。 简介 如上图所示,XMNetworking 采用中心化的设计思想

KANGZUBIN 981 Dec 29, 2022
A light weight network library with automated model parser for rapid development

Gem A light weight network library with automated model parser for rapid development. Managing all http request with automated model parser calls in a

Albin CR 10 Nov 19, 2022
A new, clean and lean network interface reachability library written in Swift.

Reachability A new, clean and lean network interface reachability library written in Swift. Remarks Network reachability changes can be monitored usin

Alecrim 7 Aug 8, 2022
iOS network debugging, like a wizard 🧙‍♂️

Start debugging iOS network calls like a wizard, without extra code! Wormholy makes debugging quick and reliable. What you can do: No code to write an

Paolo Musolino 2.1k Jan 8, 2023
iOS Network monitor/interceptor framework written in Swift

NetShears NetShears is a Network interceptor framework written in Swift. NetShears adds a Request interceptor mechanisms to be able to modify the HTTP

Divar 119 Dec 21, 2022
Network Diagnosis for iOS

Network Diagnosis for iOS 中文 Summary Network Diagnosis Library,support Ping/TcpPing/Rtmp/TraceRoute/DNS/external IP/external DNS。 Install CocoaPods po

Qiniu Cloud 139 Dec 10, 2022
An iOS app for communicating with your clightning node over the lightning network

An iOS app for communicating with your clightning node over the lightning network

William Casarin 18 Dec 14, 2022
iOS 15, MVVM, Async Await, Core Data, Abstract Network Layer, Repository & DAO design patterns, SwiftUI and Combine

iOS 15, MVVM, Async Await, Core Data, Abstract Network Layer, Repository & DAO design patterns, SwiftUI and Combine

Conrado Mateu Gisbert 18 Dec 23, 2022
Dratini is a neat network abstraction layer.

Dratini Dratini is a neat network abstraction layer. If you are looking for a solution to make your network layer neat, Dratini is your choice. Dratin

Kevin Lin 37 Jan 29, 2022
Network abstraction layer written in Swift.

Moya 14.0.0 A Chinese version of this document can be found here. You're a smart developer. You probably use Alamofire to abstract away access to URLS

Moya 14.4k Jan 1, 2023
A toolkit for Network Extension Framework

NEKit NEKit is deprecated. It should still work but I'm not intent on maintaining it anymore. It has many flaws and needs a revamp to be a high-qualit

zhuhaow 2.8k Jan 2, 2023
Elegant network abstraction layer in Swift.

Elegant network abstraction layer in Swift. 中文 Design Features Requirements Communication Installation Usage Base Usage - Target - Request - Download

null 100 Dec 9, 2022
Lightweight network abstraction layer, written on top of Alamofire

TRON is a lightweight network abstraction layer, built on top of Alamofire. It can be used to dramatically simplify interacting with RESTful JSON web-

MLSDev 528 Dec 26, 2022