Adding a GUI File Explorer to Loki C2: A Quick Overview

Listen to this Post

Bobby Cooke, from IBM X-Force Red, recently shared his experience of adding a GUI file explorer to the Loki C2 client. Built with Electron, the file explorer allows users to open readable files in a new window and download non-text files directly to the Loki downloads directory. While the design may not win awards, the functionality is impressive, especially considering it was developed in just a few hours with the help of AI for web development tasks.

You Should Know:

Here are some practical commands and code snippets related to file exploration and Electron development that you might find useful:

1. Electron Quick Start:


<h1>Clone the Quick Start repository</h1>

git clone https://github.com/electron/electron-quick-start

<h1>Navigate to the directory</h1>

cd electron-quick-start

<h1>Install dependencies</h1>

npm install

<h1>Run the app</h1>

npm start

2. File Handling in Electron:

const { app, BrowserWindow, ipcMain, dialog } = require('electron');
const fs = require('fs');
const path = require('path');

let mainWindow;

function createWindow() {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});

mainWindow.loadFile('index.html');

// Open file dialog
ipcMain.on('open-file-dialog', (event) => {
dialog.showOpenDialog({
properties: ['openFile'],
}).then(result => {
if (!result.canceled) {
const filePath = result.filePaths[0];
fs.readFile(filePath, 'utf-8', (err, data) => {
if (err) {
console.error(err);
return;
}
event.reply('file-data', data);
});
}
}).catch(err => {
console.error(err);
});
});
}

app.whenReady().then(createWindow);

3. Linux File Exploration Commands:


<h1>List files in a directory</h1>

ls -l /path/to/directory

<h1>Search for files by name</h1>

find /path/to/directory -name "*.txt"

<h1>Open a file in the default text editor</h1>

xdg-open /path/to/file.txt

<h1>Download a file using wget</h1>

wget https://example.com/file.zip -O /path/to/downloads/file.zip

4. Windows File Exploration Commands:

:: List files in a directory
dir C:\path\to\directory

:: Search for files by name
dir C:\path\to\directory /s /p | find "filename"

:: Open a file in the default text editor
start notepad C:\path\to\file.txt

:: Download a file using PowerShell
Invoke-WebRequest -Uri https://example.com/file.zip -OutFile C:\path\to\downloads\file.zip

What Undercode Say:

Adding a GUI file explorer to a command-and-control (C2) framework like Loki C2 is a significant step towards improving user experience, especially for those who prefer graphical interfaces over command-line operations. The use of Electron for rapid development highlights the power of modern web technologies in creating cross-platform applications. However, it’s essential to balance functionality with security, especially when dealing with sensitive operations like file handling in a C2 environment. The provided commands and code snippets should help you get started with similar projects, whether you’re working on Linux or Windows. For further reading on Electron development, check out the official Electron documentation.

References:

Reported By: Bobby Cooke – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

Whatsapp
TelegramFeatured Image