Skip to content
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

IPV6 support #80

Open
ghost opened this issue Mar 18, 2018 · 8 comments
Open

IPV6 support #80

ghost opened this issue Mar 18, 2018 · 8 comments

Comments

@ghost
Copy link

ghost commented Mar 18, 2018

Good evening, I would like to congratulate you on the excellent tool. After much research and several attempts, I found Heralding, this fantastic tool that allows you to capture undue access attempts; as it is simple to install, the tutorial is very well explained and the logs very intuitive.
My final undergraduate work is using this amazing tool. I am using only for IPv4 however, a colleague asked me if there would be support for IPv6?
Att.

Felipe Duarte

@kajojify
Copy link
Contributor

@feliped79 Hello! Thanks for your opinion!
I think we can add IPv6 support, if @johnnykv doesn't mind of course :)
Good luck with your undergraduate work!

@johnnykv
Copy link
Owner

johnnykv commented Mar 19, 2018

Yes, ipv6 should be possible, I wonder if all it takes is to do two create_server for each capability?

@kajojify
Copy link
Contributor

kajojify commented Mar 19, 2018

@johnnykv I played with asyncio.start_server a little bit yesterday.
There are 2 variants:

  1. Implement two modes separately: ipv4 mode and ipv6 mode.
  2. Implement one mode, which works fine with both ipv4 and ipv6 modes.

For the first variant we can teach mitmproxy to respect -4 and -6 console arguments or --ipv4 and --ipv6. Then depending on the chosen variant:
ipv4

server_coro = asyncio.start_server(cap.handle_session, '0.0.0.0', port,
                                   loop=self.loop, family=socket.AF_INET)

ipv6

server_coro = asyncio.start_server(cap.handle_session, '::', port, 
                                   loop=self.loop, family=socket.AF_INET6)

For the second variant:

sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
sock.bind(('::', port))

server_coro = asyncio.start_server(cap.handle_session, sock=sock, loop=loop)

@ghost
Copy link
Author

ghost commented Mar 19, 2018

Wow, that's cool, I hope one day I'll get to that level of programming in Python and networks too ... but for now I know only the basics of Python.

@johnnykv johnnykv changed the title Congratulations and a doubt ... IPV6 support Mar 27, 2018
@kajojify
Copy link
Contributor

kajojify commented Apr 17, 2018

@feliped79 Hello again! :)
I've just looked through possible variants of ipv6 support providing and found out an interesting thing.
Heralding already has basic support of ipv6 support.
asyncio.start_server has attribute family, which is inteded to choose ip version

family can be set to either socket.AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to socket.AF_UNSPEC).

The thing is asyncio.start_server can automatically choose appropriate family relying on the specified host.
Host is taken from config file heralding.yml. So you can enable ipv6 by setting ipv6 host address into config file directly:

image
or
image

@johnnykv
Copy link
Owner

Yes, confirmed. It sure does work:

$ telnet ::1
Trying ::1...
Connected to ::1.
Escape character is '^]'.
Username: james
Password:

And log_auth:

2018-04-27 19:35:14.490495,cd100a4f-64dd-4fe2-a403-0fec5d048495,f188c3f7-bf3c-46cc-b387-aeb68c6a73bc,::1,33636,,23,telnet,james,bond

I guess the challenge now is how to make it listen to both ipv6 and 4?

@slavkoja
Copy link

perhaps this can help about binding socket to both https://bugs.python.org/issue17561

@hammas9
Copy link

hammas9 commented Mar 3, 2020

Hi @johnnykv and others interested in this thread,
Did you end up adding IPv6 support to Heralding officially? Or do I still have to go by the way mentioned above?

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants