Introduction

IDAPython is a powerful feature of IDA Pro, and there are many open-sourced IDAPython projects. However, we cannot use every GUI-based IDAPython script due to some Qt-related breaking changes between IDA Pro 6.8 and 6.9 or later. The main problem is about migrating no longer supported PySide code to PyQt5.

Recently I ported PySide code within idasec–one of the most sophisticated deobfuscation frameworks, which tackles opaque predicates and call stack tampering in terms of infeasibility questions, by utilizing Backward-Bounded Dynamic Symbolic Execution proposed in the remarkably well written paper S. Bardin et al. IEEE S&P’17–to PyQt5.

That’s why I decided to write this blog post for a note to self and for someone trying to do similar thing.

Related Work

There are 2 guidances to migrate PySide code to PyQt5:

Please read them before. I only give supplemental information in addition to predecessors.

How to Migrate

Now let’s get started.

Change QtGui methods to QtWidgets

Most methods in QtGui migrated to QtWidgets. Therefore,

1
from PySide import QtGui, QtCore

becomes:

1
from PyQt5 import QtCore, QtGui, QtWidgets

As an example, QTextEdit described in Hex Blog. In additions, the methods to be rewritten are as follows:

  • QtWidgets.QLayout
  • QtWidgets.QVBoxLayout
  • QtWidgets.QHBoxLayout
  • QtWidgets.QWidget
  • QtWidgets.QTableWidget
  • QtWidgets.QListWidget
  • QtWidgets.QTabWidget
  • QtWidgets.QDockWidget
  • QtWidgets.QTreeWidget
  • QtWidgets.QTreeWidgetItem
  • QtWidgets.QPushButton
  • QtWidgets.QRadioButton
  • QtWidgets.QToolButton
  • QtWidgets.QButtonGroup
  • QtWidgets.QGroupBox
  • QtWidgets.QSpinBox
  • QtWidgets.QCheckBox
  • QtWidgets.QComboBox
  • QtWidgets.QTextEdit
  • QtWidgets.QLineEdit
  • QtWidgets.QApplication
  • QtWidgets.QLabel
  • QtWidgets.QSizePolicy
  • QtWidgets.QMenu
  • QtWidgets.QFrame
  • QtWidgets.QProgressBar
  • QtWidgets.QStyle
  • QtWidgets.QSpacerItem
  • QtWidgets.QScrollArea
  • QtWidgets.QSplitter
  • There might be more…

My experience says that other than the following 3 methods may be rewritten:

  • QtGui.QPixmap
  • QtGui.QIcon
  • QtGui.QFont

idacute may overwrite all of QtGui methods, so I think there still needs to be manual works.

Overwrite _fromUtf8

We also need to overwrite _fromUtf8.

1
2
3
4
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    _fromUtf8 = lambda s: s

Others

These issues are described by predecessors:

  • Handling SIGNAL
  • Change FormToPySideWidget to FormToPyQtWidget
  • Change setResizeMode to setSectionResizeMode

Conclusion

This time, I was able to run idasec on IDA Pro 7.0 with some bug fixes and dirty patches – like this cool video:

If you are an IDA Pro 7.0 user, note that other backward-compatibility issue described in IDA: IDAPython backward-compatibility with 6.95 APIs will occur.

Enjoy!

HAI DOMO VIRTUAL YOUTUBER KIZUNA AI DESU. I’m still working on my English.