Skip to content

Commit fbf5422

Browse files
authored
Merge pull request from s3team/existing-symbols
Use existing symbols if binary is not stripped
2 parents 896d165 + d811ff3 commit fbf5422

8 files changed

Lines changed: 188 additions & 101 deletions

File tree

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Uroboros: Infrastructure for Reassembleable Disassembling and Transformation (v1.0)
1+
# Uroboros: Infrastructure for Reassembleable Disassembling and Transformation
22

3-
# Installation
3+
## Installation
44

5-
## Docker
5+
### Docker
66

77
Uroboros is available as a docker image, you can check the details in [docker](docker).
88

9-
## Build
9+
### Build
1010

1111
The OCaml compiler and dependent libraries can be obtained through
1212
[opam](https://opam.ocaml.org/):
@@ -18,7 +18,7 @@ $ opam install -y ppx_deriving.6.0.3 parmap.1.2.5 batteries.3.9.0
1818
$ eval $(opam env)
1919
```
2020

21-
# Usage
21+
## Usage
2222

2323
Uroboros can take a 32-bit or 64-bit, statically-linked or dynamically-linked ELF executable as the
2424
input. To use Uroboros:
@@ -52,7 +52,7 @@ $ python3 uroboros.py bzip -i 500 -k
5252
A subfolder will be created in `./src` folder, with input binary name and
5353
timestamp (e.g., `test_fold_bzip_2021-09-19_05:51:00`).
5454

55-
# Instrumentation
55+
## Instrumentation
5656

5757
Instrumentation tools process the internal data structure of
5858
Uroboros. Some examples are shown in the [plugins](src/plugins) folder. You
@@ -64,7 +64,7 @@ To register instrumentation code:
6464
$ cp plugins/mem_write.ml instrumentation_plugin.ml
6565
```
6666

67-
# Publication
67+
## Publication
6868
```
6969
@inproceedings {190920,
7070
author = {Shuai Wang and Pei Wang and Dinghao Wu},

docker/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ Use `docker build` to build the docker image from Dockerfile.
66

77
```shell
88
# build using Ubuntu 20.04 (default)
9-
docker build -f ./Docker/Dockerfile -t uroboros:1.0 .
9+
docker build -f ./Docker/Dockerfile -t uroboros .
1010
# build using Ubuntu 22.04
11-
docker build --build-arg UBUNTU_VERSION=22.04 -f ./Docker/Dockerfile -t uroboros:1.0 .
11+
docker build --build-arg UBUNTU_VERSION=22.04 -f ./Docker/Dockerfile -t uroboros .
1212
# build using Ubuntu 24.04
13-
docker build --build-arg UBUNTU_VERSION=24.04 -f ./Docker/Dockerfile -t uroboros:1.0 .
13+
docker build --build-arg UBUNTU_VERSION=24.04 -f ./Docker/Dockerfile -t uroboros .
1414
```
1515

1616
## Docker usage
1717

1818
run the Docker container with `docker run`.
1919

2020
```shell
21-
docker run -it -v <path to uroboros parent>/uroboros:/usr/src uroboros:1.0 bash
21+
docker run -it -v <path to uroboros parent>/uroboros:/usr/src uroboros bash
2222
```

src/ail.ml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ object (self)
9494
Enum.iter help filelines
9595

9696
method ail_dump =
97-
(*currently we just dump the extern function info *)
97+
(* currently we just dump the extern function info *)
9898
let check_sym_func f =
9999
try
100100
let s = Char.escaped(f.func_name.[0])^Char.escaped(f.func_name.[1]) in
@@ -116,35 +116,33 @@ object (self)
116116
method post_process f (arch : string) =
117117
ignore (Sys.command ("python3 main_discover.py " ^ " " ^ f ^ " " ^ arch));
118118
ignore(Sys.command("python3 post_process.py "^arch));
119-
ignore(Sys.command("python3 post_process_lib.py"));
120-
()
121-
(*
122-
self#ehframe_dump;
123-
self#excpt_tbl_dump;
124-
*)
119+
ignore(Sys.command("python3 post_process_lib.py"))
120+
(*
121+
self#ehframe_dump;
122+
self#excpt_tbl_dump;
123+
*)
125124

126125
method pre_process =
127-
let _ = Sys.command("python3 pre_process.py") in
128-
()
129-
130-
126+
let _ = Sys.command("python3 pre_process.py") in ()
131127

132128
method instrProcess_2 f (arch: string) =
133129
let open Disassemble_process in
134130
let open Analysis_process in
135131
let module D = Disam in
136132
let module A = Analysis in
133+
let module S = Symbol_get in
137134
let () = self#pre_process in
138135
let (il, fl, re) = D.disassemble f funcs secs arch in
139136

140-
print_endline "3: analysis";
137+
print_endline "3: analysis";
141138

142139
let (fbl, bbl, cfg_t, cg, il', re) = A.analyze_one il fl re in
140+
let il' = S.apply il' in
143141
let open Instrumentation_plugin in
144142
let module IP = Instrumentation_Plugin in
145143
let instrumented_il = IP.instrument il' fbl bbl in
146144

147-
print_endline "4: post processing";
145+
print_endline "4: post processing";
148146
A.post_analyze instrumented_il re;
149147

150148
self#post_process f arch

src/disassemble_process.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module Disam = struct
5353
ail_parser#process_instrs instr_list arch;
5454

5555
let fl = ail_parser#get_funcs in
56-
print_endline "2: disassembly validates --> ";
56+
print_endline "2: disassembly validates";
5757

5858
(*let _ = List.iter (
5959
fun f ->
@@ -73,7 +73,6 @@ module Disam = struct
7373
()
7474
) func2cfg_table in ()
7575
else ();
76-
7776

7877
il :=
7978
if EU.elf_32 () && arch <> "arm" then
@@ -101,4 +100,4 @@ module Disam = struct
101100
print_endline "\tno disassembly error detects";
102101
let funcs = ail_parser#get_funcs in
103102
(!il, funcs, re)
104-
end
103+
end

src/post_process.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def check_32():
9292
# adjust it into jmp S_0x4006C1
9393
elif "jmpq " in l and "*" not in l:
9494
l = l.replace('jmpq ', 'jmp ')
95-
elif "__libc_start_main" in l and is_32 == True:
95+
elif "call " in l and "__libc_start_main" in l and is_32 == True:
9696
if arch == "arm":
9797
"""
9898
In case of ARM, main symbol is not pushed into stack.
@@ -117,7 +117,7 @@ def check_32():
117117
main_symbol = lines[i-1].split()[1]
118118
lines[i-1] = lines[i-1].replace(main_symbol, "main")
119119
main_symbol = main_symbol[1:].strip()
120-
elif is_32 == False and "__libc_start_main" in l:
120+
elif is_32 == False and "call " in l and "__libc_start_main" in l:
121121
if arch == "arm":
122122
pass
123123
else:

0 commit comments

Comments
 (0)