hey i have this error
The debugged program raised the exception unhandled RuntimeError
"underlying C/C++ object has been deleted"
the code is:

class qthread(QtCore.QThread):
    def __init__(self, x, y, z):
        self.x=x
        self.y=y
        self.z=z
        self.name=""
        self.m=hashlib.md5()
    def changeresultsig(self, text):
        self.emit(QtCore.SIGNAL("changeresult(text)"),text)
    def conssig(self, text):
        self.emit(QtCore.SIGNAL("cons(text)"), text)
    def enablesig(self):
        self.emit(QtCore.SIGNAL("enable("))
    def disablesig(self):
        self.emit(QtCOre.SIGNAL("disable()"))
    def gui(self):
        self.emit(QtCore.SIGNAL("gui()"))
    def run(self):
        self.name="md"+str(z)+".dat"
        self.conssig("starting thread "+str(z)+"..")
        self.changeresultsig("starting thread "+str(z)+"..")
        self.gui()

        try:
            self.db=anydbm.open(name, "n")
        except e:

            self.conssig("error openning the database "+self.name+" "+e.reason())
            self.changeresultsig("error oppening the database "+str(self.name))
            self.enable()
            self.gui()

            pass
            return 1
        self.s=string.printable

        self.conssigole("setting up...")
        self.gui()

        while self.x<=self.y:

            self.changeresultsig("starting loop..")
            self.conssig("starting loop..")
            self.gui()

            self.it=itertools.product(self.s, reapeat=self.x)
            for i in self.it:
                self.ij="".join(i)
                self.m=hashlib.md5(self.ij)
                self.db[self.m.hexdigest()]=self.ij

                self.changeresultsig("calculating hash of the string ("+self.ij+") with the hash ("+self.m.hexdigest()+").")
                self.gui()

        self.db.close()

        self.changeresultsig("thread "+str(self.z)+" finished!")
        self.conssig("finished!")
        self.gui()


th1=qthread(0, 3, 1)
th2=qthread(4, 6, 2)
th3=qthread(7, 9, 3)
th4=qthread(10, 13, 4)
th5=qthread(14, 15, 5)
def connecter():
    QtCore.QObject.connect(th1,  QtCore.SIGNAL("gui()"), gui)#ERROR line
    QtCore.QObject.connect(th2,  QtCore.SIGNAL("gui()"), gui)
    QtCore.QObject.connect(th3,  QtCore.SIGNAL("gui()"), gui)
    QtCore.QObject.connect(th4,  QtCore.SIGNAL("gui()"), gui)
    QtCore.QObject.connect(th5,  QtCore.SIGNAL("gui()"), gui)
    QtCore.QObject.connect(th1,  QtCore.SIGNAL("enable()"), enable)
    QtCore.QObject.connect(th2,  QtCore.SIGNAL("enable()"), enable)
    QtCore.QObject.connect(th3,  QtCore.SIGNAL("enable()"), enable)
    QtCore.QObject.connect(th4,  QtCore.SIGNAL("enable()"), enable)
    QtCore.QObject.connect(th5,  QtCore.SIGNAL("enable()"), enable)
    QtCore.QObject.connect(th1,  QtCore.SIGNAL("disable()"), disable)
    QtCore.QObject.connect(th2,  QtCore.SIGNAL("disable()"), disable)
    QtCore.QObject.connect(th3,  QtCore.SIGNAL("disable()"), disable)
    QtCore.QObject.connect(th4,  QtCore.SIGNAL("disable()"), disable)
    QtCore.QObject.connect(th5,  QtCore.SIGNAL("disable()"), disable)
    QtCore.QObject.connect(th1,  QtCore.SIGNAL("changeresult()"), changeresult)
    QtCore.QObject.connect(th2,  QtCore.SIGNAL("changeresult()"), changeresult)
    QtCore.QObject.connect(th3,  QtCore.SIGNAL("changeresult()"), changeresult)
    QtCore.QObject.connect(th4,  QtCore.SIGNAL("changeresult()"), changeresult)
    QtCore.QObject.connect(th5,  QtCore.SIGNAL("changeresult()"), changeresult)
    QtCore.QObject.connect(th1,  QtCore.SIGNAL("cons()"), cons)
    QtCore.QObject.connect(th2,  QtCore.SIGNAL("cons()"), cons)
    QtCore.QObject.connect(th3,  QtCore.SIGNAL("cons()"), cons)
    QtCore.QObject.connect(th4,  QtCore.SIGNAL("cons()"), cons)
    QtCore.QObject.connect(th5,  QtCore.SIGNAL("cons()"), cons)

def main():
    cons("new session")
    cons("setting connecter")
    connecter()
    cons("disabling GUI")
    disable()
    gui()
    cons("starting threads....")
    gui()
    th1.start()
    th2.start()
    th3.start()
    th4.start()
    th5.start()

Recommended Answers

All 4 Replies

I do not know answer to your question but you are refering to undefined variable z at line 19.

hmm maybe this is the full code

#! /usr/bin/python
# -*- coding: utf-8 -*-
import hashlib, anydbm, string, time, threading, sys, itertools
from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    _fromUtf8 = lambda s: s
gui=QtGui.QApplication.processEvents
lock=threading.Lock()
cracked=None
def enable():
    MainWindow.setEnabled(True)
def disable():
    MainWindow.setEnabled(False)
def cons(text):
    firsttext=ui.console.toPlainText()
    finaltext=firsttext+"-"+text+"\n"
    ui.console.setText(finaltext)
def clearcons():
    ui.console.setText("")
def changeresult(text):
    ui.statue.setText(text)
def bruter(x, y, z):
    s=string.printable
    hash=str(ui.md5.text())
    lock.acquire()
    cons("starting thread "+str(z))
    gui()
    lock.release()
    while x<=y:
        it=itertools.product(s, repeat=x)
        for i in it:
            ij="".join(i)
            m=hashlib.md5(ij)
            if m.hexdigest()==hash:
                cracked=m.hexdigest()
                lock.acquire()
                enable()
                cons("the cracked hash is ("+m.hexdigest()+").")
                changestatue(m.hexdigest())
                gui()
                lock.release()
                break
    else:
        lock.acquire()
        cons("not found!!")
        cracked="NULL"
        changeresult("no result founded")
        gui()
        lock.release()
def bruteattack():

    while True:
        if cracked!=None:
            cons("the cracked hash is ("+cracked+")")
            changeresult(cracked)
            enable()
            gui()
            break

def hasher():
    text=str(ui.string.text())
    m=hashlib.md5(text)
    changeresult(m.hexdigest())
    cons("the hash for ("+text+") is ("+m.hexdigest()+") .")
    gui()
x=None
y=None
z=None
class qthread(QtCore.QThread):
    def __init__(self, x, y, z):
        self.x=x
        self.y=y
        self.z=z
        self.name=""
        self.m=hashlib.md5()
    def changeresultsig(self, text):
        self.emit(QtCore.SIGNAL("changeresult(text)"),text)
    def conssig(self, text):
        self.emit(QtCore.SIGNAL("cons(text)"), text)
    def enablesig(self):
        self.emit(QtCore.SIGNAL("enable("))
    def disablesig(self):
        self.emit(QtCOre.SIGNAL("disable()"))
    def gui(self):
        self.emit(QtCore.SIGNAL("gui()"))
    def run(self):
        self.name="md"+str(self.z)+".dat"
        self.conssig("starting thread "+str(self.z)+"..")
        self.changeresultsig("starting thread "+str(self.z)+"..")
        self.gui()

        try:
            self.db=anydbm.open(name, "n")
        except e:

            self.conssig("error openning the database "+self.name+" "+e.reason())
            self.changeresultsig("error oppening the database "+str(self.name))
            self.enable()
            self.gui()

            pass
            return 1
        self.s=string.printable

        self.conssigole("setting up...")
        self.gui()

        while self.x<=self.y:

            self.changeresultsig("starting loop..")
            self.conssig("starting loop..")
            self.gui()

            self.it=itertools.product(self.s, reapeat=self.x)
            for i in self.it:
                self.ij="".join(i)
                self.m=hashlib.md5(self.ij)
                self.db[self.m.hexdigest()]=self.ij

                self.changeresultsig("calculating hash of the string ("+self.ij+") with the hash ("+self.m.hexdigest()+").")
                self.gui()

        self.db.close()

        self.changeresultsig("thread "+str(self.z)+" finished!")
        self.conssig("finished!")
        self.gui()


th1=qthread(0, 3, 1)
th2=qthread(4, 6, 2)
th3=qthread(7, 9, 3)
th4=qthread(10, 13, 4)
th5=qthread(14, 15, 5)
def connecter():
    th1.connect(th1,  QtCore.SIGNAL("gui()"), gui)
    QtCore.QObject.connect(th2,  QtCore.SIGNAL("gui()"), gui)
    QtCore.QObject.connect(th3,  QtCore.SIGNAL("gui()"), gui)
    QtCore.QObject.connect(th4,  QtCore.SIGNAL("gui()"), gui)
    QtCore.QObject.connect(th5,  QtCore.SIGNAL("gui()"), gui)
    QtCore.QObject.connect(th1,  QtCore.SIGNAL("enable()"), enable)
    QtCore.QObject.connect(th2,  QtCore.SIGNAL("enable()"), enable)
    QtCore.QObject.connect(th3,  QtCore.SIGNAL("enable()"), enable)
    QtCore.QObject.connect(th4,  QtCore.SIGNAL("enable()"), enable)
    QtCore.QObject.connect(th5,  QtCore.SIGNAL("enable()"), enable)
    QtCore.QObject.connect(th1,  QtCore.SIGNAL("disable()"), disable)
    QtCore.QObject.connect(th2,  QtCore.SIGNAL("disable()"), disable)
    QtCore.QObject.connect(th3,  QtCore.SIGNAL("disable()"), disable)
    QtCore.QObject.connect(th4,  QtCore.SIGNAL("disable()"), disable)
    QtCore.QObject.connect(th5,  QtCore.SIGNAL("disable()"), disable)
    QtCore.QObject.connect(th1,  QtCore.SIGNAL("changeresult()"), changeresult)
    QtCore.QObject.connect(th2,  QtCore.SIGNAL("changeresult()"), changeresult)
    QtCore.QObject.connect(th3,  QtCore.SIGNAL("changeresult()"), changeresult)
    QtCore.QObject.connect(th4,  QtCore.SIGNAL("changeresult()"), changeresult)
    QtCore.QObject.connect(th5,  QtCore.SIGNAL("changeresult()"), changeresult)
    QtCore.QObject.connect(th1,  QtCore.SIGNAL("cons()"), cons)
    QtCore.QObject.connect(th2,  QtCore.SIGNAL("cons()"), cons)
    QtCore.QObject.connect(th3,  QtCore.SIGNAL("cons()"), cons)
    QtCore.QObject.connect(th4,  QtCore.SIGNAL("cons()"), cons)
    QtCore.QObject.connect(th5,  QtCore.SIGNAL("cons()"), cons)

def main():
    cons("new session")
    cons("setting connecter")
    connecter()
    cons("disabling GUI")
    disable()
    gui()
    cons("starting threads....")
    gui()
    th1.start()
    th2.start()
    th3.start()
    th4.start()
    th5.start()




class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(804, 386)
        MainWindow.setMinimumSize(QtCore.QSize(804, 386))
        MainWindow.setMaximumSize(QtCore.QSize(804, 386))
        MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "memo md5 cracker 2", None, QtGui.QApplication.UnicodeUTF8))
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8("../memomd5cracker/data/d.jpg")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        MainWindow.setWindowIcon(icon)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.generate = QtGui.QPushButton(self.centralwidget)
        self.generate.setGeometry(QtCore.QRect(30, 350, 97, 27))
        self.generate.setText(QtGui.QApplication.translate("MainWindow", "generate", None, QtGui.QApplication.UnicodeUTF8))
        self.generate.setObjectName(_fromUtf8("generate"))
        self.check = QtGui.QPushButton(self.centralwidget)
        self.check.setGeometry(QtCore.QRect(140, 240, 97, 27))
        self.check.setText(QtGui.QApplication.translate("MainWindow", "check", None, QtGui.QApplication.UnicodeUTF8))
        self.check.setObjectName(_fromUtf8("check"))
        self.quit = QtGui.QPushButton(self.centralwidget)
        self.quit.setGeometry(QtCore.QRect(360, 350, 97, 27))
        self.quit.setText(QtGui.QApplication.translate("MainWindow", "quit", None, QtGui.QApplication.UnicodeUTF8))
        self.quit.setObjectName(_fromUtf8("quit"))
        self.clear = QtGui.QPushButton(self.centralwidget)
        self.clear.setGeometry(QtCore.QRect(680, 350, 97, 27))
        self.clear.setText(QtGui.QApplication.translate("MainWindow", "clear", None, QtGui.QApplication.UnicodeUTF8))
        self.clear.setObjectName(_fromUtf8("clear"))
        self.brute = QtGui.QPushButton(self.centralwidget)
        self.brute.setGeometry(QtCore.QRect(30, 240, 97, 27))
        self.brute.setText(QtGui.QApplication.translate("MainWindow", "brute", None, QtGui.QApplication.UnicodeUTF8))
        self.brute.setObjectName(_fromUtf8("brute"))
        self.tomd5 = QtGui.QPushButton(self.centralwidget)
        self.tomd5.setGeometry(QtCore.QRect(30, 140, 97, 27))
        self.tomd5.setText(QtGui.QApplication.translate("MainWindow", "to md5", None, QtGui.QApplication.UnicodeUTF8))
        self.tomd5.setObjectName(_fromUtf8("tomd5"))
        self.string = QtGui.QLineEdit(self.centralwidget)
        self.string.setGeometry(QtCore.QRect(30, 100, 411, 27))
        self.string.setObjectName(_fromUtf8("string"))
        self.md5 = QtGui.QLineEdit(self.centralwidget)
        self.md5.setGeometry(QtCore.QRect(30, 200, 411, 27))
        self.md5.setObjectName(_fromUtf8("md5"))
        self.console = QtGui.QTextEdit(self.centralwidget)
        self.console.setGeometry(QtCore.QRect(480, 40, 301, 291))
        self.console.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.console.setReadOnly(True)
        self.console.setObjectName(_fromUtf8("console"))
        self.label = QtGui.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(120, 10, 231, 51))
        self.label.setText(QtGui.QApplication.translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Ubuntu\'; font-size:11pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:18pt; font-weight:600;\">memo md5 cracker</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.label.setObjectName(_fromUtf8("label"))
        self.label_2 = QtGui.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(30, 80, 67, 17))
        self.label_2.setText(QtGui.QApplication.translate("MainWindow", "string :", None, QtGui.QApplication.UnicodeUTF8))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.label_3 = QtGui.QLabel(self.centralwidget)
        self.label_3.setGeometry(QtCore.QRect(30, 180, 67, 17))
        self.label_3.setText(QtGui.QApplication.translate("MainWindow", "md5 :", None, QtGui.QApplication.UnicodeUTF8))
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.label_4 = QtGui.QLabel(self.centralwidget)
        self.label_4.setGeometry(QtCore.QRect(480, 20, 67, 17))
        self.label_4.setText(QtGui.QApplication.translate("MainWindow", "console :", None, QtGui.QApplication.UnicodeUTF8))
        self.label_4.setObjectName(_fromUtf8("label_4"))
        self.statue = QtGui.QLabel(self.centralwidget)
        self.statue.setGeometry(QtCore.QRect(30, 280, 411, 51))
        self.statue.setText(_fromUtf8(""))
        self.statue.setObjectName(_fromUtf8("statue"))
        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        QtCore.QObject.connect(self.quit, QtCore.SIGNAL(_fromUtf8("clicked()")), MainWindow.close)
        QtCore.QObject.connect(self.clear, QtCore.SIGNAL(_fromUtf8("clicked()")), clearcons)
        QtCore.QObject.connect(self.generate, QtCore.SIGNAL(_fromUtf8("clicked()")), main)
        QtCore.QObject.connect(self.tomd5, QtCore.SIGNAL(_fromUtf8("clicked()")), hasher)
        QtCore.QObject.connect(self.brute,  QtCore.SIGNAL(_fromUtf8("clicked()")), bruteattack)




        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        pass


app = QtGui.QApplication(sys.argv)
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())

still having the same error
is the wrong from my way to connect signals??

guys? :|

hmmm well it is solved i'v found the error
i just insert the

QtCore.QThread.__init__(self)

in the init function in qthread class :)
thanx for nothing :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.