-
Notifications
You must be signed in to change notification settings - Fork 0
/
miso.txt
289 lines (250 loc) · 11.1 KB
/
miso.txt
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
import sys
import hashlib
import os
from PyQt5.QtWidgets import (
QApplication, QWidget, QLabel, QLineEdit, QPushButton, QFileDialog, QMessageBox,
QVBoxLayout, QProgressBar, QDialog, QHBoxLayout
)
from PyQt5.QtCore import Qt, QPropertyAnimation, QRect
from PyQt5.QtGui import QPixmap, QIcon
class HashChecker(QWidget):
def __init__(self):
super().__init__()
self.app_data_dir = self.get_app_data_dir()
# Ensure app data directory exists
if not os.path.exists(self.app_data_dir):
os.makedirs(self.app_data_dir)
self.init_ui()
self.last_used_files = {"iso": "", "md5_sha256": ""}
self.matching_hash = None
def init_ui(self):
self.setWindowTitle("MISO Hash ISO Doğrulayıcı")
self.setFixedSize(600, 500) # Increased size to accommodate all elements
self.setStyleSheet(self.load_styles())
# Set window icon
icon_path = self.get_icon_path()
if icon_path:
self.setWindowIcon(QIcon(icon_path))
# Main layout
main_layout = QVBoxLayout()
# Logo
logo_label = QLabel(self)
logo_path = self.get_logo_path()
if logo_path and os.path.exists(logo_path):
logo_pixmap = QPixmap(logo_path)
if not logo_pixmap.isNull():
scaled_logo = logo_pixmap.scaled(150, 150, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation)
logo_label.setPixmap(scaled_logo)
logo_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
else:
logo_label.setText("Logo Yüklenemedi")
else:
logo_label.setText("Logo Bulunamadı!")
main_layout.addWidget(logo_label)
# ISO File Selection
iso_layout = QHBoxLayout()
self.label_iso = QLabel("ISO:")
self.line_edit_iso = QLineEdit()
self.line_edit_iso.setPlaceholderText("ISO dosyasını seçin")
self.line_edit_iso.setReadOnly(True)
self.button_browse_iso = QPushButton("Gözat")
iso_layout.addWidget(self.label_iso)
iso_layout.addWidget(self.line_edit_iso)
iso_layout.addWidget(self.button_browse_iso)
main_layout.addLayout(iso_layout)
# Hash File Selection
hash_layout = QHBoxLayout()
self.label_md5_sha256 = QLabel("Hash:")
self.line_edit_md5_sha256_file = QLineEdit()
self.line_edit_md5_sha256_file.setPlaceholderText("MD5/SHA-256 dosyasını seçin")
self.line_edit_md5_sha256_file.setReadOnly(True)
self.button_browse_md5_sha256 = QPushButton("Gözat")
hash_layout.addWidget(self.label_md5_sha256)
hash_layout.addWidget(self.line_edit_md5_sha256_file)
hash_layout.addWidget(self.button_browse_md5_sha256)
main_layout.addLayout(hash_layout)
# Check Button
self.button_check = QPushButton("Hash Kontrol Et")
main_layout.addWidget(self.button_check)
# Progress Bar
self.progress_bar = QProgressBar(self)
self.progress_bar.setRange(0, 100)
self.progress_bar.setValue(0)
self.progress_bar.setTextVisible(True)
main_layout.addWidget(self.progress_bar)
# Matching Hash Label
self.label_matching_hash = QLabel("Eşleşen hash değeri: -")
self.label_matching_hash.setWordWrap(True)
main_layout.addWidget(self.label_matching_hash)
# About Button
self.button_about = QPushButton("Hakkında")
main_layout.addWidget(self.button_about)
# Set the main layout
self.setLayout(main_layout)
# Connect signals
self.button_browse_iso.clicked.connect(self.browse_iso_file)
self.button_browse_md5_sha256.clicked.connect(self.browse_md5_sha256_file)
self.button_check.clicked.connect(self.check_hash)
self.button_about.clicked.connect(self.show_about)
# Add click event to matching hash label
self.label_matching_hash.mousePressEvent = self.copy_hash_on_click
def load_styles(self):
return """
QWidget {
background-color: #1f1f1f;
font-family: Arial, sans-serif;
color: white;
}
QLabel {
color: white;
font-size: 14px;
}
QLineEdit {
padding: 5px;
border-radius: 10px;
background-color: #333;
color: white;
border: 1px solid #555;
}
QPushButton {
background-color: #cca206;
color: white;
border: none;
border-radius: 12px;
padding: 10px;
font-size: 14px;
}
QPushButton:hover {
background-color: #ffcb08;
}
QProgressBar {
height: 20px;
border-radius: 10px;
background-color: #444;
}
QProgressBar::chunk {
background-color: #cca206;
border-radius: 10px;
}
"""
def get_app_data_dir(self):
"""Return user data directory based on platform."""
if sys.platform == "win32":
home = os.getenv("USERPROFILE", os.path.expanduser("~"))
return os.path.join(home, "AppData", "Local", "MISO")
elif sys.platform == "darwin":
home = os.getenv("HOME", os.path.expanduser("~"))
return os.path.join(home, "Library", "Application Support", "MISO")
else:
home = os.getenv("HOME", os.path.expanduser("~"))
return os.path.join(home, ".local", "share", "MISO")
def get_logo_path(self):
"""Return logo file path."""
possible_paths = [
getattr(sys, '_MEIPASS', None) and os.path.join(sys._MEIPASS, "misolo.png"),
os.path.join(os.path.dirname(__file__), "misolo.png"),
"/usr/share/icons/hicolor/48x48/apps/misolo.png",
"misolo.png"
]
for path in possible_paths:
if path and os.path.exists(path):
return path
return None
def get_icon_path(self):
"""Return icon file path."""
possible_paths = [
getattr(sys, '_MEIPASS', None) and os.path.join(sys._MEIPASS, "misolo.png"),
os.path.join(os.path.dirname(__file__), "misolo.png"),
"/usr/share/icons/hicolor/48x48/apps/misolo.png",
"misolo.png"
]
for path in possible_paths:
if path and os.path.exists(path):
return path
return None
def browse_iso_file(self):
self.progress_bar.setValue(0)
self.label_matching_hash.setText("Eşleşen hash değeri: -")
file_path, _ = QFileDialog.getOpenFileName(self, "ISO Dosyasını Seçin", self.last_used_files.get("iso", ""), "ISO Files (*.iso)")
if file_path:
self.line_edit_iso.setText(file_path)
self.last_used_files["iso"] = file_path
def browse_md5_sha256_file(self):
self.progress_bar.setValue(0)
self.label_matching_hash.setText("Eşleşen hash değeri: -")
file_path, _ = QFileDialog.getOpenFileName(self, "MD5 veya SHA-256 Dosyasını Seçin", self.last_used_files.get("md5_sha256", ""), "Tüm Dosyalar (*)")
if file_path:
self.line_edit_md5_sha256_file.setText(file_path)
self.last_used_files["md5_sha256"] = file_path
def check_hash(self):
iso_path = self.line_edit_iso.text()
md5_sha256_file_path = self.line_edit_md5_sha256_file.text()
if not iso_path or not md5_sha256_file_path:
QMessageBox.warning(self, "Eksik Bilgi", "Lütfen ISO ve MD5/SHA-256 dosyasını seçin.")
return
try:
# Check every line in the hash file
with open(md5_sha256_file_path, 'r') as f:
hash_lines = f.readlines()
# Calculate ISO file hash
iso_hash_md5 = self.calculate_hash(iso_path, "md5")
iso_hash_sha256 = self.calculate_hash(iso_path, "sha256")
# Compare hash values
match_found = False
matching_hash = ""
for line in hash_lines:
expected_hash = line.split()[0].strip()
if expected_hash == iso_hash_md5 or expected_hash == iso_hash_sha256:
match_found = True
matching_hash = expected_hash
break
if match_found:
self.label_matching_hash.setText(f"Eşleşen hash değeri: {matching_hash}")
self.label_matching_hash.setStyleSheet("color: #32CD32; font-weight: bold;")
self.matching_hash = matching_hash
else:
self.label_matching_hash.setText("Eşleşen hash değeri bulunamadı.")
self.label_matching_hash.setStyleSheet("color: #FF6347; font-weight: bold;")
except Exception as e:
QMessageBox.warning(self, "Hata", f"Bir hata oluştu: {e}")
def calculate_hash(self, file_path, hash_type="md5", chunk_size=8192):
hash_func = hashlib.md5() if hash_type == "md5" else hashlib.sha256()
total_size = os.path.getsize(file_path)
try:
with open(file_path, 'rb') as f:
bytes_read = 0
while chunk := f.read(chunk_size):
hash_func.update(chunk)
bytes_read += len(chunk)
percent_done = int((bytes_read / total_size) * 100)
self.progress_bar.setValue(percent_done)
return hash_func.hexdigest()
except Exception as e:
QMessageBox.warning(self, "Hata", f"Dosya okuma hatası: {e}")
return ""
def copy_hash_on_click(self, event):
"""Copy matching hash value to clipboard."""
if self.matching_hash:
clipboard = QApplication.clipboard()
clipboard.setText(self.matching_hash)
QMessageBox.information(self, "Hash Kopyalandı", "Eşleşen hash değeri panoya kopyalandı.")
def show_about(self):
"""Show about dialog."""
about_text = (
"M-ISO Hash Uygulaması\n\n"
"Hash hesaplama, ISO doğrulama uygulaması.\n\n"
"Geliştirici: ALG Yazılım Inc.©\n"
"www.algyazilim.com | [email protected]\n\n"
"Fatih ÖNDER (CekToR) | [email protected]\n"
"GitHub: https://github.com/cektor\n\n"
"ALG Yazılım Pardus'a Göç'ü Destekler.\n\n"
"Sürüm: 1.0"
)
QMessageBox.about(self, "Hakkında", about_text)
def main():
app = QApplication(sys.argv)
window = HashChecker()
window.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()