introducao-a-assembly

Repositório dos arquivos usados na apresentação "Introdução a Assembly" da CriptoGoma de 2020 🖥️

Commit
d49c8052a6f471d0a56dd0b07957dfb805c10fd2
Parent
6b7c20c87753799db265b8e0d03663ca550cf5e6
Author
Pablo Emilio Escobar Gaviria <pablo-escobar@riseup.net>
Date

Refactored the script that extracts the relevant machine code of the example function

Diffstat

1 file changed, 6 insertions, 6 deletions

Status File Name N° Changes Insertions Deletions
Modified examples/reverse_engeneering/convert.py 12 6 6
diff --git a/examples/reverse_engeneering/convert.py b/examples/reverse_engeneering/convert.py
@@ -1,11 +1,11 @@
 #!python3
 
 START = 0x5fa # Start of the factorial function according to gdb
-END = 0x625   # End of the factorial function according to gdb
+END   = 0x625 # End of the factorial function according to gdb
 
-with open("exemplo.bin", "rb") as binary:
-    byts = binary.read()[START:END]
-    bin_str = lambda b: bin(b)[2:].rjust(8, "0")
+with open("exemplo.bin", "rb"), as machine_code:
+    bs = machine_code.read()[START:END]
+
+    with open("bin.txt", "w", encoding="utf8") as output:
+        output.write(" ".join([f"{byte:b}".zfill(8) for byte in bs]))
 
-    with open("bin.txt", "w", encoding="utf8") as bin_file:
-        bin_file.write(" ".join([s for s in map(bin_str, byts)]))