Reader small image

You're reading from  Attacking and Exploiting Modern Web Applications

Product typeBook
Published inAug 2023
PublisherPackt
ISBN-139781801816298
Edition1st Edition
Concepts
Right arrow
Authors (2):
Simone Onofri
Simone Onofri
author image
Simone Onofri

Simone Onofri is a cybersecurity director with over two decades of experience in Red and Blue Teaming, vulnerability research, and product management. He has been an instructor at the Joint Intelligence and EW Training Centre and is associated with global companies such as HewlettPackard Enterprise. Simone has discovered various vulnerabilities and holds key certifications such as GXPN, GREM, GWAPT, OSCP, and OPSA. An active participant in organizations such as OWASP and ISECOM, he regularly speaks at major conferences, including TEDx. Simone is committed to inspiring and educating industry professionals and enthusiasts through his work, with a mission to create a positive influence.
Read more about Simone Onofri

Donato Onofri
Donato Onofri
author image
Donato Onofri

Donato Onofri is a seasoned Red Team engineer. He has over a decade of experience in activities including reverse engineering, Red Teaming, threat research, and penetration testing. Passionate about both the offensive and defensive sides of cybersecurity, Donato has worked with industry leaders such as CrowdStrike and Hewlett-Packard Enterprise and as an advisor and engineer for governments and financial institutions. His research delves into state-of-the-art security techniques, malware analysis, and internals. He holds the GREM, GXPN, OSCP, OSCE, and OSWE certifications, and his expertise is underscored by multiple recognitions for vulnerability discovery.
Read more about Donato Onofri

View More author details
Right arrow

Attacking Electron JavaScript Applications – from Cross-Site Scripting (XSS) to Remote Command Execution (RCE)

“The growing list of graphics formats relate primarily to static displays. But some people feel a Web page isn’t sufficiently exciting unless it moves. At a minimum, they want the page to change as a user interacts. Pop-up balloons and menus, and forms that fill themselves in, are simple examples we find today on the Web. These work because a small program, or script, is loaded with the page. It operates the page like the hand inside a puppet, in response to the user’s actions.”

Sir Tim Berners Lee and Mark Fischietti [1]

Welcome to the sixth chapter of this book, where we will analyze cross-site scripting (XSS) and how to make a remote command execution (RCE) from Electron JavaScript applications. We will start by looking at static analysis and different dynamic analysis techniques.

It was 1989 when Sir Tim Berners-Lee invented...

Technical requirements

You can use the Ubuntu LTS machine configured in Chapter 2 in this chapter.

Scenario files

To reproduce the scenario in this chapter, you can use the files in the Chapter06 directory in this book’s GitHub repository.

The scenario comprises application and test files.

Electron JavaScript applications scenario introduction

In this scenario, we will examine an Electron JavaScript application we enjoy using during incident response activities. Although we often focus on red team operations, we also engage in blue team practices. Performing both activities provides us with a significant advantage. On the one hand, thinking like attackers, even when defending an organization, allows us to implement the think like your enemy principle. On the other hand, we learn our adversaries’ tactics, techniques, and procedures (TTPs), which can be useful in various situations. Consequently, red and blue team activities can be seen as the yin and yang of cybersecurity.

We will discuss Aurora Incident Response [4], an Electron application created by Mathias Fuchs [5], which is incredibly useful for managing incident response tasks, including organizing our findings and to-do lists.

We discovered an XSS vulnerability within the application, which made us...

How Electron JavaScript applications and XSS work

Electron applications are popular among developers seeking to create cross-platform desktop applications using web technologies such as HTML, CSS, and JavaScript. The framework allows developers to leverage web development practices and frameworks such as React, Angular, or Vue to create rich, responsive interfaces. Electron apps can also benefit from the extensive ecosystem of JavaScript libraries and modules available through the Node.js environment.

Understanding an Electron JavaScript application’s structure

Let’s understand how the processes and filesystems of these applications are structured.

Electron JavaScript application processes structure

An Electron app’s structure is based on two primary processes – the main process and the renderer process:

  • The main process serves as the application’s entry point and creates and manages application windows. This process runs the main...

How to find and exploit XSS in Electron JavaScript applications to obtain RCE

We will now begin our journey into Electron applications. Since Aurora’s sources are available, we can directly download the build environment, which is also the most up-to-date one.

Downloading the source code and running the application

Follow the instructions on the GitHub page (https://github.com/cyb3rfox/Aurora-Incident-Response) to download the source code. Follow these steps:

  1. Install npm, the default package manager for the runtime environment Node.js, with apt:
    $ sudo apt install nodejs npm
  2. Clone the repository using git, enter the directory with cd, and checkout the specific commit we used in this chapter – that is, bb4533e81b16aa37c2baba6f73fce97c8b1b1d3d (the latest at the time of writing):
    $ git clone https://github.com/cyb3rfox/Aurora-Incident-Response  && cd Aurora-Incident-Response && git checkout bb4533e81b16aa37c2baba6f73fce97c8b1b1d3d...

Summary

In this chapter, we looked at the structure of Electron applications while focusing on aspects such as filesystems and processes. We also provided an overview of XSS and discussed its types, techniques, and vectors.

We analyzed an Electron JavaScript application using source code analysis, dynamic analysis, instrumentation, and debugging techniques. We also identified different types of XSS, including stored XSS and self-XSS, and demonstrated how to turn XSS into RCE in an Electron JavaScript application.

In the next chapter, we’ll focus on Ethereum Smart Contracts.

Further reading

This chapter covered many topics. If you like to dive deeper, we’re happy to share some useful resources with you:

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Attacking and Exploiting Modern Web Applications
Published in: Aug 2023Publisher: PacktISBN-13: 9781801816298
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Authors (2)

author image
Simone Onofri

Simone Onofri is a cybersecurity director with over two decades of experience in Red and Blue Teaming, vulnerability research, and product management. He has been an instructor at the Joint Intelligence and EW Training Centre and is associated with global companies such as HewlettPackard Enterprise. Simone has discovered various vulnerabilities and holds key certifications such as GXPN, GREM, GWAPT, OSCP, and OPSA. An active participant in organizations such as OWASP and ISECOM, he regularly speaks at major conferences, including TEDx. Simone is committed to inspiring and educating industry professionals and enthusiasts through his work, with a mission to create a positive influence.
Read more about Simone Onofri

author image
Donato Onofri

Donato Onofri is a seasoned Red Team engineer. He has over a decade of experience in activities including reverse engineering, Red Teaming, threat research, and penetration testing. Passionate about both the offensive and defensive sides of cybersecurity, Donato has worked with industry leaders such as CrowdStrike and Hewlett-Packard Enterprise and as an advisor and engineer for governments and financial institutions. His research delves into state-of-the-art security techniques, malware analysis, and internals. He holds the GREM, GXPN, OSCP, OSCE, and OSWE certifications, and his expertise is underscored by multiple recognitions for vulnerability discovery.
Read more about Donato Onofri