Skip to content

Commit 1e79c58

Browse files
committed
Fix and fmt
1 parent a4b3c40 commit 1e79c58

File tree

4 files changed

+56
-8
lines changed

4 files changed

+56
-8
lines changed

jingle/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,56 @@ This will install `jingle` in your path. Note that
2121

2222
`jingle` requires that a Ghidra installation be present.
2323

24+
When you provide it as the first argument to the `jingle` CLI, it
25+
will save that path for future usage.
26+
27+
Once it has been configured, you can simple run it as follows:
28+
29+
```shell
30+
jingle disassemble x86:LE:32:default 89fb
31+
jingle lift x86:LE:32:default 89fb
32+
jingle model x86:LE:32:default 89fb
33+
```
34+
35+
These three invocations will print disassembly, pcode translation, and
36+
a logical model respectively. None of these, particularly the logical model,
37+
are intended to be used directly from this utility; this is merely for demonstration.
38+
The proper way to use this tool is through the API.
39+
40+
The above invocations will produce the following output:
41+
```shell
42+
# jingle disassemble x86:LE:32:default 89fb
43+
MOV EBX,EDI
44+
```
45+
46+
```shell
47+
# jingle lift x86:LE:32:default 89fb
48+
EBX = COPY EDI
49+
```
50+
51+
```shell
52+
# jingle model x86:LE:32:default 89fb
53+
; benchmark generated from rust API
54+
(set-info :status unknown)
55+
(declare-fun register!4 () (Array (_ BitVec 32) (_ BitVec 8)))
56+
(declare-fun register!9 () (Array (_ BitVec 32) (_ BitVec 8)))
57+
(declare-fun ram!3 () (Array (_ BitVec 32) (_ BitVec 8)))
58+
(declare-fun ram!8 () (Array (_ BitVec 32) (_ BitVec 8)))
59+
(declare-fun OTHER!1 () (Array (_ BitVec 64) (_ BitVec 8)))
60+
(declare-fun OTHER!6 () (Array (_ BitVec 64) (_ BitVec 8)))
61+
(assert
62+
(let ((?x77 (store (store register!4 (_ bv12 32) (select register!4 (_ bv28 32))) (_ bv13 32) (select register!4 (_ bv29 32)))))
63+
(let ((?x81 (store (store ?x77 (_ bv14 32) (select register!4 (_ bv30 32))) (_ bv15 32) (select register!4 (_ bv31 32)))))
64+
(let (($x82 (= register!9 ?x81)))
65+
(let (($x63 (= ram!8 ram!3)))
66+
(let (($x62 (= OTHER!6 OTHER!1)))
67+
(and $x62 $x63 $x82)))))))
68+
(check-sat)
69+
70+
```
71+
72+
### Usage string
73+
2474
```shell
2575
Usage: jingle [GHIDRA_PATH] <COMMAND>
2676

jingle/src/main.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ fn get_instructions(
125125
let img = decode(hex_bytes)?;
126126
let max_len = img.len();
127127
let mut offset = 0;
128-
let sleigh = sleigh_build
129-
.build(&architecture)
130-
.context("Unable to build the selected architecture.\n\
131-
This is either a bug in sleigh or the .sinc file for your architecture is malformed.")?;
128+
let sleigh = sleigh_build.build(&architecture).context(
129+
"Unable to build the selected architecture.\n\
130+
This is either a bug in sleigh or the .sinc file for your architecture is malformed.",
131+
)?;
132132
let sleigh = sleigh.initialize_with_image(img)?;
133133
let mut instrs = vec![];
134134
while offset < max_len {
@@ -192,7 +192,6 @@ fn model(config: &JingleConfig, architecture: String, hex_bytes: String) -> anyh
192192
let jingle_ctx = JingleContext::new(&z3, &sleigh);
193193
let block = ModeledBlock::read(&jingle_ctx, instrs.into_iter())?;
194194
let final_state = jingle_ctx.fresh_state();
195-
println!("{}", block.get_final_state().fmt_smt_arrays());
196195
solver.assert(&final_state._eq(block.get_final_state())?.simplify());
197196
println!("{}", solver.to_smt2());
198197
Ok(())

jingle/src/modeling/slice.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,3 @@ impl<'ctx, T: ModelingContext<'ctx>> ModelingContext<'ctx> for &[T] {
5050
self.last().unwrap().get_branch_constraint()
5151
}
5252
}
53-

jingle/src/modeling/state/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ impl<'ctx> State<'ctx> {
310310
let eq_terms: Vec<&Bool> = terms.iter().collect();
311311
Ok(Bool::and(self.jingle.z3, eq_terms.as_slice()))
312312
}
313-
314-
pub fn fmt_smt_arrays(&self)-> String{
313+
314+
pub fn fmt_smt_arrays(&self) -> String {
315315
let mut lines = vec![];
316316
for x in &self.spaces {
317317
lines.push(x.fmt_smt_array())

0 commit comments

Comments
 (0)