Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ __pycache__/
*.py[cod]
*$py.class
binwalk/

_firmware*/
# C extensions
*.so

Expand Down
47 changes: 40 additions & 7 deletions binwalkgui.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import binwalk
from tkinter import *
from tkinter import filedialog
from tkinter import messagebox

# Initial Setup
window = Tk()
Expand All @@ -23,19 +25,50 @@

# Helper functions
def analyze():
label_name.configure(text="firmware.zip")
# label_name.configure(text="firmware.zip")
if label_name.cget("text") is not "":
# binwalk execution

# binwalk execution
results_string = ''
for module in binwalk.scan(label_name.cget("text"), signature=True, quiet=True):
for result in module.results:
results_string += "0x%.8X %s \n" % (result.offset, result.description)

results_string = ''
for module in binwalk.scan("firmware.zip", signature=True, quiet=True):
for result in module.results:
results_string += "0x%.8X %s \n" % (result.offset, result.description)
label_results_data.configure(text=results_string)
else:
messagebox.showerror("Error", "Please choose a file before analyzing")

def extract():
files_extracted = ""
if label_name.cget("text") is not "":
for module in binwalk.scan(label_name.cget("text"), signature=True, extract=True):
for result in module.results:
if result.file.path in module.extractor.output:
# These are files that binwalk carved out of the original firmware image, a la dd
if result.offset in module.extractor.output[result.file.path].carved:
print ("Carved data from offset 0x%X to %s" % (result.offset, module.extractor.output[result.file.path].carved[result.offset]))
files_extracted += module.extractor.output[result.file.path].carved[result.offset]
files_extracted += "\n"
# These are files/directories created by extraction utilities (gunzip, tar, unsquashfs, etc)
if result.offset in module.extractor.output[result.file.path].extracted:
print ("Extracted %d files from offset 0x%X to '%s' using '%s'" % (len(module.extractor.output[result.file.path].extracted[result.offset].files),result.offset,module.extractor.output[result.file.path].extracted[result.offset].files[0],module.extractor.output[result.file.path].extracted[result.offset].command))

messagebox.showinfo("Files carved", "The following files have been carved: \n" + files_extracted)

def choose_file():
label_results_data.configure(text='')
file_name = filedialog.askopenfilename()
label_name.configure(text=file_name)

label_results_data.configure(text=results_string)

# Generating buttons
execute_button = Button(window, text="Analyze File", command=analyze)
execute_button.grid(column=1, row=5)

extract_button = Button(window, text="Extract File", command=extract)
extract_button.grid(column=2, row=5)

choose_file_button = Button(window, text="Choose file to analyze", command=choose_file)
choose_file_button.grid(column=2, row=0)

window.mainloop()