aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Li <li.davidm96@gmail.com>2016-01-12 09:26:23 -0700
committerDavid Li <li.davidm96@gmail.com>2016-01-12 09:26:23 -0700
commitf4ecb2e56397365d8ea809b169df0734a1a6524c (patch)
tree00a6672dd3dd0af9171b8bd9f2bd81fc544af276
parent6ee72c288121ffa611ad75a00682bf103acea1fe (diff)
Generate payload randomly
-rw-r--r--Cargo.lock20
-rw-r--r--Cargo.toml1
-rw-r--r--devkit/cacheracer.h2
-rw-r--r--src/main.rs9
4 files changed, 29 insertions, 3 deletions
diff --git a/Cargo.lock b/Cargo.lock
index b1a2219..580d37c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5,12 +5,22 @@ dependencies = [
"docopt 0.6.78 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"rustv 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
+name = "advapi32-sys"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "aho-corasick"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -73,6 +83,16 @@ dependencies = [
]
[[package]]
+name = "rand"
+version = "0.3.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "regex"
version = "0.1.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 7188a85..814194f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,5 +8,6 @@ log = "0.3"
env_logger = "0.3"
rustv = "0.4.1"
docopt = "0.6"
+rand = "0.3"
rustc-serialize = "0.3"
time = "0.1"
diff --git a/devkit/cacheracer.h b/devkit/cacheracer.h
index 7626524..7e9aa8c 100644
--- a/devkit/cacheracer.h
+++ b/devkit/cacheracer.h
@@ -1,7 +1,7 @@
#ifndef CACHERACER_H
#define CACHERACER_H
-void __start(int core_id);
+void __start(int core_id, unsigned char payload);
/** Memory Layout
*
diff --git a/src/main.rs b/src/main.rs
index 7d17d48..0667401 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,7 @@
extern crate docopt;
#[macro_use] extern crate log;
extern crate env_logger;
+extern crate rand;
extern crate rustc_serialize;
extern crate rustv;
extern crate time;
@@ -77,7 +78,10 @@ fn main() {
let start1 = load_program(&mut memory, &mmu, &args.arg_program1);
let start2 = load_program(&mut memory, &mmu2, &args.arg_program2);
- let memory = MemoryTracker::new(memory, 0x43, 0x42);
+ let payload1 = rand::random::<u8>();
+ let payload2 = rand::random::<u8>();
+
+ let memory = MemoryTracker::new(memory, payload1, payload2);
let memory_ref = Rc::new(RefCell::new(memory));
let cache = memory::DirectMappedCache::new(2, 64, memory_ref.clone());
@@ -85,7 +89,6 @@ fn main() {
let cache2 = memory::DirectMappedCache::new(2, 64, memory_ref.clone());
let cache2_ref = Rc::new(RefCell::new(cache2));
-
let mut cores = vec![];
let mut core_caches = vec![];
@@ -98,6 +101,7 @@ fn main() {
Box::new(memory::IdentityMmu::new())
);
core.registers().write_word(isa::Register::X10, i as isa::Word);
+ core.registers().write_word(isa::Register::X11, payload1 as isa::Word);
cores.push(core);
}
@@ -110,6 +114,7 @@ fn main() {
Box::new(memory::ReverseMmu::new(0x4000000))
);
core.registers().write_word(isa::Register::X10, (i - 4) as isa::Word);
+ core.registers().write_word(isa::Register::X11, payload2 as isa::Word);
cores.push(core);
}