This tutorial is a mash-up derived from several blogs and presentations:
- LinuxBabe’s 2 Ways to Install Nvidia Drivers on Ubuntu 18.04
- Changjiang’s Blog re: Nvidia GTX 1080 on Ubuntu 16.04 for Deep Learning
- Install NVIDIA GPU Drivers on Kali Linux
- Infosec Institute’s Hashcat Tutorial for Beginners
You can follow along in my YouTube screencast above or proceed below with my in-depth documentation- enjoy!
Ubuntu
Download Ubuntu 18.04 and Burn ISO
- Go to Ubuntu Desktop download page and download Ubuntu 18.04.
- After downloading the ISO file, burn the image on to a disk with unetbootin tool (Mac users) or the Rufus tool(Windows) on to a USB thumb-drive.
- Insert thumb-drive into mining-rig | super-computer.
Install Ubuntu on Mining Rig
- After turning on the mining-rig, immediately hit the F2-key.
- Click on the boot-menu.
- Make sure the sandisk device containing the Ubuntu 18.04 iso file is selected.
- Save and Exit
Updating Ubuntu
- Hit the Option-key or Windows key on keyboard and type in “Software Updater” within the Ubuntu-OS search-field and then hit enter; that should prompt the Ubuntu-updater- upon completion, select the “Install Now” button and then enter system-password.
- After running the Ubuntu-updater, restart the system.
- For the sake of thoroughness, update Ubuntu 18.04 from the command-line by running the following commands in sequence.
sudo apt-get update
# Fetches the list of available updatessudo apt-get upgrade
# Strictly upgrades the current packagessudo apt-get dist-upgrade
sudo reboot
- After running the above commands, restart Ubuntu or simply type
sudo reboot
from the command-line.
Ubuntu Preparation for SSH (Optional)
- Download net-tools by running
sudo apt install net-tools
- Run
ifconfig -a
orip addr show
to identify the host-IP address or name to access via SSH. - Prepare Ubuntu-environment for SSH
sudo apt-get install openssh-server
sudo ufw allow 22
sudo reboot
- Download nMap (optional).
- Run
nmap -sn your-device-ip-address
to ping Ubuntu instance; it should return the name of the Ubuntu-host or computer name in additon to the IP-address within the terminal output.
- e.g.
nmap -sn 10.3.1.233
- Run
ssh -v username@your-device-ip-address
orssh -v username@computer-name
- e.g.
ssh -v alexanderjsingleton@10.3.1.233
orssh -v alexanderjsingleton@alexanderjsingleton-ubuntu
How to Install Nvidia GeForce GTX 1080 Graphics Drivers
Updating GPU Drivers from Graphical User Interface (GUI)
- Hit the Activities icon within the bottom left corner of the screen and click-on “Settings” OR hit the Option-key and search for “Settings”.
- Next click on “Details” within the “Settings” window.
- Since we haven’t loaded any drivers yet, Ubuntu 18.04 pre-loaded the instnace with whatever your on-board CPU carried (e.g., on my rig, within the Settings > Details, the “Graphics” field displays “Intel HD Graphics 630 (Kaby Lake GT2)”.
- After verifying the aforementioned, go back to the Activites-page within the lower left-corner of the desktop and select “Software & Updates” or hit Option-key and search for “Software & Updates”.
- Within the Software & Updates window, click on the “Additional Drivers” tab.
- After a few moments, Ubuntu will return a suggested driver to download- by default it will select the second option radio-button parenthetically described as (open source) but you want the radio-button option parenthetically described as “proprietary, tested” (e.g. in my case it was “Using NVIDIA driver metapackage from nvidia-driver-390 (proprietary, tested).
- After selecting the previously mentioned radio-button option, select “Apply Changes” and then reboot the computer.
- After rebooting the computer, go back to Settings > Details- verify that the new drivers were installed by checking Graphics description field (it should say (nvidia-driver-390).
- Go back to the Activites-icon page within the lower left-corner of the desktop and select “Nvidia X Server Settings” from the application menu; click on the “Prime Profiles” tab on the left-pane, and then select Intel card on the right-pane.
- Select the NVIDIA (Performance Mode) radio-button and then close the window.
- Proceed to ‘Installing Hashchat’ Section.
Updating GPU Drivers from the Command-Line (Recommended)
- Access the Terminal.
- Run
sudo lshw -c display
ORsudo lshw -c video
to display the Ubuntu 18.04 stock-drivers loaded for the Nvidia GeForce GTX 1080 GPU cards. - Since we haven’t installed any drivers from the command-line yet, the driver-detail within the configuration field should display “driver=nouveau”.
- Run
sudo ubuntu-drivers devices
- After running the above command, only two drivers will be displayed (e.g. ‘nvidia-driver-390 – distro non-free recommended’ and ‘xserver-xorg-video-nouveau – distro free builtin’); we want the latter ‘non-free recommended’- so run
sudo apt install nvidia-driver-version-number
(e.g.sudo apt install nvidia-driver-390
). - After installing the drivers from the command-line, reboot the computer by running
sudo shutdown -r now
. - If after rebooting your welcome-screen hangs, click on the settings-wheel icon, select the “Ubuntu on wayland” and then re-enter password.
- Access the terminal and run
sudo lshw -c display
; the driver field should now display “nvidia” instead of “nouveau”.
Installing the Nvidia CUDA Toolkit 10.0
Installing the Nvidia CUDA Toolkit 10.0 for Ubuntu 18.04 – Option A (Recommended)
sudo apt update && apt dist-upgrade -y && reboot
lspci -v
sudo apt install -y ocl-icd-libopencl1 nvidia-driver nvidia-cuda-toolkit
.
- e.g.
sudo apt install -y ocl-icd-libopencl1 nvidia-driver-390 nvidia-cuda-toolkit
nvidia-smi
sudo reboot
- Access terminal and enter the following commands in sequence:
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install mesa-common-dev
sudo apt-get install freeglut3-dev
- Reboot the computer by running
sudo reboot
Installing the Nvidia CUDA Toolkit 10.0 for Ubuntu 18.04 – Option B
- Go to Nvidia CUDA Toolkit 10.0 for Ubuntu 18.04.
- Select the following Select Target Platform Window: Linux > X86_64 > Ubuntu > 18.04 > runfile (local)
- To check your OS architecture run
uname -a
it should return “x_86_64” within the terminal display.
- Download the Base Installer (2.0 GB) by click on the Download button.
- Access Terminal and close X Server to avoid errors while updating nVidia driver by running
sudo init 3
; a black-screen will appear and prompt you to enter your Ubuntu username and password- please enter. - After logging-in, run
cd ~/Downloads
. - Run
sudo sh cuda_10.0.130_410.48_linux.run
- Scroll down to accept the conditions by holding down the “Return” key or space-bar- upon scrolling to the bottom, type:
accept
; alternatively, you can hit ‘CTRL + D’ to bypass scrolling. - Install the CUDA 10.0 Toolkit by enter
y
- Do you want to Install the OpenGL Libraries
y
- Do you want to run nvidia-xconfig? Enter
y
- Install the CUDA Toolkit? Enter
y
- Unless otherwise preferred, hit the “Return” key to enter the specified default absolute-path (e.g.
/usr/local/cuda-10.0
). - Enter
y
to install a symbolic link at/usr/local/cuda
. - Enter
y
to Install the CUDA 10.0 Samples - Hit the “Return” key to enter CUDA Samples default location-path (e.g.
/home/alexanderjsingleton
). - After the install, open the X Server by running
sudo init 5
; if for whatever reason you’re unable to reboot the computer after installing the CUDA 10.0 Toolkit, turn-off the computer and reboot- remember to click on the Settings icon and select “Ubuntu on wayland” before entering the username and password. - Access terminal and enter the following commands in sequence:
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install mesa-common-dev
sudo apt-get install freeglut3-dev
- Reboot the computer by running
sudo shutdown -r now
Installing OpenCL™ Runtimes for Intel® Processors
Installing OpenCL™ Runtimes for Intel® Processors – Option A (Recommended)
- Check your CPU system processor architecture by running
sudo lscpu
to identify the class of CPU e.g. “Intel (R) Core (TM) i7-7700 CPU @ 3.60Ghz”- alternatively, you can go to Settings > Details which will also reveal the CPU-family (e.g. Intel (R) HD Graphics 630 (Kaby Lake GT2)). - Go to the Intel Developer Zone and scroll down to the corresponding download link for your system; assuming you’re running Ubuntu 18.04 and have a Intel Core-class CPU, scroll down to “Linux* OS Ubuntu* 16.04.x (deb)” and click on the Github link for 18.46.11837 Runtimes to access the runtime-packages to download.
- There should be instructions within the aforementioned Github repo- or you can proceed with the following in the next steps.
cd ~/Desktop
mkdir neo
cd neo
sudo wget https://github.com/intel/compute-runtime/releases/download/18.46.11837/intel-gmmlib_18.4.0.348_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/18.46.11837/intel-igc-core_18.44.1060_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/18.46.11837/intel-igc-opencl_18.44.1060_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/18.46.11837/intel-opencl_18.46.11837_amd64.deb
- Install the packages by running
sudo dpkg -i *.deb
. - Restart the system by running
sudo reboot
.
Installing OpenCL™ Runtimes for Intel® Processors – Option B
- Go to Intel OpenCL Runtimes website and scroll down to the bottom of the page to Download Intel CPU Runtime for OpenCL Applications 18.1 for LINUX OS (64-bit only).
- After downloading the OpenCL Runtimes for Intel Processors,
cd ~/Downloads
- Run
sudo tar -xzf l_opencl_p_18.1.0.013.tgz
to unpack the tgz file- please note, the OpenCL file version may update since the time as of this gist (ie as of this gist, the version is 18.1.0.013.) cd l_opencl_p_18.1.0.013
- Run
sudo ./install.sh
- A welcome screen is prompted- hold-down the “Enter” key until able to input select “2” for “I do NOT consent to the collection of my Information”
- Hit “1”
- Hit “1”
- Hit “Enter” and then restart the computer.
- If any additional Intel OpenCL errors are encountered after testing hashcat, go to section ‘Installing OpenCL™ Runtimes for Intel® Processors – B’- if not, proceed with section “Testing Hashcat”
Hashcat
Downloading Hashcat Binaries – Option A (Recommended)
- Download the latest version of hashcat– scroll down to the bottom and download the version at the top of the table (as of this gist, the latest version is v5.1.0.7- be sure to download the “binaries” version of Ubuntu); use the
wget
command to download the latest version of hashcat from the hashcast website (e.g.wget https://hashcat.net/files/hashcat-5.1.0.7z
– be sure tocd
into the Downloads folder for the sake of consistency). - Access the download-directory:
cd ~/Downloads
- If you haven’t already, download p7zip:
sudo apt install p7zip
- Assuming you’re still in the Downloads folder, run
sudo p7zip -d hashcat-5.1.0.7z
to unzip (if that command didn’t work, simply right-click and extract file within the Downloads folder). - Access the unzipped hashcat folder by running
cd hashcat-5.1.0.7z
- Next run
ls /usr/bin/ | grep -i hash
- Run
sudo cp hashcat64.bin /usr/bin/
sudo ln -s /usr/bin/hashcat64.bin /usr/bin/hashcat
sudo cp -Rv OpenCL/ /usr/bin/
sudo cp hashcat.hcstat2 /usr/bin/
sudo cp hashcat.hctune /usr/bin/
Downloading Hashcat from Ubuntu Repository – Option B
Alternatively, you may download hashcat from the Ubuntu repository by simply running sudo apt-get install hashcat
; however, this will more than likely download a deprecated version of hashcat.
Testing Hashcat
- Test hashcat, by running
sudo hashcat --benchmark
. - As of this gist, hashcat is reporting that Intel’s OpenCL runtime (GPU only) is currently broken and they are currently waiting for updated OpenCL drivers from Intel; if you encounter that error message try running
sudo hashcat --benchmark --force
that should successfully override any OpenCL issues. - After running
sudo hashcat --benchmark
orsudo hashcat --benchmark --force
the terminal output will report hashrates for given hash-algorithms (eg. ‘MD5 560.4 KH/s’, ‘SHA1 149.4 MH/s’, ‘SHA2-256 72485.9 Mh/s’ etc.) - Hit CTRL + C to stop benchmark testing.
Creating Password Hashes
- Go to the Desktop by running
cd ~/Desktop
- Create a new folder within the desktop (e.g.
mkdir infosexy
). cd infosexy
- Create a new folder within
infosexy
directory for the password dictionary (e.g.mkdir skull
) cd skull
- Go to skullsecurity and download the ‘rockyou.txt’ password dictionary.
- Assuming you downloaded the ‘rockyou.txt’ file go to the ‘Downloads’ folder: (e.g.
cd ~/Downloads
). - Run
bzip2 -d rockyou.txt.bz2
to unpack the file-folder. - Copy the ‘rockyou.txt’ dictionary from the Downloads-folder to the destination skull-folder- easiest way to do this is launch two terminals by opening another terminal-window from Terminal (e.g. CTRL + ALT + T) and then enter
pwd
from both terminal-windows to identify their respective paths. - Copy source-folder file ‘rockyou.txt’ by running the
cp
command between file-paths (e.g.cp /home/alexanderjsingleton/Downloads/rockyou.txt /home/alexanderjsingleton/infosexy/skull
). - Run
ls
to confirm file transfer. - Go back into the infosexy folder (e.g.
cd ..
)
Cracking the MD5 Hash Algorithm
- Within the infosexy directory, run the following commands below in sequence to create password hashes encrypting the passwords with the MD5 hash-algorithm.
echo -n “Password” | md5sum | tr -d ” -” >> target_hashes.txt
echo -n “HELLO” | md5sum | tr -d ” -” >> target_hashes.txt
echo -n “MYSECRET” | md5sum | tr -d ” -” >> target_hashes.txt
echo -n “Test1234″ | md5sum | tr -d ” -” >> target_hashes.txt
echo -n “P455w0rd” | md5sum | tr -d ” -” >> target_hashes.txt
echo -n “GuessMe” | md5sum | tr -d ” -” >> target_hashes.txt
echo -n “S3CuReP455Word” | md5sum | tr -d ” -” >> target_hashes.txt
- Run
cat target_hashes.txt
to display all of the encrypted password with the md5sum algorithm within the Terminal window. - Run
sudo hashcat -m 0 -a 0 -o cracked.txt target_hashes.txt skull/rockyou.txt
- I have 8 * Nvidia Asus GeForce GTX 1080 * 8 GB GPUs on my mining-rig- cracking-time may vary per computer; I cracked this set within less than one second- needless to say that is really fast.
- Run
sudo cat cracked.txt
to reveal the hash key-value-pairs corresponding to the encrypted passwords within the Terminal window.
Cracking the SHA256 Hash Algorithm
- Within the infosexy directory, run the following commands below in sequence to create password hashes encrypting the passwords with the SHA256 hash-algorithm.
echo -n “Password” | sha256sum | tr -d ” -” >> target_hashes-2.txt
echo -n “HELLO” | sha256sum | tr -d ” -” >> target_hashes-2.txt
echo -n “MYSECRET” | sha256sum | tr -d ” -” >> target_hashes-2.txt
echo -n “Test1234″ | sha256sum | tr -d ” -” >> target_hashes-2.txt
echo -n “P455w0rd” | sha256sum | tr -d ” -” >> target_hashes-2.txt
echo -n “GuessMe” | sha256sum | tr -d ” -” >> target_hashes-2.txt
echo -n “S3CuReP455Word” | sha256sum | tr -d ” -” >> target_hashes-2.txt
- Run
cat target_hashes-2.txt
to display all of the encrypted passwords with the SHA256 algorithm within the Terminal window. - Run
sudo hashcat -m 1400 -a 0 -o cracked-2.txt target_hashes-2.txt skull/rockyou.txt
- I have 8 * Nvidia Asus GeForce GTX 1080 * 8 GB GPUs on my mining-rig- cracking-time may vary per computer; I cracked the first hash for “Password” within less than one second- needless to say that is really fast, considering SHA256 is the same encryption-grade protecting the Bitcoin network.
- Run
sudo cat cracked-2.txt
to reveal the hash key-value-pairs corresponding to the encrypted password within the Terminal window.
Congratulations
Congratulations, you can now crack a hash- hope you learned something.
8 comments for “InfoSexy: How to use Hashcat to Crack Passwords in Ubuntu 18.04”