如何在kali linux中安装英伟达内核模块cuda和pyrit

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在kali linux中安装英伟达内核模块cuda和pyrit相关的知识,希望对你有一定的参考价值。

参考技术A 安装cuda以及nvidia驱动
这一步比较简单,安装之前,推荐大家编辑一下/etc/apt/source.list文件,把国外的源注释掉换成国内科大的,下载比较快。科大源的地址如下
deb http://mirrors.ustc.edu.cn/kali kali main non-free contrib
deb-src http://mirrors.ustc.edu.cn/kali kali main non-free contrib
deb http://mirrors.ustc.edu.cn/kali-security kali/updates main contrib non-free
设置完之后,执行以下命令安装
apt-get update

apt-get install nvidia-detect nvidia-libopencl1 nvidia-opencl-common nvidia-support nvidia-opencl-icd nvidia-visual-profiler nvidia-glx nvidia-installer-cleanup nvidia-kernel-common nvidia-smi nvidia-alternative nvidia-opencl-dev libglx-nvidia-alternatives nvidia-kernel-dkms nvidia-cuda-toolkit nvidia-vdpau-driver nvidia-xconfig glx-alternative-nvidia libgl1-nvidia-alternatives nvidia-settings libgl1-nvidia-glx xserver-xorg-video-nvidia libcublas4 libcudart4 libcufft4 libnpp4 libnvidia-compiler libcuda1 libcuinj4 libnvidia-ml1 libxvmcnvidia1 libcusparse4 libcurand4 python-pycuda-doc python-pycuda-headers python-pycuda nvidia-cuda-doc nvidia-cuda-gdb
由于包比较多可能有点慢,安装过程会弹出两个窗口需要确认,直接OK就好,执行完之后toolkit和驱动都装上了,然后把一些变量写入系统,在/root/.bashrc最后面加上下面一段
PATH=$PATH:/usr/lib/nvidia-cuda-toolkit/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nvidia-cuda-toolkit/lib:/lib
export PATH
export LD_LIBRARY_PATH
可以执行一下ldconfig马上生效,不过反正都要重启一次的了,重启。
安装pyrit-cuda
下面重新编译个pyrit来试一试使用GPU。下载pyrit的地址是:
https://code.google.com/p/pyrit/downloads/list
我们需要下载pyrit-0.4.0.tar.gz和cpyrit-cuda-0.4.0.tar.gz,下载完之后,安装一下编译所需要的工具
atp-get install libpcap-dev python2.7-dev
解压pyrit-0.4.0.tar.gz并且安装
tar -xzvf pyrit-0.4.0.tar.gz
cd pyrit-0.4.0
python setup.py build
python setup.py install
解压cpyrit-cuda-0.4.0.tar.gz
tar -xzvf cpyrit-cuda-0.4.0.tar.gz
cd cpyrit-cuda-0.4.0
这里需要进行一些改动,编辑setup.py,把第35行
for path in ('/usr/local/cuda', '/opt/cuda'):
改成
for path in ('/usr/local/cuda','/usr/lib/nvidia-cuda-toolkit','/opt/cuda'):
免得安装程序找不到nvcc
然后就安装
python setup.py build
python setup.py install
安装完,运行一下
pyrit list_cores
应该能看到GPU了,类似
#1: 'CUDA-Device #1 'GeForce 8400 GS''
#2: 'CPU-Core (SSE2)'
#3: 'CPU-Core (SSE2)'
#4: 'CPU-Core (SSE2)'
#5: 'CPU-Core (SSE2)'
#6: 'CPU-Core (SSE2)'
#7: 'CPU-Core (SSE2)'
#8: 'CPU-Core (SSE2)'
安装optimus
把源Key取回来
wget -O - http://suwako.nomanga.net/suwako.asc | apt-key add -
在/etc/apt/source.list中加入Bumblebee的源
deb http://suwako.nomanga.net/debian sid main contrib
deb-src http://suwako.nomanga.net/debian sid main
然后执行安装
apt-get update
apt-get install bumblebee bumblebee-nvidia
安装完毕,把root加入bemblebe组,然后重启
adduser root bumblebee
重启完毕可以测试一下,分别运行
glxspheres
optirun glxspheres
可以看到帧数是不同的本回答被提问者采纳

在linux系统中安装LANMP

1.安装LANMP步骤

root@kali:~# wget http://dl.wdlinux.cn/files/lanmp_v3.tar.gz #下载

root@kali:~# tar xzvf lanmp_v3.tar.gz  #解压

root@kali:~# sh lanmp.sh  #运行报错,原因:系统的dash兼容性不好,而编译常用的就是dash
lanmp.sh: 49: lib/common.conf: function: not found
lanmp.sh: 76: lib/common.conf: Syntax error: "}" unexpected

root@kali:~# sudo dpkg-reconfigure dash  #解决方法:运行此命令,选择NO

root@kali:~# sh lanmp.sh  #重新运行LANMP,成功
  grep: /etc/redhat-release: 没有那个文件或目录
  grep: /etc/redhat-release: 没有那个文件或目录
  Select Install
        1 LAMP (apache + php + mysql + zend + pureftpd + phpmyadmin)
        2 LNMP (nginx + php + mysql + zend + pureftpd + phpmyadmin)
        3 LNAMP (nginx + apache + php + mysql + zend + pureftpd + phpmyadmin)
        4 install all service
        5 dont install is now

  Please Input 1,2,3,4,5: #此时选择要安装的环境即可,这里我选择1

2.sh lanmp.sh安装服务时遇到的各种报错

<1>报错:cmake:未找到命令

问题:
root@kali:~# sh lanmp.sh 
...
lib/mysql.sh:行13: cmake:未找到命令

x86_64
----Install Error: mysql configure err -----------

解决方法:
root@kali:~# wget https://github.com/Kitware/CMake/releases/download/v3.13.2/cmake-3.13.2.tar.gz #下载
root@kali:~# tar xzvf cmake-3.13.2.tar.gz -C software/cmake/  #解压到指定目录
root@kali:~/software/cmake/cmake-3.13.2# ./bootstrap && make && make install #安装
root@kali:~# cmake -version  #查看版本信息
cmake version 3.13.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).

<2>报错:./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function); did you mean ‘fgets’?

root@kali:~# sh lanmp.sh 
...
make[3]: 对“am--refresh”无需做任何事。
make[3]: 离开目录“/root/src/libiconv-1.14”
gcc -DHAVE_CONFIG_H -DEXEEXT="" -I. -I.. -I../lib  -I../intl -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1   -g -O2 -c progname.c
In file included from progname.c:26:
./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function); did you mean ‘fgets’?
 1010 | _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
      | ^~~~~~~~~~~~~~~
make[2]: *** [Makefile:914:progname.o] 错误 1
make[2]: 离开目录“/root/src/libiconv-1.14/srclib”
make[1]: *** [Makefile:865:all] 错误 2
make[1]: 离开目录“/root/src/libiconv-1.14/srclib”
make: *** [Makefile:35:all] 错误 2

x86_64
----Install Error: libiconv make err -----------


解决方法:
root@kali:~# vi /root/src/libiconv-1.14/srclib/stdio.in.h
找到以下这一行
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
使用/* */注释掉

然后再注释的行下面添加以下三行:
#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif
保存退出!(注意#endif 下面还有一个 #endif)

root@kali:~# cd src/
root@kali:~/src# rm -rf libiconv-1.14.tar.gz  #删除原来的压缩包
root@kali:~/src# tar czvf  libiconv-1.14.tar.gz libiconv-1.14/ #重新打包
注意:删除原来的压缩包并重新打包是关键,因为sh lanmp.sh 会自动解压缩并编译libiconv-1.14.tar.gz文件,
如果你仅仅修改了libiconv-1.14/srclib/目录中的stdio.in.h文件,
在sh lanmp.sh运行时它会自动解压缩原来的压缩包并覆盖你刚才修改了文件的目录,此时你的修改就完全没有意义了

参考:https://blog.csdn.net/hanghang121/article/details/79481771

<3>报错:configure: error: xml2-config not found. Please check your libxml2 installation.

root@kali:~# sh lanmp.sh 
...
checking libxml2 install dir... /usr
checking for xml2-config path... 
configure: error: xml2-config not found. Please check your libxml2 installation.

x86_64
----Install Error: php configure err -----------

解决方法:
root@kali:~# apt install libxml2 
root@kali:~# apt install libxml2-dev 

<4>报错:configure: error: Please reinstall the libcurl distribution -easy.h should be in <curl-dir>/include/curl/

root@kali:~# sh lanmp.sh 
...
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
    easy.h should be in <curl-dir>/include/curl/

x86_64
----Install Error: php configure err -----------

解决方法:
root@kali:~# apt-get install curl
root@kali:~# apt-get install libcurl4-gnutls-dev
root@kali:~# apt-get install php-curl
注意:我装了这3个都没用。。。。。。

没成功。。。

以上是关于如何在kali linux中安装英伟达内核模块cuda和pyrit的主要内容,如果未能解决你的问题,请参考以下文章

被 Linux 之父骂遭黑客威胁,英伟达终于“想开”了:正式开源 Linux GPU 内核模块

英伟达开源其Linux GPU内核驱动,苹果市值一夜蒸发8710亿失掉榜首,祝融号发现火星水活动迹象,今日更多大新闻在此...

如何在VMware中安装kali linux

怎么在VMware中安装kali

如何在VMware虚拟机中安装kali系统

VMware中安装Linux-kali