Hacking QR Codes with QRGen to Attack Scanning Devices [Tutorial]

Null Byte
23 Aug 201910:07

Summary

TLDRThis episode of Cyber Weapons Lab explores QR Gen, a tool that encodes exploits into QR codes to test device vulnerabilities. The video demonstrates how QR codes, widely used due to their ease of creation and reading, can pose security risks if the devices scanning them are not regularly updated. The tutorial guides viewers through setting up QR Gen on a Linux system, installing necessary libraries, and generating QR codes with various payloads. It also showcases creating custom wordlists and testing the QR codes on an Android phone to illustrate potential security breaches. The video concludes with a cautionary note on the responsible use of such tools.

Takeaways

  • 📱 QR codes are prevalent due to their ease of creation and compatibility with many devices.
  • 🛠️ Devices that scan QR codes might have vulnerabilities due to infrequent updates.
  • 💻 The tool 'QR Gen' is introduced to encode exploits into QR codes for testing purposes.
  • 🐍 Python is required to use QR Gen, and the setup process is outlined in the script.
  • 🔧 QR Gen is easy to install on Linux systems, with a minor correction needed for the execution script.
  • 📚 It includes a 'requirements.txt' file for necessary libraries, simplifying the setup process.
  • 🔑 QR Gen offers two options for generating QR codes: using a word list or selecting from pre-installed exploit lists.
  • 🔍 The tool can generate QR codes with various payloads, such as command injection, to test device vulnerabilities.
  • 📱 The script demonstrates testing QR codes on an Android phone to see how it interprets the malicious payloads.
  • ⚠️ It's emphasized that testing QR Gen should only be done on non-critical devices with permission to avoid causing harm or disruption.

Q & A

  • What is the main focus of the 'Cyber Weapons Lab' episode described in the transcript?

    -The main focus of the episode is exploring a tool that can encode exploits into QR codes, which when scanned by vulnerable devices, could potentially execute malicious code.

  • Why are QR codes prevalent in various industries such as concerts and grocery stores?

    -QR codes are prevalent because they are easy to create, easy to use, and most people have devices capable of reading them.

  • What vulnerabilities are associated with devices that read QR codes?

    -Devices that read QR codes often have vulnerabilities because they are usually not updated very often, which can lead to exploitation.

  • What tool is used in the episode to generate malicious QR codes?

    -The tool used is called 'QR Gen', which is used to encode various exploit payloads into QR codes.

  • What programming language is required to use QR Gen, and what is the recommended operating system?

    -Python is required to use QR Gen, and the recommended operating system is Linux, specifically Kali Linux.

  • How does the QR Gen tool work, and what kind of payloads can it encode?

    -QR Gen works by encoding a variety of exploit payloads into QR codes, such as cross-site scripting, SQL injections, and command injections.

  • What is the purpose of the 'requirements.txt' file in the QR Gen tool?

    -The 'requirements.txt' file lists all the necessary libraries needed to run the QR Gen tool, and it can be used with pip3 to install these libraries easily.

  • How can users create custom wordlists for QR Gen?

    -Users can create custom wordlists by using a text editor like 'nano' to create a 'wordlist.txt' file and then adding their own payloads to it.

  • What is the significance of the 'tak l' option in QR Gen?

    -The 'tak l' option allows users to select from preinstalled lists of common exploits that could be used against unpatched services or vulnerable systems.

  • What is the potential risk of testing QR Gen on a critical device without permission?

    -Testing QR Gen on a critical device without permission could potentially cause it to malfunction, display erratic behavior, or even be disabled, leading to serious consequences.

  • What precautions are advised when using QR Gen to test for vulnerabilities?

    -It is advised to only test QR Gen on devices where you have permission and to avoid testing on critical devices that are about to be used, to prevent unintended consequences.

Outlines

00:00

📱 Exploring QR Code Vulnerabilities

The script introduces a tool called QR Gen, designed to exploit vulnerabilities in devices that scan QR codes. QR codes are prevalent due to their ease of creation and use, often leading to outdated scanning devices with exploitable weaknesses. The tool encodes popular exploits into QR codes, aiming to execute code when scanned. The setup requires Python and can be easily installed on a Linux system, with a specific mention of Kali Linux. The script highlights a minor issue with the execution script's naming but emphasizes the ease of setup. It also mentions the tool's ability to generate QR codes with various payloads, such as cross-site scripting or SQL injections, and introduces the word list feature for custom payload creation.

05:03

🔍 Testing QR Code Exploits

This paragraph delves into the practical application of the QR Gen tool by generating QR codes with custom and pre-installed exploit payloads. It discusses the process of selecting and generating malicious QR codes, which are then tested on an Android phone to observe the device's reaction. The script illustrates how these QR codes can induce unexpected behavior in devices, such as ticket scanners or supermarket scanners, if they are vulnerable. The demonstration includes reading out the payloads, which can contain malicious commands like accessing unauthorized directories or executing system commands. The script concludes with a cautionary note on the responsible use of such tools, emphasizing the importance of having permission before testing and suggesting the tool's value for penetration testers to discover new vulnerabilities in QR code systems.

Mindmap

Keywords

💡QR codes

QR codes are a type of barcode that can be scanned by smartphones and other devices to quickly access information. In the video, QR codes are highlighted as being ubiquitous, particularly in concert tickets, due to their ease of creation and use. The video explores how these codes can be exploited through hacking tools, emphasizing their widespread adoption and potential vulnerabilities.

💡Vulnerabilities

Vulnerabilities refer to weaknesses in a system that can be exploited. The script discusses how QR code readers, often used in places like grocery stores or concert venues, may have vulnerabilities because they are not frequently updated. This makes them a target for attacks using QR codes encoded with malicious payloads.

💡Custom tools

Custom tools are software applications designed for specific purposes or industries. The video mentions that various custom tools are used to read QR codes, and these tools may have inherent vulnerabilities due to their specialized nature and lack of frequent updates.

💡Python

Python is a widely-used high-level programming language known for its readability and versatility. The video discusses using Python to set up a tool called QR Gen, which can encode exploits into QR codes. Python's ease of use and powerful libraries make it a popular choice for such tasks.

💡Exploits

Exploits are pieces of software, code, or data that take advantage of a system's vulnerabilities to disrupt its normal functioning. The script explains how QR Gen can encode various exploits into QR codes, which, when scanned by a vulnerable device, can lead to unintended behavior or security breaches.

💡QR Gen

QR Gen is the tool discussed in the video for generating QR codes with embedded exploits. It is easy to install and use, requiring only a Linux system with Python. The tool allows users to select from a list of pre-built exploits or create custom wordlists to encode into QR codes.

💡Wordlist

A wordlist is a collection of words or phrases used in various security testing scenarios, including penetration testing. In the video, a wordlist is created with potential payloads to be encoded into QR codes. This allows for the generation of QR codes that, when scanned, may trigger specific actions or responses from the scanning device.

💡Payloads

Payloads in the context of cybersecurity are the actual code or data delivered by an exploit to carry out a malicious action. The video describes how QR Gen can encode various payloads into QR codes, such as command injections, which could be used to execute unauthorized commands on a device.

💡Penetration testing

Penetration testing, often shortened to pen testing, is the practice of testing a computer system, network, or web application to find vulnerabilities that a malicious hacker could exploit. The video suggests that using QR Gen for generating malicious QR codes can be a form of pen testing, helping to identify security weaknesses in systems that read QR codes.

💡Malicious QR codes

Malicious QR codes are QR codes that, when scanned, can cause harmful actions on the device reading them. The video demonstrates how QR Gen can be used to create such QR codes by encoding various exploits and payloads, which can then be used to test the security of QR code readers or potentially exploit vulnerable systems.

💡Ethical considerations

Ethical considerations refer to the moral principles that guide actions, especially in the context of technology and security. The video concludes with a reminder of the importance of obtaining permission before testing QR codes on devices, emphasizing ethical hacking practices to avoid causing harm or disruption.

Highlights

Exploring a tool to hack devices that scan QR codes.

QR codes are ubiquitous due to their ease of creation and use.

Devices reading QR codes often have vulnerabilities due to infrequent updates.

Introducing a tool that encodes exploits into QR codes for device scanning.

The tool requires Python and can be set up with a Linux system.

QR Gen is a tool that generates QR codes with embedded exploits.

The tool is easy to install on Kali Linux and has a straightforward setup process.

QR Gen has a built-in list of various payloads for different types of attacks.

Users can create custom wordlists for generating QR codes with specific payloads.

The tool can generate QR codes for command injection and other exploits.

Demonstration of generating malicious QR codes using custom and preinstalled lists.

Testing the generated QR codes on an Android phone to see the payloads.

The QR codes can potentially induce strange behavior in devices like ticket scanners or supermarket scanners.

The tool is useful for pen testers to find vulnerabilities in QR code implementations.

QR Gen is highly customizable, allowing for the creation of various payloads.

A cautionary note on testing the tool on non-critical devices with permission.

The tool can be used to discover problems in device configurations that could be exploited.

The episode concludes with a call to action for feedback and suggestions for future episodes.

Transcripts

play00:00

QR codes are everywhere and today we'll

play00:03

explore a tool that can help us hack

play00:05

devices that can scan them on this

play00:06

episode of cyber weapons lab

play00:09

[Music]

play00:15

[Applause]

play00:18

[Music]

play00:29

if you've been to a concert lately you

play00:32

might have noticed one thing that most

play00:33

of the tickets have in common and that

play00:34

is QR codes now the reason that QR codes

play00:38

are everywhere is because they're easy

play00:40

to create they're easy to use and most

play00:42

people have devices that are capable of

play00:44

reading them because of this there's

play00:46

also a variety of different custom tools

play00:48

that things like grocery stores or

play00:49

ticket scanners will use in order to

play00:51

read QR codes and often these devices

play00:54

will have vulnerabilities because

play00:55

they're usually not updated very often

play00:57

now today we're going to look at a tool

play00:59

that will basically encode some popular

play01:01

exploits into QR codes hoping that when

play01:05

a device scans it it'll read it and then

play01:07

actually execute the code now in order

play01:09

to do this we'll need to have Python and

play01:11

if you have any trouble setting this up

play01:13

you can also check out the null byte

play01:14

article linked in the description as

play01:16

soon as you have a Linux system ready to

play01:18

go with Python installed then we're

play01:20

ready to begin today we're going to use

play01:24

a tool called QR gen and this is really

play01:27

interesting because there's a lot of

play01:29

devices that are customized for various

play01:30

applications that might be running

play01:32

services that are vulnerable to various

play01:34

types of attacks now this is also super

play01:37

easy to install and in order to do so

play01:40

you'll just need a Linux system although

play01:42

I actually have not tried this on Mac OS

play01:43

and it may work as well but because it's

play01:46

Python I figured I would try it on Kali

play01:48

Linux and lo and behold it worked the

play01:49

first time without any complications

play01:51

except one little quirk in the way that

play01:53

this is written and that's actually the

play01:55

execution script is not right that's it

play01:58

says QR code pi it's QR Gen dot pi but

play02:00

aside from that these instruction

play02:01

instructions are actually kind of a

play02:03

breeze to set up so first we are going

play02:06

to copy this and in a fresh terminal

play02:08

window we're going to paste the git

play02:10

clone command and here it's gonna fail

play02:13

because I already have this path but if

play02:15

you didn't have this installed then it

play02:16

would download everything in the github

play02:19

directory to your folder that you're

play02:22

currently in so once we CD change

play02:25

directory into hue our gen we can type

play02:29

LS and see all the various files that

play02:31

are there

play02:31

and there is a requirements text file

play02:34

which is really useful because it has

play02:36

all the various libraries that we'll

play02:37

need to run this so if we want to do it

play02:40

easily we can follow the instructions

play02:42

here and use pip3 install tack

play02:44

requirements text which is a easy way of

play02:47

using pep 3 or if you just have pep you

play02:49

can use Python 3 tack em pip install

play02:52

tack our requirements text obviously the

play02:54

first one is a little bit shorter so I

play02:56

like it more so once we do this it

play03:00

should go through and make sure we have

play03:01

all the various libraries we need to use

play03:03

this Python tool when it finishes

play03:05

installing then we should be able to

play03:06

just run it and see what happens so

play03:09

again if we that's actually just still

play03:11

there we can see it's QR Gen dot pi so

play03:22

after running Python 3 Q our agenda PI

play03:24

we can see that we can now select one of

play03:27

two different options either a word list

play03:29

or tock elf or a number now this is

play03:33

where things get interesting because it

play03:34

has a built-in list of various different

play03:37

payloads that could be useful depending

play03:38

on what you're going after now this

play03:41

could be cross-site scripting SQL

play03:43

injections or a variety of different

play03:44

other things so we're going to use I

play03:46

guess let's see maybe a command

play03:48

injection as an example of the various

play03:51

types of QR codes you can generate that

play03:52

might be malicious depending on whether

play03:54

or not a particular device is vulnerable

play03:56

now I also want to show off the word

play03:59

list feature if we want to create a new

play04:01

wordlist we can say nano word list dot

play04:06

text and type in a couple random

play04:08

payloads these aren't real

play04:22

and then I'll add another one

play04:35

all right now we have our malicious code

play04:38

it looks really bad we'll save it and if

play04:42

I type LS again we should now see we

play04:44

have our word list text so if we want to

play04:47

go back up and run Python 3 QR code QR

play04:51

Gen hi tak W and then requirements dot

play04:56

text it should generate some QR codes

play04:59

let's see-oh need to be together it

play05:03

should generate some QR codes based on

play05:05

the payloads that we ourselves created

play05:08

and we'll test that in a little bit when

play05:09

we test some of the malicious ones that

play05:11

we generate as well now the next thing

play05:14

we can do is actually use the tak l

play05:16

option to select one of the preinstalled

play05:18

lists which include a variety of

play05:20

different common exploits for maybe an

play05:22

unpatched service that's using SQL or

play05:24

something that might be vulnerable to

play05:26

something like string fuzzing now I

play05:29

guess let's see we'll select number two

play05:31

for command injection and we'll tie tack

play05:34

L and then just - and we'll see if we

play05:37

can get this to generate some malicious

play05:39

QR codes for us to test now if I go to

play05:43

the folder I might even be able to see

play05:44

these being created and as you can see

play05:48

we have a whole bunch of QR codes if the

play05:50

system is creating right now and if we

play05:52

go we can see there we go we have a lot

play05:55

of different malicious QR codes we can

play05:56

now test so this is the perfect testbed

play05:59

for anyone who wants to take a device

play06:01

and test it so we're gonna go ahead and

play06:03

take an Android phone and see if we can

play06:05

read these and if so what it actually

play06:06

sees I don't expect it will be able to

play06:09

actually exploit it but if we were

play06:10

running something like a ticket scanner

play06:11

or something at a grocery store it's

play06:13

likely we would be able to induce some

play06:15

strange behavior

play06:17

all right so now we're going to go ahead

play06:19

and test the payloads that we created

play06:21

and to do that we'll use this QR code

play06:24

reader and see what we can actually pull

play06:26

out of the payloads and it pulls them

play06:28

out rather quickly so I'm gonna have to

play06:29

limit the ones that I have on screen so

play06:31

it doesn't just immediately grab them so

play06:33

let's go ahead and pick one of the first

play06:34

ones we did and we can see that this is

play06:37

QR code it actually actually wasn't able

play06:40

to display all the way oh we can see the

play06:44

pipe character so this is actually it

play06:46

looks like it's interpreting it I

play06:47

remember typing the pipe character into

play06:49

the payloads that we generated and as we

play06:54

read these we can see that they are

play06:55

unusual or like break characters you can

play07:05

see this is a trying to get it to escape

play07:08

and then try to ping something so if

play07:10

something has network activity this one

play07:12

is trying to et Cie into a password

play07:14

directory and it could display the

play07:15

password to the device on the screen

play07:17

this is requesting the ID of the device

play07:20

so as you can see these usually consist

play07:22

of something like a pipe symbol

play07:24

something that is trying to get us to be

play07:27

able to either access more parts of the

play07:30

device that we shouldn't have access to

play07:32

or actually do something that we're just

play07:34

really not supposed to do and here we go

play07:36

that's some really malicious looking

play07:40

code that will probably get us deeper

play07:43

into maybe a database or some other

play07:46

thing that uses structured calls that is

play07:48

an expecting a call like this and would

play07:50

escape it and then attempt to run

play07:52

something like this such as this dollar

play07:54

sign and then in closed string Who am I

play07:57

so as you can see there are a bunch of

play08:00

different malicious things that we could

play08:03

now run on something that we have

play08:04

permission to and potentially discover a

play08:06

number of different problems in the way

play08:09

that this device is configured that

play08:10

could allow someone with a single

play08:12

malicious timaya command to get a whole

play08:14

bunch of free tickets a special price on

play08:16

groceries or some other thing that you

play08:17

didn't intend on when you design your

play08:19

system so this is a great way of making

play08:22

sure that there aren't any

play08:23

vulnerabilities in a QR code

play08:25

implementation or if you're a pen tester

play08:27

maybe find an interesting

play08:29

way of exploiting something that nobody

play08:31

else has thought of through a network

play08:33

connected device that maybe whoa this is

play08:36

a big one a network connected device

play08:38

that maybe uses something like QR codes

play08:43

in order to process stuff so this is I

play08:45

think a really exciting project and the

play08:47

more exploits you can think of the more

play08:48

you can cram into this because it's

play08:50

highly customizable and allows you to

play08:52

create payloads for whatever you want

play08:55

QR gen can create a lot of different QR

play08:58

codes that may or may not be effective

play09:00

against a particular device that scans

play09:02

QR codes now this could be a ticket

play09:05

scanner it could be a supermarket

play09:06

scanner or it could be someone's cell

play09:08

phone but in general it's not a great

play09:10

idea to test this against something

play09:11

really critical or something you don't

play09:13

have permission to because depending on

play09:14

the payload it could potentially disable

play09:16

it or cause it to display erratic

play09:18

behavior if you're at work and choose to

play09:20

test this on your ticket scanner right

play09:22

before a big concert you could get in a

play09:24

lot of trouble so please make sure that

play09:26

your permission to do so and that you're

play09:27

not testing this on a critical device

play09:29

that's about to be used if you have any

play09:31

problems testing this you can check out

play09:33

the null byte article link in the

play09:34

description and you can also hit me up

play09:36

on Twitter if you have any ideas for

play09:37

future episodes that's all we have for

play09:40

this episode of cyber weapons lab make

play09:42

sure to LIKE comment and subscribe and

play09:43

we'll see you next time

Rate This

5.0 / 5 (0 votes)

الوسوم ذات الصلة
QR CodeHackingCybersecurityExploitPythonPenetration TestingMalicious PayloadsTicket ScannersGrocery Stores
هل تحتاج إلى تلخيص باللغة الإنجليزية؟