Git Product home page Git Product logo

mmlanscan's Introduction

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

mmlanscan's People

Contributors

mavris avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mmlanscan's Issues

Scanning is too slow

Scanning all devices in my network takes 3:30 minutes . It takes 30 seconds to get the first device.

How can I solve this problem ??

SimplePing.h not found

Hello, I have an issue when I try to build my project.
The SimplePing.h is not found. Any ideas?

My deployment target is iOS 9.3

Thanks

capture d ecran 2017-02-15 a 11 22 51

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?

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.

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

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

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

List devices connected to iPhone's hotspot

HI there,

I'm hoping that this library has the capability to list the devices which are connected to an iPhones hotspot. I have tried with no success so far. Is this something which should be possible with the library.

Thanks

Mac Addresses are not getting in iOS 10.2

I am running this on my iPhone with OS version 10.2 and getting the follow mac address. And for all ip addresses it is same.
Found hostname: iphone
2016-12-17 15:00:33.188 Kisafa[387:102597] found 192.168.1.9
2016-12-17 15:00:33.196 Kisafa[387:102597] mac 02:00:00:00:00:00
2016-12-17 15:00:33.196 Kisafa[387:102597] device original mac = 02:00:00:00:00:00
2016-12-17 15:00:33.197 Kisafa[387:102597] device MAC = 000000

SimplePing behaving funny

I find that pinging a whole subnet will not report about 20% of the devices that should be there. Bigger numbers if the max concurrency count is higher.
When I do some logging inside [SimplePing readData], I see that all kinds of instances of Simple ping are receiving data from other pings. Somehow the SocketReadCallback gets called multiple times when data comes in. This might be related to this problem.

I'd love to solve this but might need a little extra help to fix it. Any ideas?

When I log who is receiving the data and where it came from, I get this:

  • start pinging 10.1.1.2
  • start pinging 10.1.1.1
  • start pinging 10.1.1.4
  • start pinging 10.1.1.3
  • SimplePing(10.1.1.1) receiving data from 10.1.1.1
  • SimplePing(10.1.1.2) receiving data from 10.1.1.1
  • start pinging 10.1.1.6
  • start pinging 10.1.1.5
  • SimplePing(10.1.1.4) receiving data from 10.1.1.1
  • start pinging 10.1.1.7
  • start pinging 10.1.1.8
  • start pinging 10.1.1.9
  • start pinging 10.1.1.10
  • start pinging 10.1.1.11
  • start pinging 10.1.1.12
  • SimplePing(10.1.1.8) receiving data from 10.1.1.10
  • SimplePing(10.1.1.10) receiving data from 10.1.1.10
  • SimplePing(10.1.1.7) receiving data from 10.1.1.10
  • SimplePing(10.1.1.6) receiving data from 10.1.1.10
  • SimplePing(10.1.1.9) receiving data from 10.1.1.10
  • SimplePing(10.1.1.8) receiving data from 10.1.1.12
  • SimplePing(10.1.1.12) receiving data from 10.1.1.12
  • SimplePing(10.1.1.7) receiving data from 10.1.1.12

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).

Scan devices in order?

Is there a way to seek in numerical ip address order?
ATM I store each find in an array and when lanScanDidFinishScanning the array is sorted then displayed. The drawback is the whole scan may take a while...
So I would like results shown as soon as found - but in order.

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!

Hostname issue

Sometimes host-names are not coming in list

Anyone can help with this issue?

Find Mac address

hi, Is there any way i can find MAC address on iOS11 ? i have to solve this problem .

[] 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!

Library without MAC and brand name?

hi
I am using this library in my project which runs on iPad with ios 11.2.

I would like to use only the Ip address and the number of device connected with the same network.

I dont want the details of MAC or brand name.

I tried changing the function [getMACdetails] but with no success.

Could you please help me with the library without mac or brand name?

Duplicates

results:
(one cell contains:)
192.168.1.25 / 255.255.255.0
(another cell contains:)
192.168.1.25 mac F0:24...(abbreviated)

Why is this repeated? (One has subnet-mask, one has mac address)

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"

Problem show data if my router (raspberry) not connected to Internet

Hi!
I try to use your proyect with a raspberry, my raspberry don´t have internet conexion. Then connect my iphone to wifi network raspberry , run your project and don´t have any response...
If connect my raspberry to internet or connect my iphone to my router with internet, your project work very well.
With ring app , I can see my iphone mac but my raspberry don´t have internet ...
I change AF_INET to AF_LOCAL or AF_UNIX , but don´t work...
I add and use this file in the project
[http://opensource.apple.com//source/bootp/bootp-133.8/bootplib/arp.c]
but only have mac and ip of my raspberry..
any idea how could get the mac if my iphone is connected to a wireless network without internet?
thanks for your time

regards!

get port and detect camera

hello. Can you provice me the way to detect if ip address is belong to camera and then get the port when have ip address

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!

Why I can't see hostname ?

    cell.ipLabel.text = device.ipAddress
    cell.macAddressLabel.text = device.macAddress
    cell.hostnameLabel.text = device.hostname
    cell.brandLabel.text = device.brand

In this code there is a hostname section but application doesn't show any value about hostname.

10.3.2 Mac Address Problem

I can see my device's mac address from another device but when I try to get my device's mac address from the same device what I get is only 02:00:00:00:00:00. How can I fix that?

Unable to install

I've added the line: pod 'MMLanScan' but when i try to install i've this error:

[!] Unable to find a specification for MMLanScan

How can i fix ?

Thanks

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

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 :-(

App crashing after ping

Screenshot 2019-06-19 at 14 39 01

When I start scanning the network, at some random time(not every time), the app crashes and I get this error. Can you please help me to fix it.

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

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.