-
-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Find IP based on packets without MAC #302
base: main
Are you sure you want to change the base?
Conversation
@eyJhb haha that's a clever hack! I like it :-D wdyt about adding a flag that automatically creates noise? |
ios/pcap/ipfinder.go
Outdated
} | ||
|
||
func findIp(device ios.DeviceEntry, mac string) (NetworkInfo, error) { | ||
intf, err := ios.ConnectToService(device, "com.apple.pcapd") | ||
// FindIp reads pcap packets until one is found that matches the given MAC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a comment explaining how this works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be resolved in latest commit.
ios/pcap/ipfinder.go
Outdated
func startCapture(device ios.DeviceEntry, c chan PacketInfo, done chan bool) error { | ||
intf, err := ios.ConnectToService(device, "com.apple.pcapd") | ||
if err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recently learned that for debugging things later, in Golang it is a good practice to wrap errors and indicate the function name of where they happened. So rather than just returning err here and in other places, it is better to do sth like:
return fmt.Errorf("startCapture: failed connecting to com.apple.pcapd with err: %w, err)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be resolved in latest commit.
Thanks! I quite like it as well! :D - We could just open Apple Maps :) That generates a lot of traffic, and was something I was playing with. It could be a flag to disable/enable it. I'll be looking at the PR again after Christmas, hopefully that's OK with you! |
That's a really good idea :-D |
So I've fixed the two comments, but I haven't added another flag. I've thought if it wouldn't make more sense, to just tell the user to run something like Also, I still have no clue why |
I'll take a look later today. I love this PR, it wins my prize of most creative solution ever :-D |
I changed it to this to remove the goroutines
Wdyt? |
main.go I did like this:
and then:
|
Thanks! It's a neat little hack, when Apple doesn't want to expose such information (weirdos) :D
Much cleaner! Would much rather have that, than the goroutines! I'll be updating the PR to reflect that change. :)
Perfect, thank you. I'll be playing around with that! :) Hopefully I'll be able to have it all put together, and tested before the end of the day. |
So I've updated the PR with the latest changes. I really like the idea of using the timer for stopping the process, great work!
It defaults to 10s timeout., which should be fine? Sorry for not doing this before, it's been quite a busy time.... |
The lazy option will find the IP based on how many packets it sees with X address. The IP with the most packets to/from should most likely be the address of the device itself, unless it only contacts a single other host.
I've squashed my commits into a single one, I think this is good to merge? Please test as well to ensure it however. |
sorry for the delay @eyJhb we've been a bit busy with the ios17 work. I will check and merge this today. Thank you so much for this clever solution :-D |
Awesome! Take your time, I think that ios17 work is much more important :) So no pressure from me. If there is anything I can help you with to speed up the process, please do let me know! :) |
@danielpaulus any time for reviewing this? :D |
This implements a way to find the IP address of the device, without using the mac address of the device.
Basically just counts the number of occurrences of the IP in the src, and then takes the one with the most, as it's most likely to be the correct one.
Works fine, if you make some noise while it's running.
I can't get the
--duration
to work however, not sure why.But I would appreciate some comments on this.
Also functions are not named
findIp
,findIp
andfindIP
anymore. Should be more readable.@shamanec and @danielpaulus WIP as I would appreciate any comments on this.