Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
MAJOR UPDATE!
GUI BOIIISSS
  • Loading branch information
u68 authored Feb 14, 2024
1 parent 9960e30 commit 9c3de97
Showing 1 changed file with 94 additions and 21 deletions.
115 changes: 94 additions & 21 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,95 @@
#!/usr/bin/python3
#this is terminal based, I might add a gui later, not now, its too complicated.

import os
import sys
ropa = open(sys.argv[1])
disasa = open(sys.argv[2])
disasb = open(sys.argv[3])
searchl = sys.argv[5]
for line in disasa:
if 'pop pc' in line:
os.system('echo ' + line + '>disasap')
disasap = open('disasap')
for lline in disasb:
if 'pop pc' in lline:
os.system('echo ' + lline + '>disasbp')
disasbp = open('disasbp')
for llline in ropa:
if llline in disasa:
if llline in disasbp:
os.system('printf ' + "'" + disasbp + "'") #.split()[0] + disasbp.split()[1] + disasbp.split()[2] + disasbp.split()[3] + disasbp.split()[4] + "'")

import tkinter as tk
from tkinter import filedialog

def remove_newline(strings):
return [string.replace('\n', '') for string in strings]

def extract_lines_before_pop_pc(file_path):
lines_before_pop_pc = []
with open(file_path, 'r') as file:
previous_line = ''
for line in file:
if 'pop pc' in line:
lines_before_pop_pc.append(previous_line.strip())
previous_line = line
return lines_before_pop_pc

def find_matching_strings(list1, list2):
result = []
for string1 in list1:
for string2 in list2:
if string1 in string2:
result.append(string2)
return result

def open_rop_file():
file_path = filedialog.askopenfilename()
if file_path:
global ropfile
ropfile = file_path
rop_text.delete("1.0", tk.END)
with open(ropfile, 'r') as file:
rop_content = remove_newline(file.readlines())
rop_text.insert(tk.END, '\n'.join(rop_content))

def open_disas_file():
file_path = filedialog.askopenfilename()
if file_path:
global disasfile
disasfile = file_path
disas_text.delete("1.0", tk.END)
with open(disasfile, 'r') as file:
disas_content = remove_newline(file.readlines())
disas_text.insert(tk.END, '\n'.join(disas_content))

def compile_translate():
rop = remove_newline(open(ropfile).readlines())
lines_before_pop_pc = extract_lines_before_pop_pc(disasfile)
matching_strings = find_matching_strings(rop, lines_before_pop_pc)
result_text.delete("1.0", tk.END)
result_text.insert(tk.END, '\n'.join(matching_strings))

root = tk.Tk()
root.title("String Matching")

ropfile = ""
disasfile = ""

# Create menu bar
menubar = tk.Menu(root)
root.config(menu=menubar)

# Create File menu
file_menu = tk.Menu(menubar, tearoff=0)
menubar.add_cascade(label="File", menu=file_menu)
file_menu.add_command(label="Open ROP File", command=open_rop_file)
file_menu.add_command(label="Open Disas File", command=open_disas_file)
file_menu.add_separator()
file_menu.add_command(label="Exit", command=root.quit)

# Create Compile menu
compile_menu = tk.Menu(menubar, tearoff=0)
menubar.add_cascade(label="Compile", menu=compile_menu)
compile_menu.add_command(label="Translate", command=compile_translate)

rop_label = tk.Label(root, text="ROP File:")
rop_label.grid(row=0, column=0, padx=5, pady=5, sticky='w')

disas_label = tk.Label(root, text="Disas File:")
disas_label.grid(row=0, column=1, padx=5, pady=5, sticky='w')

rop_text = tk.Text(root, height=10, width=50)
rop_text.grid(row=1, column=0, padx=5, pady=5)

disas_text = tk.Text(root, height=10, width=50)
disas_text.grid(row=1, column=1, padx=5, pady=5)

result_label = tk.Label(root, text="Output:")
result_label.grid(row=2, column=0, padx=5, pady=5, sticky='w')

result_text = tk.Text(root, height=20, width=100)
result_text.grid(row=3, column=0, columnspan=2, padx=5, pady=5)

root.mainloop()

0 comments on commit 9c3de97

Please sign in to comment.