Location Research Breakthrough Possible @S-Logix pro@slogix.in

Exposing QR-Code Phishing Attacks Through ZBar-Based QR Scanning Using Convolutional Neural Network Threat Classification

Description

QR codes are widely used to provide quick access to websites, authentication pages, payment services, application resources, documents, and other online destinations. Because the actual destination is encoded inside the QR image, a user may not know where the QR code will lead before it is scanned and decoded.

QR-code phishing, commonly referred to as quishing, abuses this characteristic by embedding a deceptive or malicious destination inside a QR code. An attacker can distribute such QR codes through documents, images, posters, messages, or other delivery channels. When the QR code is scanned, the user may be redirected to a phishing resource that attempts to obtain sensitive information.

In this use case, a controlled QR-code phishing detection environment is implemented using a ZBar-based QR scanning workflow. A public QR-code security dataset is used to train and validate a Convolutional Neural Network (CNN) for QR-code threat classification.

The controlled attack is performed only inside an isolated Ubuntu and Kali Linux laboratory environment. A laboratory-only phishing destination is encoded into a QR code and introduced into the scanning workflow. ZBar is used to decode the QR payload, while the CNN provides the AI-based threat classification.

The complete implementation follows:

Public QR-Code Security Dataset → QR Image Preprocessing → CNN Model Training → CNN Validation → Controlled Phishing Destination → Phishing QR Code Generation → QR Code Introduction → ZBar Decoding → CNN Threat Classification → Security Decision → Suspicious QR Code Identification

Existing Security Problem

Application : ZBar-Based QR Scanning Environment

ZBar provides QR-code and barcode decoding functionality and can identify information encoded inside a QR image, such as a URL or text payload.

However, QR decoding and QR security classification are separate functions. A QR scanner may successfully decode a QR code without determining whether the destination represented by the QR code is legitimate or associated with phishing activity.

Existing Problem :

A malicious QR code can visually appear similar to a legitimate QR code. A user may therefore scan the QR code without knowing that the encoded destination is deceptive.

In a conventional QR-scanning workflow, the primary operation is decoding the information contained inside the QR image.

The security problem is:
Malicious Destination Prepared
→
Destination Embedded into QR Code
→
QR Code Distributed
→
QR Code Scanned
→
ZBar Decodes Embedded Content
→
Malicious Destination Becomes Available
→
Destination May Appear Legitimate
→
User May Access Phishing Resource
→
Credential or Sensitive Information Exposure Risk

The proposed solution introduces an AI-based QR-code threat-classification layer into the QR-scanning workflow. The CNN is trained using a public QR-code security dataset and is used to classify submitted QR-code samples. ZBar provides the QR-decoding capability required to expose the embedded destination for additional security validation.

Attack

Specific Attack : QR-Code Phishing Attack

The controlled QR-code phishing attack introduces a QR code containing a laboratory-only phishing destination into the isolated security-testing environment.

The attack does not target a real user, production application, or external phishing infrastructure. Instead, a controlled phishing-style destination is created inside the laboratory and encoded into a QR code.

The generated QR code is then introduced into the QR-scanning workflow. The submitted QR image is analyzed by the trained CNN, while ZBar decodes the information encoded inside the QR code.

Attack Behavior :
Controlled Phishing Destination Created
→
Destination Embedded into QR Code
→
Phishing QR Code Generated
→
Phishing QR Code Introduced into Laboratory
→
QR Image Submitted to Scanner
→
QR Image Preprocessed
→
CNN Performs Threat Classification
→
ZBar Decodes QR Payload
→
Classification and Payload Results Correlated
→
Suspicious QR Code Identified

Security Concept

AI-Assisted QR-Code Threat Classification and Pre-Access Validation

The security concept introduces an AI-based classification layer into the QR-scanning process so that QR-code security characteristics can be evaluated before the decoded destination is treated as trusted within the controlled environment.

The CNN learns classification patterns from the public QR-code security dataset. During detection, a submitted QR-code image is processed using the same preprocessing pipeline used during model training.

ZBar performs the complementary QR-decoding function and exposes the information encoded inside the QR code.

The assessment follows:
QR Code Input
→
QR Image Preprocessing
→
CNN Feature Extraction
→
CNN Threat Classification
→
ZBar QR Payload Decoding
→
Decoded Destination Identification
→
Classification and Payload Correlation
→
Security Decision
→
Suspicious QR Code Flagging

Defensive Mechanism

The security concept defines the overall security strategy.

The following are the specific defensive mechanisms implemented.

QR-Code Threat Classification :

The submitted QR-code image is processed using the trained CNN model. The model extracts learned image characteristics and produces the security classification associated with the QR-code sample.

Purpose: To automatically classify QR-code samples according to the security categories learned during model training.

QR Payload Inspection

ZBar decodes the information embedded inside the submitted QR code and exposes the encoded content for further security analysis.

Purpose
  • To identify the actual information or destination hidden inside the QR code.

Pre-Access Security Validation

The QR classification result and decoded payload are evaluated before the destination is treated as trusted within the controlled environment.

Purpose
  • To prevent suspicious QR-code content from being accepted without security validation.

Suspicious QR-Code Flagging

QR codes that receive a suspicious classification are flagged for security review instead of being treated as trusted input.

Purpose
  • To provide an actionable security decision when a potential QR-code phishing attempt is detected.

Controlled Destination Isolation

The phishing destination used during the attack simulation remains inside the isolated laboratory.

Purpose
  • To safely reproduce the QR-code phishing scenario without targeting real users, external systems, or production services.

Security Tools

Primary QR Decoding Tool: Zbar

ZBar is used to scan and decode QR-code images submitted to the security-testing workflow.

Purpose
  • Decode the QR code and extract its embedded content.
  • Identify the URL or payload represented by the QR code.
  • Provide decoded information for subsequent security validation.

AI Framework: PyTorch

PyTorch is used to implement and train the Convolutional Neural Network.

Purpose
  • Build the CNN architecture used for QR-code classification.
  • Train the CNN using the public QR-code security dataset.
  • Generate classifications for previously unseen QR-code samples.

Image Processing Tool: OpenCV

OpenCV is used to process QR-code images before they are provided to the CNN.

Purpose
  • Read and validate QR-code image files.
  • Resize and normalize images according to the model input requirements.
  • Convert image data into a consistent representation for CNN processing.

Programming and Automation Tool: Python

Python provides the main implementation environment for the QR-code detection workflow.

Purpose
  • Integrate dataset processing, image preprocessing, CNN inference, and QR decoding.
  • Automate the detection and validation workflow.
  • Record and analyze classification results.

Data Processing Tool: Pandas

Pandas is used to organize dataset metadata and model-evaluation information.

Purpose
  • Load and organize QR-code dataset records.
  • Manage classification labels and metadata.
  • Analyze model predictions and validation results

Numerical Processing Tool: NumPy

NumPy is used for numerical operations required during image and model-data preparation.

Purpose
  • Represent QR-code images as numerical arrays.
  • Perform numerical preprocessing operations.
  • Prepare image data for CNN input.

Machine-Learning Utility: Scikit-learn

Scikit-learn is used for dataset preparation and model-performance evaluation.

Purpose
  • Split available labelled data into training and validation portions.
  • Generate classification evaluation metrics.
  • Analyze prediction performance using the known labels.

Attack Simulation Environment: Kali Linux

Kali Linux is used as the controlled security-testing environment.

Purpose
  • Prepare controlled phishing-test inputs.
  • Generate and introduce the laboratory phishing QR-code scenario.
  • Validate the detection workflow from an attacker-simulation perspective.

Detection Environment: Ubuntu Linux

Ubuntu Linux is used as the AI and QR-analysis environment.

Purpose
  • Execute the CNN-based detection workflow.
  • Run the ZBar-based QR decoding process.
  • Perform security classification and result analysis.

Virtualization Platform: VirtualBox

VirtualBox provides the isolated virtual-machine environment required for the laboratory.

Purpose
  • Maintain separate Ubuntu and Kali Linux environments.
  • Isolate attack simulation from the host environment.
  • Support repeatable controlled security testing.

Process

STEP 01

Prepare the Virtualized Security Environment

  • Create the cybersecurity laboratory using VirtualBox.
  • Configure an Ubuntu virtual machine for the AI-based QR-code analysis environment
  • Configure a Kali Linux virtual machine for controlled attack simulation and security testing.
  • Configure the required network connectivity between the virtual machines.
  • Verify that the two virtual environments can communicate only through the intended laboratory network.
  • Confirm that the testing environment is isolated from production systems and real users.
Tools: VirtualBox + Ubuntu + Kali Linux
STEP 02

Prepare the ZBar-Based QR Scanning Environment

  • Install and configure the ZBar-based QR scanning capability inside the Ubuntu analysis environment.
  • Prepare a dedicated directory for incoming QR-code test images.
  • Test ZBar using a known benign QR-code sample.
  • Confirm that ZBar can successfully identify the QR code.
  • Verify that the decoded content is displayed correctly.
  • Record the decoded result as baseline evidence for later testing.
Tools: ZBar + Ubuntu + Python
STEP 03

Prepare the Public QR-Code Security Dataset

  • Obtain the public QR-code security dataset required for CNN training.
  • Store the dataset inside the isolated analysis environment
  • Organize the QR-code image files according to their available security labels
  • Verify that the dataset contains usable image samples
  • Review the class distribution before beginning model training
  • Maintain the original labels so that model predictions can later be compared with known ground truth.
Tools: Python + Pandas + Ubuntu
STEP 04

Inspect and Clean the Dataset

  • Load the dataset metadata into Python.
  • Identify missing or invalid image references.
  • Check whether QR-code images can be successfully opened.
  • Identify corrupted or unreadable samples.
  • Check the relationship between each QR image and its assigned security label.
  • Remove or isolate unsuitable samples so that invalid data does not affect model training.
  • Record the final usable sample count for the training workflow.
Tools: Python + Pandas + OpenCV + NumPy
STEP 05

Preprocess the QR-Code Images

  • Read each usable QR-code image using OpenCV.
  • Convert the images into the format required by the CNN.
  • Resize the images to a consistent input dimension.
  • Normalize the numerical image values.
  • Convert the processed images into arrays suitable for model processing
  • Verify that all processed images have consistent dimensions
  • Ensure that the preprocessing operation used for training can also be reused during later detection.
Tools: OpenCV + NumPy + Python
STEP 06

Prepare Training and Validation Data

  • Separate the processed QR-code samples into training and validation portions.
  • Maintain the security labels during the split.
  • Ensure that the validation samples are not directly used for model training.
  • Maintain representative samples for each available classification category.
  • Record the training and validation data distributions.
  • Prepare the resulting data structures for PyTorch model input.
Tools: Python + Pandas + Scikit-learn + NumPy
STEP 07

Build the Convolutional Neural Network

  • Implement the CNN architecture using PyTorch.
  • Configure convolutional layers for extracting image characteristics.
  • Configure pooling operations to reduce unnecessary spatial information while retaining relevant patterns.
  • Configure the classification layers according to the security classes represented by the dataset.
  • Define the training loss function and optimization process.
  • Verify that a sample QR-code image can pass through the model without dimensional errors.
Tools: PyTorch + Python + NumPy
STEP 08

Train the CNN Model

  • Provide the prepared training QR-code images to the CNN.
  • Provide the corresponding security labels during training.
  • Run multiple training iterations so that the model can learn the patterns represented in the training data.
  • Monitor training loss and classification performance.
  • Record the model performance after each training stage.
  • Save the trained model for subsequent validation and detection.
Tools: PyTorch + Python
STEP 09

Validate the Trained CNN Model

  • Load the trained CNN model.
  • Provide previously unseen validation QR-code images to the model.
  • Generate predictions for the validation samples.
  • Compare each prediction with its known security label.
  • Calculate accuracy, precision, recall, and F1-score where appropriate.
  • Review incorrect predictions to identify potential classification limitations.
  • Store the validation results for later comparison with controlled attack results.
Tools: PyTorch + Scikit-learn + Pandas + Python
STEP 10

Prepare the Controlled Phishing Destination

  • Create a phishing-style destination only inside the isolated laboratory.
  • The destination is designed to reproduce the behavior required for the QR-code phishing test.
  • Do not connect the laboratory destination to real credential-collection infrastructure.
  • Ensure that the test destination remains accessible only within the controlled environment.
  • Verify that accessing the destination does not affect real users or external systems.
  • Record the laboratory destination as the known attack ground truth.
Tools: Ubuntu + Kali Linux + Python
STEP 11

Generate the Controlled Phishing QR Code

  • Encode the controlled laboratory destination into a QR code.
  • Generate the resulting QR image using the laboratory environment.
  • Store the QR image in the designated attack-testing directory.
  • Prepare a benign QR-code sample for comparison.
  • Verify that the generated phishing QR code can be successfully decoded by Zbar.
  • Do not expose the generated phishing QR code to real users or external services.
Tools: Kali Linux + Python + Zbar
STEP 12

Introduce the QR-Code into the Security Testing Environment

  • Transfer the controlled phishing QR image into the Ubuntu QR-analysis environment.
  • Submit the QR image through the same workflow used for benign QR-code samples.
  • Maintain the original image as attack evidence.
  • Repeat the process with benign QR-code samples.
  • Ensure that the same preprocessing and classification workflow is applied to both conditions.
  • Record the time and result associated with each submitted QR-code sample.
Tools: Kali Linux + Ubuntu + VirtualBox
STEP 13

Preprocess the Submitted QR Image

  • Load the submitted QR image using the same OpenCV preprocessing pipeline used during training.
  • Verify that the image can be read successfully.
  • Resize the image to the model's expected input dimension.
  • Normalize the image values.
  • Convert the processed image into the numerical representation required by PyTorch.
  • Verify that the final tensor dimensions match the trained CNN input requirements.
  • Pass the prepared input to the detection stage.
Tools: OpenCV + NumPy + Python + PyTorch
STEP 14

Perform CNN-Based Threat Classification

  • Load the trained CNN model.
  • Provide the preprocessed QR image to the model.
  • Generate the model prediction for the submitted QR code.
  • Record the predicted security category.
  • Record the model confidence or class probability where supported.
  • Compare the prediction with the known condition of the laboratory test.
  • Store the result as part of the security evidence.
Tools: PyTorch + Python + NumPy
STEP 15

Decode the QR Payload Using Zbar

  • Submit the same QR image to Zbar.
  • Allow ZBar to identify and decode the QR code.
  • Extract the encoded URL or payload.
  • Verify that the decoded content corresponds to the destination embedded during QR generation.
  • Record the decoded destination as security evidence.
  • Compare the decoded result against the known laboratory phishing destination.
Tools: ZBar + Python + Ubuntu
STEP 16

Correlate CNN Classification and QR Payload

  • Collect the CNN classification result.
  • Collect the ZBar decoded payload.
  • Associate both results with the same QR-code test sample.
  • Compare the CNN classification with the known attack condition.
  • Determine whether the decoded destination corresponds to the controlled phishing destination.
  • Apply the predefined security decision logic.
  • Flag the QR code for security review when the implemented conditions identify suspicious activity.
  • Record the complete classification and decoding evidence.
Tools: Python + PyTorch + ZBar + Pandas
STEP 17

Validate the Controlled QR-Code Phishing Detection

  • Repeat the complete workflow using multiple benign QR-code samples.
  • Repeat the workflow using multiple controlled phishing QR-code samples.
  • Record CNN predictions for each sample.
  • Record ZBar decoding results for each sample.
  • Compare every prediction against the known ground truth.
  • Calculate detection accuracy and relevant classification metrics.
  • Identify false-positive and false-negative results.
  • Investigate incorrect classifications and determine whether additional training or preprocessing is required.
  • Verify that the detection workflow does not incorrectly treat all QR codes as malicious.
Tools: Python + Pandas + Scikit-learn + PyTorch + ZBar
STEP 18

Record and Analyze the Final Security Outcome

  • Collect the final CNN classification results.
  • Collect the corresponding ZBar decoded payloads.
  • Document the controlled attack condition for each test.
  • Compare the observed results against the known laboratory ground truth.
  • Record correctly detected phishing QR codes.
  • Record incorrectly classified benign and phishing QR codes.
  • Calculate the final evaluation metrics.
  • Document the effectiveness and limitations of the implemented detection workflow.
  • Verify that the complete attack simulation, QR decoding, AI classification, and security-validation process can be repeated consistently.
Tools: Python + Pandas + PyTorch + ZBar + Scikit-learn

Outcome

The QR-code phishing attack is successfully reproduced inside an isolated Ubuntu and Kali Linux security-testing environment without targeting real users or external production systems.

A public QR-code security dataset is processed and used to train and validate the Convolutional Neural Network for QR-code threat classification.

The CNN learns classification patterns from the available labelled QR-code image data and produces security predictions for previously unseen QR-code samples.

The ZBar-based QR-scanning workflow successfully decodes the information embedded inside the submitted QR-code samples.

The controlled phishing destination is successfully embedded into a QR code and introduced into the laboratory detection workflow as a known attack condition.

The CNN classification and ZBar payload-decoding results provide complementary security information for evaluating the submitted QR code.

The implemented workflow can classify tested QR-code samples and compare the resulting predictions against the known laboratory ground truth.

Repeated testing with benign and controlled phishing QR-code samples provides measurable evidence for accuracy, false-positive, and false-negative analysis.

The implementation demonstrates how an AI-based threat-classification layer can be integrated with an existing QR-decoding workflow to provide additional security validation.

The final result is a repeatable laboratory-based QR-code phishing detection workflow that can be further evaluated, optimized, and integrated into a broader QR-code security solution.