Skip to content

Commit

Permalink
version 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
shipperzhang committed Dec 14, 2021
1 parent cdb379a commit c074cca
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 29 deletions.
6 changes: 3 additions & 3 deletions Docker/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Docker for Uroboros version 0.4
# Docker for Uroboros version 0.5

## Docker build


Then use `docker build` to build the docker image from Dockerfile.

```shell
docker build -f Dockerfile -t uroboros:0.4 .
docker build -f Dockerfile -t uroboros:0.5 .
```

## Docker usage

run the Docker container with `docker run`.

```shell
docker run -it uroboros:0.4
docker run -it uroboros:0.5
```
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Uroboros: Infrastructure for Reassembleable Disassembling and Transformation (Version 0.4)
# Uroboros: Infrastructure for Reassembleable Disassembling and Transformation (Version 0.5)

# Installation

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Please use Uroboros (version 0.4) for the tests below.
Please use Uroboros (version 0.5) for the tests below.

# Coreutils:

Expand Down
2 changes: 1 addition & 1 deletion src/cfg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class cfg =
begin
match c with
| Jump _ -> true (* jump ops *)
| CALL -> true (* call *)
(*| CALL -> true (* call *)*)
| RET -> true
| RETN -> true
| _ -> false
Expand Down
4 changes: 2 additions & 2 deletions src/extern_symbol_process64.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def check_32():

for i in range(len(lines)):
l = lines[i]
if "#" in l and not "+" in l:
m_s = re.search(pat_s, l)
m_s = re.search(pat_s, l)
if "#" in l and not "+" in l and m_s:
m_d = re.search(pat_d, l)
try:
src = m_s.group(1) # let it crash it not
Expand Down
3 changes: 1 addition & 2 deletions src/init.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ object (self)

print_string "1: linearly disassemble\n";

ret := Sys.command("objdump -Dr -j \
.text "^f^" > "^f^".temp");
ret := Sys.command("objdump -Dr -j .text "^f^" > "^f^".temp");
self#checkret ret (f^".temp");

Sys.command("python pic_process.py "^f^" "^(string_of_bool !is_32));
Expand Down
6 changes: 3 additions & 3 deletions src/pic_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def text_process_unstrip(f):
info_dump(f)
pic_map = info_collect()

for i in xrange(1,len(ls)):
for i in range(1,len(ls)):
l = ls[i]
if "<__i686.get_pc_thunk.bx>" in l and "call" in l:
t = ls[i+1]
Expand Down Expand Up @@ -96,7 +96,7 @@ def text_process_unstrip(f):
def thunk_identify(ls):
global step

for i in xrange(step, len(ls)):
for i in range(step, len(ls)):
l = ls[i]
m = re.search(r'([0-9A-Fa-f]*)(.+)(mov\s+\(%esp\),)(%e\w{2})', l.strip())
if m != None:
Expand Down Expand Up @@ -157,7 +157,7 @@ def text_process_strip(f):
while True:
pc_thunk_addr, register = thunk_identify(ls)
if pc_thunk_addr == None: break
for i in xrange(1,len(ls)):
for i in range(1,len(ls)):
l = ls[i]
if re.search(r'call\s+'+pc_thunk_addr, l) != None:
t = ls[i+1]
Expand Down
6 changes: 3 additions & 3 deletions src/pic_process64.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
l = lines[i]
if "#" in l:
des = l.split('#')[1].split()[0]
#symbols.append(des+"\n")
if des.startswith('0x'): des = des[2:]
m = re.search(pat, l)
try:
sub = m.group(0) # let it crash it not
Expand All @@ -44,8 +44,8 @@
l = l.replace(sub, sub1)
lines[i] = l+"\n"
except Exception:
print "exception in pic processing of 64-bit ELF"
print l
print("exception in pic processing of 64-bit ELF")
print(l)
with open(fn + '.temp', 'w') as f:
f.writelines(lines)

Expand Down
20 changes: 14 additions & 6 deletions src/post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ def check_32():
if m and re.search(r'add\s+%r\w{2},'+m.group(1),lines[i-1]):
lines[i-1] = "nop\n"

pre_symbol = ''
pre_idx = -1
for i in range(ll):
l = lines[i]
if l.startswith('BB_'):
if len(lines[i+1].strip()) == 0 or lines[i+1].startswith('S_0x'):
lines[i] = ""
if l.startswith('S_0x'):
if l == pre_symbol:
lines[pre_idx] = ''
pre_symbol = l
pre_idx = i


for i in range(ll):
l = lines[i]
if ".text" in l:
Expand Down Expand Up @@ -129,13 +143,7 @@ def check_exe():

def help(l):
if main_symbol1 != "" and main_symbol1 in l and l.startswith(main_symbol1):
#main_s1 = "S"+main_symbol
#if main_s1 in l:
#l = l.replace(main_s1, ".globl main\nmain")
l = ".globl main\nmain:\n"+l
#else:
#l = l.replace(main_symbol, ".globl main\nmain")
# l = ".globl main\nmain:\n"+l
return l
#print lines
lines = map(lambda l : help(l), lines)
Expand Down
10 changes: 5 additions & 5 deletions src/reassemble_symbol_get.ml
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ end
let p = object(sp)
method process lbs =
let dec_hex (s:int) : string =
(Printf.sprintf "S_0x%X : " s)
(Printf.sprintf "S_0x%X:\n" s)
in
let rec help loc_list =
match loc_list with
Expand Down Expand Up @@ -1195,7 +1195,7 @@ class instrhandler instr_list des' =
"S_0x"^(Printf.sprintf "%X" s) in
let help l =
let d = dec_hex l.loc_addr in
print_string (l.loc_label^" : "^d^"\n") in
print_string (l.loc_label^":\n"^d^"\n") in
List.iter help locs

method get_instr_list =
Expand Down Expand Up @@ -1299,7 +1299,7 @@ class instrhandler instr_list des' =
if dh = lhd then
(
let lhs = dec_hex lh.loc_addr in
let label' = do_update lh.loc_label (lhs^" : ") in
let label' = do_update lh.loc_label (lhs^":\n") in
let lh' = {lh with loc_label=label'} in
help (lh'::acc) lt dt
)
Expand Down Expand Up @@ -1328,7 +1328,7 @@ class instrhandler instr_list des' =

method update_loc locs d =
let dec_hex (s:int) : string =
"S_0x"^(Printf.sprintf "%X : " s) in
"S_0x"^(Printf.sprintf "%X:\n" s) in
let identify_des addr1 addr2 =
addr1.loc_addr = (int_of_string addr2)
and lift_addr addr =
Expand Down Expand Up @@ -1365,7 +1365,7 @@ class funchandler instr_list u_funcs' =
"S_0x"^(Printf.sprintf "%X" s) in
let help l =
let d = dec_hex l.loc_addr in
print_string (l.loc_label^" : "^d^"\n") in
print_string (l.loc_label^":\n"^d^"\n") in
List.iter help locs


Expand Down
4 changes: 2 additions & 2 deletions src/uroboros.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def process(f, i):
def iterate (f, iterations):
print("start to process binary: " + f)

for i in xrange(0, iterations):
for i in range(0, iterations):
print ("########## iteration round "+str(i+1) + " begin ! ###########")
if process(f, i):
pass
Expand Down Expand Up @@ -220,7 +220,7 @@ def set_assumption (l):
(n-byte alignment) are set by default,
while assumption two and three need to be configured. For example, setting
assumption two and three: -a 2 -a 3''')
p.add_argument('--version', action='version', version='Uroboros v0.4')
p.add_argument('--version', action='version', version='Uroboros 0.5')

args = p.parse_args()
b = args.binary
Expand Down

0 comments on commit c074cca

Please sign in to comment.