I am using newest Kali and importing scapy ssl_tls package like this:
from scapy.layers.ssl_tls import *
But I get an error: WARNING: can't import layer ssl_tls: No module named ssl_tls
or
ImportError: No module named ssl_tls.
Also, to verify installation, I go into Scapy prompt and type TLS or SSL I get:
>>> TLS
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'TLS' is not defined
So it makes me believe that I didn't install it correctly. However I tried all 3 installation methods from official page and all worked without any errors.
I also have SSL installed: apt-get install libssl-dev
My system:
Linux kali 3.18.0-kali3-amd64 #1 SMP Debian 3.18.6-1~kali2 (2015-03-02) x86_64 GNU/Linux
Python2.7
Scapy version 2.2.1. Also tried 2.3.1.
scapy-ssl_tls version - current from https://github.com/tintinweb/scapy-ssl_tls
root#kali:~/Downloads# pip freeze | grep scapy
Warning: cannot find svn location for distribute==0.6.24dev-r0
scapy==2.2.0-dev
scapy-ssl-tls==1.2.1
NOTE: I have same exact python code running good on different Kali machine, on the same Python, Scapy and scapy-ssl_tls versions.
I just installed ssl_tls using pip. Using this installation method in my case config.py was not updated with added layer, which means that running scapy does not import ssl_tls automatically thus it is not possible to do from scapy.layers.ssl_tls import *. Your case sounds similar.
There are 2 options:
Update scapy's config.py (location depends on the way you installed scapy) by adding ssl_tls module. See https://github.com/tintinweb/scapy-ssl_tls#option-3-manual-installation for example
Import module using from scapy_ssl_tls.ssl_tls import * after importing scapy (or running scapy directly)
github/scapy-ssl_tls PR #55 fixes an issue where setup.py would not find all scapy installation dirs in case you have multiple locations for site-packages. Also see the updated installation instructions and troubleshooting. The fix is in master and will be in scapy-ssl_tls > 1.2.2. Please give it a try and raise a bug on github if this does not fix the issue for you. thanks
Please make sure your python version is > 2.7.6 and then run 'pip install scapy-ssl_tls'
Related
I am trying to make a nmap scanner for the InfoSec Certification on freeCodeCamp.org and cannot get Visual Studio Code to recognize that I have installed nmap. I am very beginner and in the process of learning.
from cProfile import run
import nmap
scanner = nmap.PortScanner()
print("Welcome, this is a simple automattion tool")
print("<------------------------------------------->")
When I run this in VS Code I get the following in the terminal:
PS C:\Users\mjame\OneDrive\Documents\Jim\Coding\fcc_python_for-pen_testing\nmap_scanner_1> python3 scanner.py
Traceback (most recent call last):
File "C:\Users\mjame\OneDrive\Documents\Jim\Coding\fcc_python_for-pen_testing\nmap_scanner_1\scanner.py", line 2, in <module>
import nmap
ModuleNotFoundError: No module named 'nmap'
PS C:\Users\mjame\OneDrive\Documents\Jim\Coding\fcc_python_for-pen_testing\nmap_scanner_1>
I have so far:
Updated to the current Python 3.10.7
Installed Nmap the first time from https://nmap.org/ for Windows
Uninstalled Nmap
Reinsalled Nmap using >>>pip3 install python-nmap
For future searchers (as in my comment above), if you installed a module with pip3 but are still getting module import errors, try python3 -m pip install <module-name>.
Not sure how/why this happens (pip3 installing somewhere that python3 is not looking for modules - maybe PYTHONPATH-related), but the above can [usually] help.
It seems that Python cannot find nmap module.
You can either add it to path in Windows via Start -> Edit system environment variables -> Environment variables... and then edit PATH VARIABLE by adding at the end path to nmap module that you have installed or move the module to default Python modules directory which should be C:\Users\YourLogin\AppData\Local\Programs\Python\Python310\Lib\site-packages
I'm trying to use w3af to start doing some routine security testing on a webapp that I'm using. Install instructions recommend cloning a git repo, then running the python code and seeing what dependencies are unmet then installing them. My first run yielded:
ModuleNotFoundError: No module named 'ConfigParser
OK, no problem, right?
$ pip install ConfigParser
Collecting ConfigParser
Downloading configparser-5.2.0-py3-none-any.whl (19 kB)
Installing collected packages: ConfigParser
Successfully installed ConfigParser-5.2.0
Mission accomplished, let's try again!
$ ./w3af_console
Traceback (most recent call last):
File "./w3af_console", line 12, in <module>
from w3af.core.controllers.dependency_check.dependency_check import dependency_check
File "/Users/westonx/bin/w3af/w3af/core/controllers/dependency_check/dependency_check.py", line 26, in <module>
from w3af.core.data.db.startup_cfg import StartUpConfig
File "/Users/westonx/bin/w3af/w3af/core/data/db/startup_cfg.py", line 22, in <module>
import ConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
Hmmm. Could swear we took care of that. Let's run pip (maybe pip3?) again to be sure?
$ pip3 install ConfigParser
Requirement already satisfied: ConfigParser in /Users/westonx/.pyenv/versions/3.8.2/lib/python3.8/site-packages (5.2.0)
Seems good. Let's check to see if the import path includes that directory:
$ python -c "import sys; print('\n'.join(sys.path)); import ConfigParser;"
/Users/westonx/.pyenv/versions/3.8.2/lib/python38.zip
/Users/westonx/.pyenv/versions/3.8.2/lib/python3.8
/Users/westonx/.pyenv/versions/3.8.2/lib/python3.8/lib-dynload
/Users/westonx/.pyenv/versions/3.8.2/lib/python3.8/site-packages
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'ConfigParser'
So... we know the sys.path includes the directory pip says the module is installed in, but when we import it, python insists it's not there.
configparser-5.2.0.dist-info and configparser.py are indeed in my ~/.pyenv/versions/3.8.2/lib/python3.8/site-packages directory, so it doesn't look like pip telling me something that's not true. But it sure looks like python is.
I'm using pyenv on MacOS 10.14, not sure if that makes a difference. Anyone have ideas of what next steps should be?
ConfigParser is a built in library in Python, but its name was changed to configparser in Python 3. It appears like w3af is still using Python 2 (I found this check that actively states it, but you never even got that far). So, to run this code, you need to run it with Python 2.
There are very many (thousands) of python3 compatibility issues with the w3af codebase. The ConfigParser issue is just the first one you hit - the codebase is full of references to outdated / unmaintained libraries, and has no support for python3 byte strings vs. unicode strings (b"" vs ""), which are used throughout the codebase.
There is a w4af project on Github, where someone has made the effort to port all the w3af code to python3, but you didn't hear that from me.
The issue
I've pip installed a library called disagree which installed and upgraded without any issues, confirming that the latest version had been successfully installed.
When running import disagree I get the error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'disagree'
Identifying what's causing the issue
Section 6.1.2 in https://docs.python.org/3/tutorial/modules.html#packages says that when a module is imported, if it is not in the sys.builtin_module_names, then it proceeds to search for it in the file paths specified in sys.path.
When I run sys.path I get:
['', '/Users/oliverprice/miniconda3/lib/python38.zip',
'/Users/oliverprice/miniconda3/lib/python3.8',
'/Users/oliverprice/miniconda3/lib/python3.8/lib-dynload',
'/Users/oliverprice/.local/lib/python3.8/site-packages',
'/Users/oliverprice/miniconda3/lib/python3.8/site-packages']
Indeed, looking into '/Users/oliverprice/miniconda3/lib/python3.8/site-packages' I can see the module that I've installed. However, it only has the .dist-info file for the package, not the actual package folder. I.e. rather than
name
name-version.dist-info
the only thing present is:
disagree-1.2.6.dist-info
So it looks like there is no actual package in there, and just the .dist-info. Specifically, this is a snapshot of what is in there:
defusedxml
defusedxml-0.6.0.dist-info
dill
dill-0.3.4.dist-info
disagree-1.2.6.dist-info
distutils-precedence.pth
docutils
docutils-0.16.dist-info
easy_install.py
entrypoints-0.3.dist-info
Questions
Is this the reason it is failing to import? If not, what is the reason?
If so, why has this happened?
I have the same issue here. This solution below worked for me.
First of all, check the version of python that you have (must be between python3.8 and 3.10 (included). No python3.7 and python3.11 as I understand.
To check it do this in your notebook/python:
import sys
print(sys.version)
If it matches with the 3.8-3.10 range, then you're ok and skip this step, otherwise you may need to do (in the terminal):
virtualenv venv --python=python3.8
source venv/bin/activate
Let's now install this library from source so that we have the needed source files. Run this in a terminal:
git clone https://github.com/o-P-o/disagree.git
cd disagree
# requirements fixed
pip install numpy pandas mathx scipy tqdm
# install this
pip install .
Now you should be able to import disagree, but with a twist:
from disagree import disagree
# or for example
from disagree.disagree.agreements import BiDisagreements
Please let me know if this works for you.
I will be doing a pull request to fix this library.
Martino
So my case is a tricky one.
I first installed OpenCV2.4.8 and started it using for python2.7. Later I planned to migrate to OpenCV3.0.0. Both the times during installation I followed the official documentation procedure. Everything was working fine until I realized that OpenCV3 doesn't have SIFT() and SURF() modules. After a bit of searching I found they are present in opencv_contrib. First I tried to install that but for some reason I couldn't.
Later I found that these modules are present in OpenCV2.4.11 and planned to install that. Again following the official procedure I installed OpenCV2.4.11 got the same SIFT() importerror. Upon checking the OpenCV __version__ in python2 and python3 I found the following
python2: "2.4.8"
python3: "3.0.0"
For checking the version I used the following code:
from cv2 import __version__
print(__version__)
Unfortunately I don't have a lot of memory in /home, so I had deleted OpenCV2.4.8 and OpenCV3.0.0 build folders after installing. Therefore, I tried to manually remove OpenCV2.4.8 and OpenCV3.0.0 and deleted all opencv the libs from /usr/local/libs/ and sub-directories and all the opencv bins from /usr/local/bins/ (following answer in this question).
After removing all opencv files I again reinstalled OpenCV2.4.11 and tried to run my code. It failed at the import step in python2 giving
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libopencv_core.so.2.4: cannot open shared object file: No such file or directory
in python3
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libopencv_core.so.3.0: cannot open shared object file: No such file or directory
I again checked if OpenCV2.4.11 is present or not and its there but the python hasn't updated the previously stored link to opencv lib. I'm stuck at this error since 2 days with no solution. Any help will be appreciated.
EDIT:
Is there some shared library lookup file which python uses to store all the locations of shared libraries? If not how does this work (how python recognizes where to look for opencv as opencv is not listed in pip freeze)
EDIT2:
I found another mistake. I hadn't enabled -D BUILD_SHARED_LIBS=ON before. This time I kept it ON and rand sudo ldconfig after make and make install. Now I have a libopencv_core.so.2.4 in my /usr/local/lib/. It is a symlink to libopencv_core.so.2.4.11 present in the same folder. After ldconfig when I checked for python2 import cv2 didn't show any error but __version__ still shows '2.4.8'. I double checked for any OpenCV2.4.8 .so file and there are none. How is it still pointing to version '2.4.8'?
Steps for removal:
remove opencv libs by : sudo apt-get purge libopencv*
Verify that whether cv2 is uninstalled by trying import cv2 in python. It should show no cv2 module present
Install opencv2.4.11 by following this sh file
Run sudo ldconfig after sudo make install
Things should usually work but it didn't work in my case because cv2.so was missing from /usr/local/lib/python2.7/dist-packages/. For that manually copy from /<opencv-2.4.11 unzip locaiton>/release/lib/cv2.so to /usr/local/lib/python2.7/dist-packages/. Use sudo for permissions.
Now import cv2 will work and __version__ is '2.4.11'.
I know this is not an actual info-sec question, but I am having problems with getting the smbrealyx.py module to work. For some reason I get the following error when I try to execute the aforementioned python program.
Traceback (most recent call last):
File "smbrelayx.py", line 43, in <module>
from impacket import smbserver, smb, ntlm, dcerpc, version
File "/usr/lib/python2.7/dist-packages/impacket/smbserver.py", line 18, in <module>
from impacket import smbserver, version
ImportError: cannot import name smbserver
I am not familiar with python programming and I was hoping someone could help me fix this issue.
Looks like you have an old impacket version installed and you are using a newer version of smbrelayx.py.
First of it'd be great to know what version you have. You can easily do that by typing inside a Python interpreter the following:
from impacket import version
print version.BANNER
Assuming you have an old version, first of all it'd be great to remove the existing version. Depending on your Unix distro it might be just as easy as to remove the python-impacket package, or you can manually remove the library files by getting to know where those files are located:
import impacket
print impacket.__file__
That will give you the path where the library is installed. I'd suggest to remove the entire directory.
Now that your system is clean, you have two options:
Install a stable version: Grab the latest stable version from here. Uncompress it in a temp directory and then run:
python setup.py install
That will install the libraries and example scripts (e.g. smbrelayx.py)
Install the development version: You will need to git clone the development version first by running:
git clone https://github.com/CoreSecurity/impacket
Once the repo is cloned, inside the impacket directory type:
python setup.py install
That will install the libraries and example scripts (e.g. smbrelayx.py)