tintinweb / scapy-ssl_tls

SSL/TLS layers for scapy the interactive packet manipulation tool
GNU General Public License v2.0
419 stars 156 forks source link

Bring support for Scapy 2.4 #136

Closed wasilukm closed 6 years ago

wasilukm commented 6 years ago

I was continuing @googlebleh work from #132 PR which was not updated for long time. Now all test are passing. Please review and let me know if there is anything else to be done before merge. I will be grateful if this PR is quickly merged and new version of the library released.

sk1985 commented 6 years ago

Hi Wasilkum, I installed the latest changes that you put in change list dd4f2ed. But still I am not able to make ssl_tls work with scapy. Here's what I did: :/tmp/scapy-ssl_tls-2.0.0/scapy-ssl_tls-dd4f2ed6d5806e07065ec84ec55c31e3c80bfc64$ sudo pip3 install -r requirements.txt Requirement already satisfied: pycryptodomex>=3.4 in /usr/local/lib/python3.5/dist-packages (from -r requirements.txt (line 1)) (3.6.4) Requirement already satisfied: scapy==2.4.* in /usr/local/lib/python3.5/dist-packages (from -r requirements.txt (line 2)) (2.4.0) Requirement already satisfied: tinyec>=0.3.1 in /usr/local/lib/python3.5/dist-packages (from -r requirements.txt (line 3)) (0.3.1)

:/tmp/scapy-ssl_tls-2.0.0/scapy-ssl_tls-dd4f2ed6d5806e07065ec84ec55c31e3c80bfc64$ sudo python setup.py install INFO: Installing scapy-ssl_tls layers to: [] running install running build running build_py running install_lib running install_egg_info running egg_info writing requirements to scapy_ssl_tls.egg-info/requires.txt writing scapy_ssl_tls.egg-info/PKG-INFO writing top-level names to scapy_ssl_tls.egg-info/top_level.txt writing dependency_links to scapy_ssl_tls.egg-info/dependency_links.txt reading manifest file 'scapy_ssl_tls.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'scapy_ssl_tls.egg-info/SOURCES.txt' removing '/usr/local/lib/python2.7/dist-packages/scapy_ssl_tls-2.0.0.egg-info' (and everything under it) Copying scapy_ssl_tls.egg-info to /usr/local/lib/python2.7/dist-packages/scapy_ssl_tls-2.0.0.egg-info running install_scripts running post install task INFO: Installing scapy-ssl_tls layers to: []

When trying to Verify installation getting: $ python3 Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information.

TLS Traceback (most recent call last): File "", line 1, in NameError: name 'TLS' is not defined

$scapy from scapy_ssl_tls.ssl_tls import TLS Traceback (most recent call last): File "/usr/lib/python3.5/code.py", line 91, in runcode exec(code, self.locals) File "", line 1, in ImportError: No module named 'scapy_ssl_tls'

Any help is really appreciated

wasilukm commented 6 years ago

Hi,

As I see you have installed scapy-ssl_tls using Python 2.7 but later you are trying to import this library under Python 3.5. Python 3 and 2.7 installations does not share packages.

Moreover as I know scapy-ssl_tls does not officially support Python 3.

sk1985 commented 6 years ago

Thanks for your reply. I have tried with both versions.

When I am launching scapy its giving me warning that its not able to find ssl_tls registry. Can you help me solve this issue?? $ scapy WARNING: No route found for IPv6 destination :: (no default route?). This affects only IPv6 INFO: This PyPI package is frozen and will not receive future updates. Please, see more information on https://github.com/phaethon/kamene WARNING: can't import layer ssl_tls: No module named 'ssl_tls_registry'

Also, when I tried to execute sudo ./ci-runtests.sh all tests failed due to same registry error.

Python 2.7 is also giving me same error $ python Python 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information.

TLS Traceback (most recent call last): File "", line 1, in NameError: name 'TLS' is not defined

wasilukm commented 6 years ago

Hi,

  1. Make sure that you don't have other scapy versions, uninstall all
  2. Make sure that you don't have scapy3k nor kamene which could be incorrectly packaged as scapy (you last comment suggests that). Uninstall all packages which mentions scapy.
  3. To install properly scapy-sll_tls from this PR you can follow an example:
    $ git clone https://github.com/tintinweb/scapy-ssl_tls.git
    Cloning into 'scapy-ssl_tls'...
    remote: Counting objects: 2470, done.
    remote: Total 2470 (delta 0), reused 0 (delta 0), pack-reused 2470
    Receiving objects: 100% (2470/2470), 1.03 MiB | 1.28 MiB/s, done.
    Resolving deltas: 100% (1602/1602), done.
    $ cd scapy-ssl_tls/
    $ git fetch origin pull/136/head:wasilukm/upgrade_to_scapy_2_4
    remote: Counting objects: 55, done.
    remote: Compressing objects: 100% (5/5), done.
    remote: Total 55 (delta 30), reused 28 (delta 28), pack-reused 22
    Unpacking objects: 100% (55/55), done.
    From https://github.com/tintinweb/scapy-ssl_tls
    * [new ref]         refs/pull/136/head -> wasilukm/upgrade_to_scapy_2_4
    $ git checkout wasilukm/upgrade_to_scapy_2_4 
    Switched to branch 'wasilukm/upgrade_to_scapy_2_4'
    $ pip install -e .
    Obtaining file:///home/mara/repos/scapy-ssl_tls
    Collecting pycryptodomex>=3.4 (from scapy-ssl-tls==2.0.0)
    Using cached https://files.pythonhosted.org/packages/c6/77/7e33afb130f80e8c5e6e5a89cfb844d15f17e077ee073a534cb54f336f2b/pycryptodomex-3.6.4-cp27-cp27mu-manylinux1_x86_64.whl
    Collecting scapy==2.4.* (from scapy-ssl-tls==2.0.0)
    Collecting tinyec>=0.3.1 (from scapy-ssl-tls==2.0.0)
    Installing collected packages: pycryptodomex, scapy, tinyec, scapy-ssl-tls
    Running setup.py develop for scapy-ssl-tls
    Successfully installed pycryptodomex-3.6.4 scapy-2.4.0 scapy-ssl-tls tinyec-0.3.1
    $ python
    Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) 
    [GCC 7.3.0] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from scapy_ssl_tls import ssl_tls
    >>> print ssl_tls
    <module 'scapy_ssl_tls.ssl_tls' from 'scapy_ssl_tls/ssl_tls.py'>
    >>> 
tintinweb commented 6 years ago

Hey @wasilukm, thanks for the PR. Are you still working on this or is it fine for review?

cheers, tin

wasilukm commented 6 years ago

Hi @tintinweb Yeah it's ready for review.

tintinweb commented 6 years ago

allright, I'll try to squeeze the review into my schedule for this week @wasilukm. 👍

added @alexmgr as a reviewer. let me know if you have some input :)

sk1985 commented 6 years ago

Hi, unfortunately I'm still getting some issues. I did uninstall all scapy as well as scapy_ssl_tls and then tried but still NOT able to make it work.

:~/scapy-ssl_tls$ sudo -H pip install -e . Obtaining file:///home/testuser/scapy-ssl_tls Requirement already satisfied: pycryptodomex>=3.4 in /usr/local/lib/python3.5/dist-packages (from scapy-ssl-tls==2.0.0) (3.6.4) Requirement already satisfied: scapy==2.4.* in /usr/local/lib/python3.5/dist-packages (from scapy-ssl-tls==2.0.0) (2.4.0) Requirement already satisfied: tinyec>=0.3.1 in /usr/local/lib/python3.5/dist-packages (from scapy-ssl-tls==2.0.0) (0.3.1) Installing collected packages: scapy-ssl-tls Found existing installation: scapy-ssl-tls 2.0.0 Uninstalling scapy-ssl-tls-2.0.0: Successfully uninstalled scapy-ssl-tls-2.0.0 Running setup.py develop for scapy-ssl-tls Successfully installed scapy-ssl-tls testuser@sk-automation:~/scapy-ssl_tls$ python Python 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information.

from scapy_ssl_tls import ssl_tls Traceback (most recent call last): File "", line 1, in File "scapy_ssl_tls/ssl_tls.py", line 5, in from scapy.packet import bind_layers, Packet, Raw ImportError: No module named scapy.packet

drwxr-sr-x 2 root staff 4096 Jan 17 2018 scapy_python3-0.23.dist-info drwxr-sr-x 13 root staff 4096 Aug 9 09:36 Cryptodome drwxr-sr-x 2 root staff 4096 Aug 9 09:36 pycryptodomex-3.6.4.dist-info drwxr-sr-x 3 root staff 4096 Aug 9 09:36 tinyec drwxr-sr-x 2 root staff 4096 Aug 9 09:36 tinyec-0.3.1.egg-info drwxr-sr-x 10 root staff 4096 Aug 13 09:00 scapy drwxr-sr-x 2 root staff 4096 Aug 13 09:00 scapy-2.4.0.egg-info -rw-r--r-- 1 root staff 44 Aug 13 09:00 scapy-ssl-tls.egg-link -rw-r--r-- 1 root staff 238 Aug 13 09:00 easy-install.pth

wasilukm commented 6 years ago

@sk1985 you still have problem related to Python 2 and 3. Make sure that you are executing pip in scope of Python 2: python -m pip install -e .

sk1985 commented 6 years ago

Finally able to make it work with Python3. Need to make some hacks in your code to make it compatible with Python3.

I modify ssl_tls.py and also had to append ssl_tls_registry path to default $PYTHONPATH One Question: Why do you have init.py empty>?? Shouldn't it have some things in it so that Python can import the modules/classes correctly??

$ python3 Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information.

from scapy.all import * WARNING: No route found for IPv6 destination :: (no default route?). This affects only IPv6 TLS <class 'scapy.layers.ssl_tls.SSL'> SSL <class 'scapy.layers.ssl_tls.SSL'> TLSRecord <class 'scapy.layers.ssl_tls.TLSRecord'>

tintinweb commented 6 years ago

@sk1985

wasilukm commented 6 years ago

Hi @tintinweb and @alexmgr, any progress in this PR?

tintinweb commented 6 years ago

excellent work. thanks for the contribution.

//fixed the testcase with https://github.com/tintinweb/scapy-ssl_tls/commit/bd2609486422aab5e51256bb3b06ad361bb53e88

sk1985 commented 6 years ago

@tintinweb can I have .tar package for scapy_ssl_tls with these #136 changes?? I need to install it on Ubuntu 18 thanks,

tintinweb commented 6 years ago

@sk1985,

install the latest master via pip. pip install "git+https://github.com/tintinweb/scapy-ssl_tls.git@master" --upgrade

sk1985 commented 6 years ago

Thanks @tintinweb I am getting thi error: Collecting git+https://github.com/tintinweb/scapy-ssl_tls.git@master Cloning https://github.com/tintinweb/scapy-ssl_tls.git (to revision master) to /tmp/pip-req-build-g7oal6w_ Complete output from command python setup.py egginfo: Traceback (most recent call last): File "", line 1, in File "/tmp/pip-req-build-g7oal6w/setup.py", line 32 except AttributeError, ex: ^ SyntaxError: invalid syntax

----------------------------------------

Command "python setup.py egginfo" failed with error code 1 in /tmp/pip-req-build-g7oal6w/