-
Notifications
You must be signed in to change notification settings - Fork 0
/
crow.py
417 lines (345 loc) · 18 KB
/
crow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
import sys
import subprocess
import os
import json
import requests
from PyQt6.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout,
QLabel, QLineEdit, QPushButton, QTextEdit, QFileDialog,
QCheckBox, QGroupBox, QFormLayout, QSpinBox, QMessageBox)
from PyQt6.QtCore import Qt, QThread, pyqtSignal
# Import the separate save and load functions
from save_settings import save_settings
from load_settings import load_settings
from build_blackbird_command import build_blackbird_command
# Worker class that handles executing the Blackbird command in a separate thread
class BlackbirdWorker(QThread):
# Signal to send output to the main thread
output_signal = pyqtSignal(str)
def __init__(self, command):
# Initialize with the command to run
super().__init__()
self.command = command
self.process = None
def run(self):
# Run the command using subprocess and capture output
self.process = subprocess.Popen(self.command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, shell=True)
for line in self.process.stdout:
# Emit output line by line to update the UI
self.output_signal.emit(line.strip())
self.process.wait()
def terminate(self):
# Terminate the process if it's running
if self.process:
self.process.terminate()
self.process.wait()
# Main GUI class for the Blackbird OSINT tool
class BlackbirdGUI(QMainWindow):
def __init__(self):
super().__init__()
# Set window properties
self.setWindowTitle("Crow")
self.setGeometry(100, 100, 1000, 800)
self.worker = None
# Create the central widget and layout for the main window
central_widget = QWidget()
self.setCentralWidget(central_widget)
layout = QVBoxLayout()
central_widget.setLayout(layout)
# Adding Hudson Rock section for email/username search
hudson_group = QGroupBox("Hudson Rock Search")
hudson_layout = QVBoxLayout()
self.hudson_email_input = QLineEdit()
hudson_layout.addWidget(QLabel("Email to Search:"))
hudson_layout.addWidget(self.hudson_email_input)
self.hudson_search_button = QPushButton("Search Hudson Rock")
self.hudson_search_button.clicked.connect(self.search_hudson_rock)
hudson_layout.addWidget(self.hudson_search_button)
hudson_group.setLayout(hudson_layout)
layout.addWidget(hudson_group)
# Input Group: For entering usernames, emails, and file selection
input_group = QGroupBox("Blackbird Search")
input_layout = QFormLayout()
self.username_input = QLineEdit()
input_layout.addRow("Username(s):", self.username_input)
self.email_input = QLineEdit()
input_layout.addRow("Email(s):", self.email_input)
# File inputs for usernames and emails
self.username_file_input = QLineEdit()
username_file_button = QPushButton("Select Username File")
username_file_button.clicked.connect(self.select_username_file)
username_file_layout = QHBoxLayout()
username_file_layout.addWidget(self.username_file_input)
username_file_layout.addWidget(username_file_button)
input_layout.addRow("Username File:", username_file_layout)
self.email_file_input = QLineEdit()
email_file_button = QPushButton("Select Email File")
email_file_button.clicked.connect(self.select_email_file)
email_file_layout = QHBoxLayout()
email_file_layout.addWidget(self.email_file_input)
email_file_layout.addWidget(email_file_button)
input_layout.addRow("Email File:", email_file_layout)
input_group.setLayout(input_layout)
layout.addWidget(input_group)
# Options Group: Various checkboxes for additional configuration
options_group = QGroupBox("Options")
options_layout = QVBoxLayout()
AI_layout = QHBoxLayout()
self.AI_checkbox = QCheckBox("Extract metadata AI")
AI_layout.addWidget(self.AI_checkbox)
AI_help_button = QPushButton("?")
AI_help_button.setFixedSize(30, 30)
AI_help_button.clicked.connect(self.show_AI_help)
AI_layout.addWidget(AI_help_button)
options_layout.addLayout(AI_layout)
# Permute username checkbox with help button on the right
permute_layout = QHBoxLayout()
self.permute_checkbox = QCheckBox("Permute username")
permute_layout.addWidget(self.permute_checkbox)
permute_help_button = QPushButton("?")
permute_help_button.setFixedSize(30, 30)
permute_help_button.clicked.connect(self.show_permute_help)
permute_layout.addWidget(permute_help_button)
options_layout.addLayout(permute_layout)
# Permute all elements checkbox with help button on the right
permuteall_layout = QHBoxLayout()
self.permuteall_checkbox = QCheckBox("Permute all")
permuteall_layout.addWidget(self.permuteall_checkbox)
permuteall_help_button = QPushButton("?")
permuteall_help_button.setFixedSize(30, 30)
permuteall_help_button.clicked.connect(self.show_permuteall_help)
permuteall_layout.addWidget(permuteall_help_button)
options_layout.addLayout(permuteall_layout)
self.no_nsfw_checkbox = QCheckBox("Exclude NSFW sites")
options_layout.addWidget(self.no_nsfw_checkbox)
# Proxy input
proxy_layout = QHBoxLayout()
proxy_layout.addWidget(QLabel("Proxy:"))
self.proxy_input = QLineEdit()
proxy_layout.addWidget(self.proxy_input)
options_layout.addLayout(proxy_layout)
# Timeout input with spinner for seconds
timeout_layout = QHBoxLayout()
timeout_layout.addWidget(QLabel("Timeout (seconds):"))
self.timeout_spinbox = QSpinBox()
self.timeout_spinbox.setRange(1, 300) # Limit timeout to 1-300 seconds
self.timeout_spinbox.setValue(30) # Default timeout is 30 seconds
timeout_layout.addWidget(self.timeout_spinbox)
options_layout.addLayout(timeout_layout)
# Checkbox to disable update checks
self.no_update_checkbox = QCheckBox("Don't check for updates")
options_layout.addWidget(self.no_update_checkbox)
# Filter input field with a help button
filter_layout = QHBoxLayout()
filter_layout.addWidget(QLabel("Filter:"))
self.filter_input = QLineEdit()
filter_layout.addWidget(self.filter_input)
# Create a help button and connect it to the help function
filter_help_button = QPushButton("?")
filter_help_button.clicked.connect(self.show_filter_help) # Connect the button to the help function
filter_layout.addWidget(filter_help_button)
options_layout.addLayout(filter_layout)
options_group.setLayout(options_layout)
layout.addWidget(options_group)
# Output Options Group: Allows user to specify output types
output_group = QGroupBox("Output Options")
output_layout = QHBoxLayout()
self.csv_checkbox = QCheckBox("CSV (Results)")
self.pdf_checkbox = QCheckBox("PDF (Results)")
self.verbose_checkbox = QCheckBox("Verbose (LOGS)")
self.dump_checkbox = QCheckBox("Dump HTML (Results)")
output_layout.addWidget(self.csv_checkbox)
output_layout.addWidget(self.pdf_checkbox)
output_layout.addWidget(self.verbose_checkbox)
output_layout.addWidget(self.dump_checkbox)
output_group.setLayout(output_layout)
layout.addWidget(output_group)
# Instagram session ID input for enhanced metadata extraction
instagram_group = QGroupBox("Instagram Enhanced Metadata")
instagram_layout = QHBoxLayout()
self.instagram_session_id = QLineEdit()
instagram_layout.addWidget(QLabel("Instagram Session ID:"))
instagram_layout.addWidget(self.instagram_session_id)
instagram_help_button = QPushButton("?")
instagram_help_button.clicked.connect(self.show_instagram_help) # Show help on click
instagram_layout.addWidget(instagram_help_button)
instagram_group.setLayout(instagram_layout)
layout.addWidget(instagram_group)
button_layout = QHBoxLayout()
# Save and Load buttons connected to the functions
save_button = QPushButton("Save Settings")
save_button.clicked.connect(self.save_settings)
button_layout.addWidget(save_button)
load_button = QPushButton("Load Settings")
load_button.clicked.connect(self.load_settings)
button_layout.addWidget(load_button)
# Add the button layout to the main layout
layout.addLayout(button_layout)
# Run and Stop buttons
button_layout = QHBoxLayout()
self.run_button = QPushButton("Run Blackbird")
self.run_button.clicked.connect(self.run_blackbird) # Start Blackbird on click
button_layout.addWidget(self.run_button)
self.stop_button = QPushButton("Stop Blackbird")
self.stop_button.clicked.connect(self.stop_blackbird) # Stop Blackbird on click
self.stop_button.setEnabled(False) # Disable initially
button_layout.addWidget(self.stop_button)
layout.addLayout(button_layout)
# Output area for displaying logs and results
self.output_area = QTextEdit()
self.output_area.setReadOnly(True)
layout.addWidget(self.output_area)
# Easter egg setup
self.key_sequence = ""
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
def keyPressEvent(self, event):
super().keyPressEvent(event)
self.key_sequence += event.text()
if 'iddqd' in self.key_sequence.lower():
self.trigger_easter_egg()
self.key_sequence = ''
if len(self.key_sequence) > 10:
self.key_sequence = self.key_sequence[-10:]
def trigger_easter_egg(self):
easter_egg = """
Crows mimic, crows are intelligent!
"""
self.output_area.append("Easter egg activated!")
self.output_area.append(easter_egg)
def select_username_file(self):
# Open a file dialog to select a username file and set its path in the input field
file_name, _ = QFileDialog.getOpenFileName(self, "Select Username File")
if file_name:
self.username_file_input.setText(file_name)
def select_email_file(self):
# Open a file dialog to select an email file and set its path in the input field
file_name, _ = QFileDialog.getOpenFileName(self, "Select Email File")
if file_name:
self.email_file_input.setText(file_name)
def search_hudson_rock(self):
self.output_area.clear()
query = self.hudson_email_input.text().strip()
if not query:
self.update_output("Please enter an email to search.\n")
return
# We assume the query could be either an email or username, so we check it
if "@" in query:
query_type = "email"
else:
self.update_output("Invalid email address. Please enter a valid email.\n")
return
base_url = "https://cavalier.hudsonrock.com/api/json/v2/osint-tools/"
endpoint = f"search-by-email?email={query}"
url = base_url + endpoint
try:
response = requests.get(url)
response.raise_for_status()
data = response.json()
self.update_output(json.dumps(data, indent=2))
except requests.exceptions.RequestException as e:
self.update_output(f"An error occurred: {e}")
def save_settings(self):
# Use the modular save_settings function
save_settings(self)
def load_settings(self):
# Use the modular load_settings function
load_settings(self)
def show_instagram_help(self):
QMessageBox.information(self, "Instagram Session ID Help",
"To use enhanced Instagram metadata extraction:\n\n"
"1. Log in to Instagram in your browser\n"
"2. Open developer tools (F12)\n"
"3. Go to Application > Cookies\n"
"4. Find the 'sessionid' cookie\n"
"5. Copy its value and paste it here")
def show_filter_help(self):
QMessageBox.information(self, "Filter Help",
"Create custom search filters using specific properties and operators.\n\n"
"Properties: name, cat, uri_check, e_code, e_string, m_string, m_code\n"
"Operators: =, ~, >, <, >=, <=, !=\n\n"
"Examples:\n"
"1. name~Mastodon\n"
"2. e_code>200\n"
"3. cat=social and uri_check~101010\n"
"4. e_string=@101010.pl or m_code<=404\n\n"
"Concatenate commands with \"\" for multiple filters.")
def show_permute_help(self):
QMessageBox.information(self, "Permute Username Help",
"The '--permute' option generates variations of a username.\n\n"
"For 'balestek86', permutations include:\n"
"balestek86, _balestek86, balestek86_, balestek_86, balestek-86, balestek.86\n"
"86balestek, _86balestek, 86balestek_, 86_balestek, 86-balestek, 86.balestek")
def show_permuteall_help(self):
QMessageBox.information(self, "Permute All Elements Help",
"The '--permuteall' option generates a broader set of permutations.\n\n"
"For 'balestek86', permutations include:\n"
"balestek, _balestek, balestek_, 86, _86, 86_,\n"
"balestek86, _balestek86, balestek86_, balestek_86, balestek-86, balestek.86,\n"
"86balestek, _86balestek, 86balestek_, 86_balestek, 86-balestek, 86.balestek")
def show_AI_help(self):
QMessageBox.information(self, "AI Metadata Help",
"The '--ai' option extracts metadata using AI.\n\n"
"For 'balestek86', results will be marked with a robot emoji (🤖).\n"
"Note: AI results may be inaccurate, so use your own judgment.")
def run_blackbird(self):
# Ensure any previous worker is stopped before starting a new one
if self.worker and self.worker.isRunning():
self.worker.terminate()
self.worker.wait()
# Get the necessary input values from the GUI
username_input = self.username_input.text()
email_input = self.email_input.text()
username_file_input = self.username_file_input.text()
email_file_input = self.email_file_input.text()
permute_checkbox = self.permute_checkbox.isChecked()
permuteall_checkbox = self.permuteall_checkbox.isChecked()
AI_checkbox = self.AI_checkbox.isChecked()
no_nsfw_checkbox = self.no_nsfw_checkbox.isChecked()
no_update_checkbox = self.no_update_checkbox.isChecked()
csv_checkbox = self.csv_checkbox.isChecked()
pdf_checkbox = self.pdf_checkbox.isChecked()
verbose_checkbox = self.verbose_checkbox.isChecked()
dump_checkbox = self.dump_checkbox.isChecked()
proxy_input = self.proxy_input.text()
timeout_spinbox = self.timeout_spinbox.value()
filter_input = self.filter_input.text()
instagram_session_id = self.instagram_session_id.text()
# Call the build_blackbird_command function to get the command
command = build_blackbird_command(username_input, email_input, username_file_input,
email_file_input, permute_checkbox, permuteall_checkbox,
AI_checkbox, no_nsfw_checkbox, no_update_checkbox,
csv_checkbox, pdf_checkbox, verbose_checkbox,
dump_checkbox, proxy_input, timeout_spinbox,
filter_input, instagram_session_id)
# Clear previous output and start the worker thread
self.output_area.clear()
self.worker = BlackbirdWorker(" ".join(command))
self.worker.output_signal.connect(self.update_output) # Connect output signal to update method
self.worker.finished.connect(self.on_worker_finished) # Handle when worker finishes
self.worker.start()
# Disable Run button and enable Stop button during execution
self.run_button.setEnabled(False)
self.stop_button.setEnabled(True)
def stop_blackbird(self):
# Stop the Blackbird process if running
if self.worker and self.worker.isRunning():
self.worker.terminate()
self.worker.wait()
self.run_button.setEnabled(True) # Re-enable Run button
self.stop_button.setEnabled(False) # Disable Stop button
def update_output(self, text):
# Update the output area with new text (logs/results)
scrollbar = self.output_area.verticalScrollBar()
was_at_bottom = scrollbar.value() == scrollbar.maximum()
self.output_area.append(text)
if was_at_bottom:
scrollbar.setValue(scrollbar.maximum()) # Auto-scroll to the bottom
def on_worker_finished(self):
# Re-enable the Run button and disable the Stop button when worker finishes
self.run_button.setEnabled(True)
self.stop_button.setEnabled(False)
if __name__ == "__main__":
# Create and run the application
app = QApplication(sys.argv)
window = BlackbirdGUI()
window.show()
sys.exit(app.exec())