├── AntiVirus-GUI_ENG.py ├── README.md ├── SystemFileScanner.py └── quarantaene.py /AntiVirus-GUI_ENG.py: -------------------------------------------------------------------------------- 1 | #Official script by n00nY 2 | 3 | from threading import * 4 | from tkinter import * 5 | from tkinter.filedialog import askopenfilename 6 | from tkinter.messagebox import showerror 7 | import tkinter, tkinter.scrolledtext 8 | import threading 9 | import os 10 | import sys 11 | import urllib.request 12 | import glob 13 | import time 14 | import hashlib 15 | import socket 16 | import subprocess 17 | #self-made 18 | import quarantaene 19 | import SystemFileScanner 20 | 21 | os_name = sys.platform 22 | verzeichnisse = [] 23 | files = [] 24 | partitionen = [] 25 | terminations = [] 26 | 27 | 28 | if "win" in os_name: 29 | if not os.path.exists("AntiVirus\\Quarantine\\"): 30 | os.makedirs("AntiVirus\\Quarantine\\") 31 | if not os.path.exists("AntiVirus\\sf\\"): 32 | os.makedirs("AntiVirus\\sf\\") 33 | if not os.path.exists("AntiVirus\\Large_Update_File\\"): 34 | os.makedirs("AntiVirus\\Large_Update_File") 35 | quarantine_folder = "AntiVirus\\Quarantine\\*" 36 | file_to_quarantine = "AntiVirus\\Quarantine\\" 37 | partitionen_folder = "AntiVirus\\sf\\sf.txt" 38 | links_current = "AntiVirus\\Large_Update_File\\links_current.txt" 39 | links_downloaded = "AntiVirus\\Large_Update_File\\links_downloaded.txt" 40 | large_signatures = "AntiVirus\\Large_Update_File\\signatures.txt" 41 | f = open(partitionen_folder, "a") 42 | f.close() 43 | f = open(links_current, "a") 44 | f.close() 45 | f = open(links_downloaded, "a") 46 | f.close() 47 | f = open(large_signatures, "a") 48 | f.close() 49 | else: 50 | if not os.path.exists("AntiVirus//Quarantine//"): 51 | os.makedirs("AntiVirus//Quarantine//") 52 | if not os.path.exists("AntiVirus//sf//"): 53 | os.makedirs("AntiVirus//sf//") 54 | if not os.path.exists("AntiVirus//Large_Update_File//"): 55 | os.makedirs("AntiVirus//Large_Update_File//") 56 | quarantine_folder = "AntiVirus//Quarantine//*" 57 | file_to_quarantine = "AntiVirus//Quarantine//" 58 | partitionen_folder = "AntiVirus//sf//sf.txt" 59 | links_current = "AntiVirus//Large_Update_File//links_current.txt" 60 | links_downloaded = "AntiVirus//Large_Update_File//links_downloaded.txt" 61 | large_signatures = "AntiVirus//arge_Update_File//signatures.txt" 62 | f = open(partitionen_folder, "a") 63 | f.close() 64 | f = open(links_current, "a") 65 | f.close() 66 | f = open(links_downloaded, "a") 67 | f.close() 68 | f = open(large_signatures, "a") 69 | f.close() 70 | 71 | files_len = counter = 0 72 | main = None 73 | update_button = None 74 | scan_button = None 75 | fullscan_button = None 76 | quit_button = None 77 | b_delete = None 78 | b_delete_all = None 79 | b_restore = None 80 | b_restore_all = None 81 | b_add_file = None 82 | text_box = None 83 | e = None 84 | li = None 85 | rb1 = None 86 | rb2 = None 87 | method = None 88 | bgc = None 89 | fgc = None 90 | special = None 91 | special_text = None 92 | t_time = None 93 | 94 | daytime = int(time.strftime("%H", time.localtime())) 95 | 96 | #Adjusting the brightness for the current day_time 97 | #It's totally unnecessary but I wanted to play around a little 98 | if daytime >= 18 or daytime <= 4: 99 | bgc = "black" 100 | fgc = "white" 101 | special = "brown" 102 | special_text = "(°_°)☽ ☆ Good evening " + os.getlogin() + " ☆ ☾(°_°)\n" 103 | elif daytime > 4 and daytime <= 8: 104 | special_text = "\(o ̄∇ ̄o)/ Good morning " + os.getlogin() + " \(o ̄∇ ̄o)/\n" 105 | bgc = "#b4d60c" 106 | fgc = "black" 107 | special = "orange" 108 | else: 109 | bgc = "white" 110 | fgc = "black" 111 | special = "#1ccaed" 112 | special_text = "\(≧∇≦)/ Welcome " + os.getlogin() + " \(≧∇≦)/\n" 113 | 114 | def clock_thread(): 115 | global e 116 | 117 | months = ["January", "February", "March", "April", "May", "June", "Juli", "August", "September", "October", "November", "December"] 118 | while True: 119 | string_time = "%H:%M:%S o'clock, on %d.{0}.%Y" 120 | month_name = time.strftime("%B", time.localtime()) 121 | for i in range(len(months)): 122 | if months[i] == month_name: 123 | month_name = str(i+1) 124 | if int(month_name) < 10: 125 | month_name = "0" + month_name 126 | break 127 | string_time = string_time.format(month_name) 128 | current_time = time.strftime(string_time, time.localtime()) 129 | e.delete(0, len(e.get())) 130 | e.update() 131 | e.insert(0, current_time) 132 | e.update() 133 | time.sleep(1) 134 | 135 | def ScanSystemFiles(): 136 | global files 137 | global text_box 138 | global files_len 139 | 140 | text_box.insert(END, "[ * ] Scanning system for files...\n") 141 | text_box.see(END) 142 | text_box.update() 143 | time.sleep(3) 144 | text_box.see(END) 145 | text_box.update() 146 | SystemFileScanner.partitions(partitionen_folder) 147 | f = open(partitionen_folder, "r") 148 | content = f.read() 149 | f.close() 150 | content = content.splitlines() 151 | files = content 152 | files_len = len(files) 153 | text_box.insert(END, "[ + ] System successfully prepared\n", 'positive') 154 | text_box.tag_config("positive", foreground="green") 155 | text_box.see(END) 156 | text_box.update() 157 | 158 | def full_scan(part): 159 | global verzeichnisse 160 | global files 161 | global text_box 162 | global e 163 | global full_scan 164 | global files_len 165 | global lock 166 | global t_time 167 | global counter 168 | 169 | if part == 1:#Thread-1 170 | i = int(len(files)*0.125) 171 | tmp = 0 172 | if part == 2:#Thread-2 173 | i = int(len(files)*0.25) 174 | tmp = int(len(files)*0.125) 175 | if part == 3:#Thread-3 176 | i = int(len(files)*0.375) 177 | tmp = int(len(files)*0.25) 178 | if part == 4:#Thread-4 179 | i = int(len(files)*0.5) 180 | tmp = int(len(files)*0.375) 181 | if part == 5:#Thread-5 182 | i = int(len(files)*0.625) 183 | tmp = int(len(files)*0.5) 184 | if part == 6:#Thread-6 185 | i = int(len(files)*0.75) 186 | tmp = int(len(files)*0.625) 187 | if part == 7:#Thread-7 188 | i = int(len(files)*0.875) 189 | tmp = int(len(files)*0.75) 190 | if part == 8:#Thread-8 191 | i = int(len(files)) 192 | tmp = int(len(files)*0.875) 193 | 194 | if len(files) == 0: 195 | return ScanSystemFiles() 196 | 197 | text_box.tag_config('positive', foreground="green") 198 | text_box.see(END) 199 | text_box.update() 200 | counter = 0 201 | st = 0 202 | while i >= tmp: 203 | try: 204 | f = open(files[i], "rb") 205 | file_content = f.read() 206 | f.close() 207 | except: 208 | continue 209 | ret = scan_auto(files[i]) 210 | if ret == True: 211 | text_box.insert(END, "[ ! ] Program: " + files[i] + " might be dangerous\n", "important") 212 | text_box.tag_config("important", foreground="red") 213 | text_box.see(END) 214 | text_box.update() 215 | quarantaene.encode_base64(files[i]) 216 | files_len -= 1 217 | i -= 1 218 | runtime = int(time.time() - start) 219 | text_box.insert(END, "[ + ] Scan ended after\n " + str(runtime/60) + " minutes.\n", "positive") 220 | text_box.tag_config("positive", foreground="green") 221 | if files_len == 0: 222 | full_scan["state"] = "normal" 223 | if len(terminations) == 0: 224 | text_box.insert(END, "[ +++ ] Your PC is safe" + "\n", 'important') 225 | else: 226 | text_box.insert(END, "[ !!! ] Found {0} Threats on your PC\n".format(len(terminations))) 227 | text_box.tag_config("important", background="red") 228 | text_box.see(END) 229 | text_box.update() 230 | 231 | def quarantine(): 232 | global text_box 233 | global terminations 234 | global li 235 | global b_delete 236 | global b_delete_all 237 | global b_restore 238 | global b_restore_all 239 | global b_add_file 240 | 241 | 242 | k = 0 243 | while True: 244 | tmp = len(li.get(k)) 245 | if tmp == 0: 246 | break 247 | else: 248 | li.delete(0, tmp) 249 | k += 1 250 | li.update() 251 | 252 | 253 | terminations = glob.glob(quarantine_folder) 254 | if terminations == []: 255 | text_box.insert(END, "[ + ] No files in quarantine\n", "positive") 256 | text_box.tag_config('positive', foreground="green") 257 | text_box.see(END) 258 | text_box.update() 259 | else: 260 | text_box.insert(END, "[ + ] Files in quarantine:\n", "positive") 261 | text_box.tag_config('positive', foreground="green") 262 | text_box.see(END) 263 | text_box.update() 264 | for i in terminations: 265 | text_box.insert(END, "[ * ] " + i + "\n", "info") 266 | text_box.tag_config("info", background = "red") 267 | text_box.see(END) 268 | text_box.update() 269 | li.insert(END, i) 270 | li.update() 271 | 272 | b_delete_all["command"] =lambda:button_action_handler("delete_all") 273 | b_delete["command"] = lambda:button_action_handler("delete") 274 | b_restore["command"] = lambda:button_action_handler("restore") 275 | b_restore_all["command"] = lambda:button_action_handler("restore_all") 276 | b_add_file["command"] = lambda:button_action_handler("add_file") 277 | 278 | 279 | def delete(file, ALL):#ALL = 1 => deletes all objects in quarantine 280 | global li 281 | global text_box 282 | global terminations 283 | 284 | if len(terminations) != 0: 285 | if ALL == 1: 286 | for i in range(len(terminations)): 287 | os.remove(terminations[i]) 288 | text_box.insert(END, "[ + ] Deletion successful: \n" + terminations[i] + "\n", "positive") 289 | text_box.tag_config("positive", foreground="green") 290 | text_box.see(END) 291 | text_box.update() 292 | li.delete(0, len(terminations[i])) 293 | li.update() 294 | elif ALL == 0: 295 | os.remove(file) 296 | li.delete(ACTIVE, len(file)) 297 | li.update() 298 | text_box.insert(END, "[ + ] Deletion successful:\n" + file + "\n", "positive") 299 | text_box.tag_config("positive", foreground="green") 300 | text_box.see(END) 301 | text_box.update() 302 | 303 | terminations = glob.glob(quarantine_folder) 304 | for i in terminations: 305 | li.insert(END, i) 306 | li.update() 307 | else: 308 | text_box.insert(END, "[ - ] Unable to locate any files\n", "negative") 309 | text_box.tag_config("negative", foreground="red") 310 | text_box.see(END) 311 | text_box.update() 312 | 313 | def restore(file, ALL): 314 | global li 315 | global text_box 316 | global terminations 317 | 318 | if len(terminations) != 0: 319 | if ALL == 1: 320 | for i in range(len(terminations)): 321 | quarantaene.decode_base64(terminations[i]) 322 | text_box.insert(END, "[ + ] Successfully restored\n" + terminations[i] + "\n", 'positive') 323 | text_box.tag_config('positive', foreground="green") 324 | text_box.see(END) 325 | text_box.update() 326 | li.delete(0, len(terminations[i])) 327 | li.update() 328 | elif ALL == 0: 329 | quarantaene.decode_base64(file) 330 | li.delete(ACTIVE, len(file)) 331 | text_box.insert(END, "[ + ] Successfully restored\n" + file + "\n", "positive") 332 | text_box.tag_config("positive", foreground="green") 333 | text_box.see(END) 334 | text_box.update() 335 | 336 | terminations = glob.glob(quarantine_folder) 337 | for i in terminations: 338 | li.insert(END, i) 339 | li.update() 340 | 341 | else: 342 | text_box.insert(END, "[ - ] Unable to locate any files\n", "negative") 343 | text_box.tag_config("negative", foreground="red") 344 | text_box.see(END) 345 | text_box.update() 346 | 347 | 348 | def add_file_to_quarantine(): 349 | global li 350 | global terminations 351 | 352 | file = askopenfilename() 353 | file = file.replace("/", "\\") 354 | quarantaene.encode_base64(file, file_to_quarantine) 355 | text_box.insert(END, "[ + ] Moved to quarantine:\n" + file + "\n", "positive") 356 | text_box.tag_config("positive", foreground="green") 357 | text_box.see(END) 358 | text_box.update() 359 | li.update() 360 | 361 | k = 0 362 | while True: 363 | tmp = len(li.get(k)) 364 | if tmp == 0: 365 | break 366 | else: 367 | li.delete(0, tmp) 368 | k += 1 369 | li.update() 370 | 371 | terminations = glob.glob(quarantine_folder) 372 | for i in terminations: 373 | li.insert(END, i) 374 | li.update() 375 | 376 | def scan_auto(file): 377 | time.sleep(3) 378 | try: 379 | f = open(file, "rb") 380 | content = f.read() 381 | f.close() 382 | content = create_md5(content) 383 | except MemoryError: 384 | f.close() 385 | return False 386 | except: 387 | f.close() 388 | return False 389 | 390 | signatures = open(large_signatures, "rb") 391 | try: 392 | if content in signatures.read():#fastest solution 393 | signatures.close() 394 | return True 395 | else: 396 | signatures.close() 397 | return False 398 | except MemoryError: 399 | try: 400 | signatures.close() 401 | signatures = open(large_signatures, "rb") 402 | if content in signatures.readlines():#again fast, but around 4 times slower than the fastest 403 | signatures.close() 404 | return True 405 | else: 406 | signatures.close() 407 | return False 408 | except MemoryError: 409 | signatures.close() 410 | signatures = open(large_signatures, "rb") 411 | while True:#slowest solution, but can read files sized over 2 GB 412 | tmp = signatures.readline() 413 | if tmp == b"": 414 | signatures.close() 415 | break 416 | 417 | if tmp == content: 418 | signatures.close() 419 | return True 420 | return False 421 | except: 422 | return False 423 | 424 | def scan(): 425 | global text_box 426 | 427 | match = False 428 | file = askopenfilename() 429 | start = time.time() 430 | text_box.insert(END, "[ * ] Scanning " + file + "\n") 431 | text_box.see(END) 432 | text_box.update() 433 | try: 434 | f = open(file, "rb") 435 | content = f.read() 436 | f.close() 437 | content = create_md5(content) 438 | text_box.insert(END, "MD5-Hash: " + content.decode("utf-8") + "\n") 439 | text_box.see(END) 440 | text_box.update() 441 | except MemoryError: 442 | text_box.insert(END, "[ - ] Unable to create MD5-Hash:\n----->MemoryError!\n", 'negative') 443 | text_box.insert(END, "[ ! ] Only select files under 1 GB\n", "negative") 444 | text_box.tag_config('negative', foreground="red") 445 | text_box.see(END) 446 | text_box.update() 447 | return None 448 | except Exception as e: 449 | text_box.insert(END, "[ ! ] Unable to handle problem\n[ ! ] Try again/file might be corrupted\n", "negative") 450 | text_box.tag_config('negative', foreground="red") 451 | text_box.see(END) 452 | text_box.update() 453 | return None 454 | 455 | signatures = open(large_signatures, "rb") 456 | #runtime of a scan varies from system to system(time on the systems tested: 1s <= t <= 20s) 457 | try: 458 | if content in signatures.read():#fastest solution 459 | signatures.close() 460 | match = True 461 | else: 462 | match = False 463 | signatures.close() 464 | except MemoryError: 465 | try: 466 | signatures.close() 467 | signatures = open(large_signatures, "rb") 468 | if content in signatures.readlines():#again fast, but around 4 times slower than the fastest 469 | f.close() 470 | match = True 471 | else: 472 | signatures.close() 473 | match = False 474 | except MemoryError: 475 | signatures.close() 476 | signatures = open(large_signatures, "rb") 477 | while True:#slowest solution, but can read files sized over 2 GB 478 | tmp = signatures.readline() 479 | if tmp == b"": 480 | signatures.close() 481 | break 482 | if tmp == content: 483 | match = True 484 | signatures.close() 485 | except: 486 | text_box.insert(END, "[ - ] Something bad happened while performing the task\n", "negative") 487 | text_box.tag_config("negative", foreground="red") 488 | text_box.see(END) 489 | text_box.update() 490 | return None 491 | 492 | text_box.insert(END, "[ * ] Scan duration: {0}\n".format(round(time.time()-start, 2))) 493 | text_box.see(END) 494 | text_box.update() 495 | if match: 496 | quarantaene.encode_base64(file, file_to_quarantine) 497 | text_box.insert(END, "[ ! ] Threat found: {0}\n[ ! ] File was moved into quarantine", "important") 498 | text_box.tag_config("important", foreground="red") 499 | text_box.see(END) 500 | text_box.update() 501 | if not match: 502 | text_box.insert(END, "[ + ] No threat was found\n", "positive") 503 | text_box.tag_config("positive", foreground="green") 504 | text_box.see(END) 505 | text_box.update() 506 | 507 | def create_md5(content): 508 | md = hashlib.md5() 509 | md.update(content) 510 | return bytes(md.hexdigest(), "utf-8") 511 | 512 | def link_collector(): #gets Links to refresh update-site;short spider 513 | global text_box 514 | u_list = [] 515 | 516 | text_box.insert(END, "[ * ] Searching for update...\n") 517 | text_box.see(END) 518 | text_box.update() 519 | u = urllib.request.urlopen("http://virusshare.com/hashes").read().decode("utf-8").splitlines() 520 | f = open(links_current, "w") 521 | for i in u: 522 | if "href='" in i: 523 | first = i.find("href='") + len("href='") 524 | i = i[first:] 525 | last = i.find("'") 526 | i = i[:last] 527 | if 'href="' in i: 528 | first = i.find('href="') + len('href="') 529 | i = i[first:] 530 | last = i.find('"') 531 | i = i[:last] 532 | if "VirusShare" in i: 533 | f.write("http://virusshare.com/hashes/" + i + "\n") 534 | f.close() 535 | return update() 536 | 537 | def update(): 538 | global text_box 539 | 540 | zaehler = 0 541 | f = open(links_current, "r") 542 | f2 = open(links_downloaded, "r") 543 | files_downloaded = f2.read() 544 | f2.close() 545 | f2 = open(links_downloaded, "r") 546 | for i in f.read().splitlines(): 547 | f2 = open(links_downloaded, "r") 548 | con = f2.read() 549 | f2.close() 550 | f2 = open(links_downloaded, "a") 551 | if i not in con: 552 | zaehler += 1 553 | f2.write(i + "\n") 554 | f2.close() 555 | text_box.insert(END, "[ * ] Download of:\n"+i) 556 | text_box.see(END) 557 | text_box.update() 558 | signatures = open(large_signatures, "a") 559 | url = i 560 | tmp = urllib.request.urlopen(url).read().decode("utf-8").splitlines() 561 | for j in tmp: 562 | if j[0] != '#': 563 | signatures.write(j + "\n") 564 | signatures.close() 565 | if zaehler == 0: 566 | text_box.insert(END, "[ * ] No new updates were found\n") 567 | text_box.see(END) 568 | text_box.update() 569 | else: 570 | text_box.insert(END, "[ + ] {0} new updates were made\n".formate(zaehler), "positive") 571 | text_box.tag_config("positive", foreground="green") 572 | text_box.see(END) 573 | text_box.update() 574 | 575 | def closing(): 576 | main.destroy() 577 | sys.exit() 578 | 579 | def button_action_handler(s): 580 | global files_len 581 | global text_box 582 | global t_time 583 | global fullscan_button 584 | global b_delete 585 | global b_delete_all 586 | global b_restore 587 | global b_restore_all 588 | global b_add_file 589 | global li 590 | global rb1 591 | global rb2 592 | global method 593 | 594 | if s == "rb1": 595 | method = 1 596 | rb1.place_forget() 597 | rb2.place_forget() 598 | if s == "rb2": 599 | method = 2 600 | rb2.place_forget() 601 | rb1.place_forget() 602 | 603 | if s == "delete": 604 | tb = Thread(target=delete, args=(li.get(ACTIVE),0)) 605 | tb.start() 606 | if s == "delete_all": 607 | tb = Thread(target=delete, args=(0,1)) 608 | tb.start() 609 | if s == "restore": 610 | tb = Thread(target=restore, args=(li.get(ACTIVE),0)) 611 | tb.start() 612 | if s == "restore_all": 613 | tb = Thread(target=restore, args=(0,1)) 614 | tb.start() 615 | 616 | if s == "add_file": 617 | tb = Thread(target=add_file_to_quarantine) 618 | tb.start() 619 | 620 | if s == "update_button": 621 | tb = Thread(target=link_collector) 622 | tb.start() 623 | 624 | if s == "scan_button": 625 | tb = Thread(target=scan) 626 | tb.start() 627 | 628 | if s == "fullscan_button": 629 | if files_len == 0: 630 | text_box.insert(END, "[ ! ] Preparing program\n", "important") 631 | text_box.see(END) 632 | text_box.update() 633 | elif files_len < len(files): 634 | text_box.insert(END, "[ ! ] One scan is already in action\n", "important") 635 | text_box.see(END) 636 | text_box.update() 637 | else: 638 | fullscan_button["state"] = "disabled" 639 | t_time = time.time() 640 | text_box.insert(END, "[ ! ] Got {0} files to scan\n".format(files_len), 'important') 641 | text_box.tag_config("important", foreground="red") 642 | text_box.update() 643 | text_box.insert(END, "[ * ] Scan might last for hours...\n") 644 | text_box.see(END) 645 | text_box.update() 646 | tb1 = Thread(target=full_scan, args=(1,)) 647 | tb1.start() 648 | time.sleep(1) 649 | tb2 = Thread(target=full_scan, args=(2,)) 650 | tb2.start() 651 | time.sleep(1) 652 | tb3 = Thread(target=full_scan, args=(3,)) 653 | tb3.start() 654 | time.sleep(1) 655 | tb4 = Thread(target=full_scan, args=(4,)) 656 | tb4.start() 657 | time.sleep(1) 658 | tb5 = Thread(target=full_scan, args=(5,)) 659 | tb5.start() 660 | time.sleep(1) 661 | tb6 = Thread(target=full_scan, args=(6,)) 662 | tb6.start() 663 | time.sleep(1) 664 | tb7 = Thread(target=full_scan, args=(7,)) 665 | tb7.start() 666 | time.sleep(1) 667 | tb8 = Thread(target=full_scan, args=(8,)) 668 | tb8.start() 669 | 670 | if s == "quarantine_button": 671 | if li.winfo_viewable() == 0: 672 | b_delete.place(x = 570, y = 70) 673 | b_delete_all.place(x = 570, y = 95) 674 | b_restore.place(x = 570, y = 120) 675 | b_restore_all.place(x = 570, y = 145) 676 | b_add_file.place(x = 570, y = 170) 677 | li.place(x = 570, y = 18.5) 678 | tb = Thread(target=quarantine) 679 | tb.start() 680 | if li.winfo_viewable() == 1: 681 | b_delete.place_forget() 682 | b_delete_all.place_forget() 683 | b_restore.place_forget() 684 | b_restore_all.place_forget() 685 | b_add_file.place_forget() 686 | li.place_forget() 687 | 688 | if s == "quit_button": 689 | tb = Thread(target=closing) 690 | tb.start() 691 | 692 | def gui_thread(): 693 | global main 694 | global update_button 695 | global scan_button 696 | global fullscan_button 697 | global quit_button 698 | global text_box 699 | global e 700 | global files_len 701 | global files 702 | global li 703 | global b_delete 704 | global b_delete_all 705 | global b_restore 706 | global b_restore_all 707 | global b_add_file 708 | global rb1 709 | global rb2 710 | global method 711 | global bgc 712 | global fgc 713 | global special_text 714 | 715 | main = tkinter.Tk() 716 | main.title("AntiVirus") 717 | main.wm_iconbitmap("") 718 | main.configure(bg=bgc) 719 | main.geometry("750x205")#width x height 720 | main.resizable(False, False) 721 | #main.overrideredirect(1) 722 | hoehe = 2 723 | breite = 20 724 | 725 | 726 | #Buttons 727 | update_button = tkinter.Button(main, bg=bgc, fg=fgc, text = "Update", command=lambda:button_action_handler("update_button"), height = hoehe, width = breite) 728 | update_button.grid(row = 0, column = 0) 729 | scan_button = tkinter.Button(main, bg=bgc, fg=fgc, text = "Scan", command=lambda:button_action_handler("scan_button"), height = hoehe, width = breite) 730 | scan_button.grid(row = 1, column = 0) 731 | fullscan_button = tkinter.Button(main, bg=bgc, fg=fgc, text = "Full scan", command=lambda:button_action_handler("fullscan_button"), height = hoehe, width = breite) 732 | fullscan_button.grid(row = 2, column = 0) 733 | quarantine_button = tkinter.Button(main, bg=bgc, fg=fgc, text = "Quarantine", command=lambda:button_action_handler("quarantine_button"), height = hoehe, width = breite) 734 | quarantine_button.grid(row = 3, column = 0) 735 | quit_button = tkinter.Button(main, bg=bgc, fg=fgc, text = "Close", command=lambda:button_action_handler("quit_button"), height = hoehe, width = breite) 736 | quit_button.grid(row = 4, column = 0, sticky="w") 737 | b_delete = tkinter.Button(main, bg=bgc, fg=fgc, text = "Remove current", height=0, width = 25, justify=CENTER) 738 | b_delete_all = tkinter.Button(main, bg=bgc, fg=fgc, text = "Remove all", height = 0, width = 25, justify=CENTER) 739 | b_restore = tkinter.Button(main, bg=bgc, fg=fgc, text = "Restore current", height=0, width = 25, justify=CENTER) 740 | b_restore_all = tkinter.Button(main, bg=bgc, fg=fgc, text = "Restore all", height = 0, width = 25, justify=CENTER) 741 | b_add_file = tkinter.Button(main, bg=bgc, fg=fgc, text = "Add file", height = 0, width = 25, justify=CENTER) 742 | b_delete.place(x = 570, y = 70) 743 | b_delete_all.place(x = 570, y = 95) 744 | b_restore.place(x = 570, y = 120) 745 | b_restore_all.place(x = 570, y = 145) 746 | b_add_file.place(x = 570, y = 170) 747 | b_delete.place_forget() 748 | b_delete_all.place_forget() 749 | b_restore.place_forget() 750 | b_restore_all.place_forget() 751 | b_add_file.place_forget() 752 | 753 | #Text 754 | text_box = tkinter.scrolledtext.ScrolledText(main) 755 | text_box.configure(bg=bgc) 756 | text_box.configure(fg=fgc) 757 | text_box.place(height = 205, width = 419,x = 150, y = 0) 758 | 759 | #Listbox 760 | li = tkinter.Listbox(main, height=3, width = 29) 761 | li.place(x = 570, y = 18.5) 762 | li.place_forget() 763 | 764 | #Entries 765 | e = tkinter.Entry(main,width = 30) 766 | e.place(x = 570, y = 0) 767 | e["justify"] = CENTER 768 | e.insert(0, "") 769 | e["bg"] = bgc 770 | e["fg"] = fgc 771 | 772 | #Intro 773 | text_box.insert(END, special_text, "VIP") 774 | text_box.tag_config("VIP", background=special) 775 | text_box.insert(END, "[ + ] Preparing the program\n", 'positive') 776 | text_box.tag_config('positive', foreground='green') 777 | text_box.see(END) 778 | text_box.update() 779 | text_box.insert(END, "[ ! ] You might have to wait for a bit\n", 'important') 780 | text_box.tag_config('important', foreground="red") 781 | text_box.see(END) 782 | text_box.update() 783 | #row_counter += 3 784 | main.mainloop() 785 | 786 | #Executing Threads 787 | t_main = Thread(target=gui_thread)# Main Thread 788 | t_files = Thread(target=ScanSystemFiles) 789 | t_clock = Thread(target=clock_thread) 790 | t_main.start() 791 | time.sleep(1) 792 | t_clock.start() 793 | time.sleep(5) 794 | #print(t_main.isAlive()) 795 | t_files.start() 796 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Antivirus-Python- 2 | 3 | This is a project I started at the beginning of December 2017. I was simply bored out of my mind and needed a good topic for a term paper for school, so yeah here it is. 4 | Since then it has gone from a console application to an "acceptable" GUI. 5 | This antivirus script is signature based only at the moment. I might add heuristics if I find the time to do so (school is hella work sometimes). 6 | As I don't know where to safely get computer threats such as viruses, trojan horses, etc., the signatures that the AV uses come from VirusShare (https://virusshare.com/). I know that on their about-page it says, that scraping the website won't be tolerated, so I will not be responsible for the actions you perform with the software I made. I suggest to you that you look in your browser yourself to check if new Hash files were uploaded, and if you should not do it, the script is going to check, whether you have to download new ones/if new ones are available and you have not downloaded them so far. (Please do not penetrate my rectal hole Mr. VirusShare!!!) 7 | 8 | Regarding what I just mentioned, if it should be a problem I will look into getting a server to make them available from there and as long as the problem exists and a server is not made available on my side I will take the program down (both crawler and Antivirus). 9 | Screenshots will be uploaded in the following week. 10 | 11 | If you should have any questions or any suggestions, here are some contact infos: 12 | - Reddit (I guess): https://www.reddit.com/user/CaptainReeetardo/ 13 | - I am practically knew to GitHub, but I guess you can contact me here, too?!?!?! 14 | -------------------------------------------------------------------------------- /SystemFileScanner.py: -------------------------------------------------------------------------------- 1 | import glob 2 | import time 3 | import sys, os 4 | 5 | os_name = sys.platform 6 | partitionen = [] 7 | verzeichnisse = [] 8 | files = [] 9 | 10 | def partitions(sfsFolder): 11 | global partitionen 12 | big = 65 13 | 14 | if "win" in os_name: 15 | for i in range(26): 16 | try: 17 | if glob.glob(str(chr(big + i)) + ":\\"): 18 | #print("Successfully found partition: " + str(chr(big + i))) 19 | partitionen.append(str(chr(big + i)) + ":\\") 20 | except: 21 | continue 22 | return indeces(sfsFolder) 23 | if "win" not in os_name: 24 | return indeces(sfsFolder) 25 | 26 | def indeces(sfsFolder): 27 | global verzeichnisse 28 | global files 29 | 30 | if "win" in os_name: 31 | verzeichnisse2 = glob.glob("\\*") 32 | else: 33 | verzeichnisse2 = glob.glob("//*") 34 | verzeichnisse_tmp = [] 35 | x = 1 36 | 37 | if "win" in os_name: 38 | for ind in range(len(partitionen)): 39 | #print(partitionen[ind]) 40 | while verzeichnisse2 != []: 41 | verzeichnisse2 = glob.glob(partitionen[ind] + "\\*"*x) 42 | for i in range(len(verzeichnisse2)): 43 | verzeichnisse.append(verzeichnisse2[i]) 44 | x += 1 45 | x = 1 46 | 47 | for i in range(len(verzeichnisse)): 48 | if "." in verzeichnisse[i]: 49 | files.append(verzeichnisse[i]) 50 | for i in range(len(verzeichnisse)): 51 | if not os.path.isfile(verzeichnisse[i]): 52 | verzeichnisse_tmp.append(verzeichnisse[i]) 53 | verzeichnisse = verzeichnisse_tmp 54 | i = 0 55 | f = open(sfsFolder, "w") 56 | for i in range(len(files)): 57 | f.write(files[i] + "\n") 58 | f.close() 59 | time.sleep(3) 60 | 61 | if "win" not in os_name: 62 | while verzeichnisse2 != []: 63 | verzeichnisse = glob.glob("//*" * x) 64 | for i in range(len(verzeichnisse2)): 65 | verzeichnisse.append(verzeichnisse2[i]) 66 | x += 1 67 | x = 1 68 | 69 | for i in range(len(verzeichnisse)): 70 | if "." in verzeichnisse[i]: 71 | files.append(verzeichnisse[i]) 72 | for i in range(len(verzeichnisse)): 73 | if not os.path.isfile(verzeichnisse[i]): 74 | verzeichnisse_tmp.append(verzeichnisse[i]) 75 | verzeichnisse = verzeichnisse_tmp 76 | i = 0 77 | f = open(sfsFolder, "w") 78 | for i in range(len(files)): 79 | f.write(files[i] + "\n") 80 | f.close() 81 | time.sleep(3) 82 | -------------------------------------------------------------------------------- /quarantaene.py: -------------------------------------------------------------------------------- 1 | import base64 2 | import os 3 | import sys 4 | 5 | os_name = sys.platform 6 | 7 | def encode_base64(file, qPath): 8 | global os_name 9 | 10 | org_file_path = bytes(file, "utf-8") 11 | if "win" in os_name: 12 | org_file_name = file.rfind("\\") 13 | else: 14 | org_file_name = file.rfind("/") 15 | org_file_name = file[org_file_name+1:] 16 | f = open(file, "rb") 17 | org_content = f.read() 18 | f.close() 19 | os.remove(file) 20 | new_content = base64.b64encode(org_content) 21 | f = open(qPath + org_file_name + ".eb64", "wb") 22 | f.write(org_file_path + b"\n") 23 | f.write(new_content) 24 | f.close() 25 | 26 | def decode_base64(file): 27 | f = open(file, "rb") 28 | org_content = f.read() 29 | f.close() 30 | org_content = org_content.splitlines() 31 | org_file_path = org_content[0] 32 | org_content.remove(org_file_path) 33 | new_content = [] 34 | for i in org_content: 35 | new_content.append(base64.b64decode(i)) 36 | f = open(org_file_path, "wb") 37 | for i in new_content: 38 | f.write(i + b"\n") 39 | f.close() 40 | os.remove(file) 41 | --------------------------------------------------------------------------------