ARTICLE AD BOX
I am creating a tool with GUI using PyQT, so the Qiling emulation is being executed in a QThread object. I am using rootfs sandbox env with the qiling. Now I can create a file before the emulation begins but once emulation is started I am not able to write to any location even after the emulation. I don't face this behavior if I emulate the PE directly without the PyQt GUI. I don't know what causes this issue. Can anyone guide me if there is a fix for it or not. Or what should be better approach for implementing this. The error traceback
Traceback (most recent call last): File "f:\Studies\University\FYP\DARTS-Final\Qiling\emulator.py", line 24, in save_json with open(json_out, "w") as f: PermissionError: [Errno 13] Permission denied: 'F:/Studies/University/FYP/DARTS-Final/Qiling/jsons' [!] Error writing JSON output: [Errno 13] Permission denied: 'F:/Studies/University/FYP/DARTS-Final/Qiling/jsons'Here is reproduce able code
import sys, json from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout, QTextEdit from PyQt5.QtCore import QThread, pyqtSignal from qiling import Qiling class QilingWorker(QThread): log_signal = pyqtSignal(str) def __init__(self, target_path, rootfs): super().__init__() self.target_path = target_path self.rootfs = rootfs def run(self): try: self.log_signal.emit("Starting Qiling emulation...\n") # Example Qiling run (safe placeholder) ql = Qiling([self.target_path], self.rootfs) # Execute until finish ql.run() self.log_signal.emit("\nEmulation finished.") except Exception as e: self.log_signal.emit(f"[Error] {str(e)}") with open('dummy.json', 'w') as f: json.dump({"Test":"Test"}, f) class MainWindow(QWidget): def __init__(self): super().__init__() self.setWindowTitle("Qiling + PyQt Example") self.resize(500, 400) self.log_box = QTextEdit() self.log_box.setReadOnly(True) self.btn_start = QPushButton("Run Emulation") self.btn_start.clicked.connect(self.start_emulation) layout = QVBoxLayout() layout.addWidget(self.log_box) layout.addWidget(self.btn_start) self.setLayout(layout) self.worker = None def start_emulation(self): # Adjust target and rootfs based on your environment target = "./test_bin" # sample binary rootfs = "./rootfs" # Qiling rootfs self.worker = QilingWorker(target, rootfs) self.worker.log_signal.connect(self.append_log) self.worker.start() self.log_box.append("Thread started...\n") def append_log(self, text): self.log_box.append(text) if __name__ == "__main__": app = QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec_())