filtering added

This commit is contained in:
George Hotz 2014-07-01 16:53:55 -07:00
parent 8548913bb3
commit b08b9979b7
11 changed files with 80 additions and 9 deletions

4
go.sh
View File

@ -1,6 +1,7 @@
#!/bin/sh
set -e
#BIN=../tests/ctf/ezhp
BIN=../tests/ctf/hudak
#BIN=../tests/ctf/simple
#SRC=../tests/hello.c
@ -19,9 +20,12 @@ cd scripts
#echo "4t_l34st_it_was_1mperat1v3..." | ./run_qemu.sh $BIN
echo "i wish i were a valid key bob" | ./run_qemu.sh $BIN
#./run_qemu.sh $BIN
#./run_qemu.sh $BIN
echo "*** build the Program database"
time python db_commit_asm.py $BIN $SRC
echo "*** filter the Change database"
time python db_filter_log.py
echo "*** build the Change database"
time python db_commit_log.py
echo "*** build the memory json"

View File

@ -146,6 +146,7 @@ int IDAP_init(void) {
void IDAP_term(void) {
unhook_from_notification_point(HT_UI, hook);
exit_websocket_thread();
return;
}

View File

@ -1,10 +1,11 @@
from pymongo import MongoClient
from qira_log import *
from pymongo import MongoClient
db = MongoClient('localhost', 3001).meteor
print "reading log"
dat = read_log("/tmp/qira_log")
#dat = read_log("/tmp/qira_log")
dat = read_log("/tmp/qira_log_filtered")
print "building database data"

37
scripts/db_filter_log.py Normal file
View File

@ -0,0 +1,37 @@
from qira_log import *
from pymongo import MongoClient
def is_library_address(address):
return address > 0x80000000
db = MongoClient('localhost', 3001).meteor
print "reading log"
dat = read_log("/tmp/qira_log")
print "filtering data"
ds = []
dds = []
maxclnum = 0
fixclnum = 0
clignore = 0
for (address, data, clnum, flags) in dat:
if clnum > maxclnum:
maxclnum = clnum
if flags & IS_START:
if is_library_address(address):
clignore = clnum
else:
fixclnum += 1
dds.append((address, data, fixclnum, flags))
if clnum == clignore and not (flags & IS_MEM):
continue
ds.append((address, data, fixclnum, flags))
print "filtered from %d(%d) to %d(%d)" % (maxclnum, len(dat), clnum, len(ds))
write_log("/tmp/qira_log", dds)
write_log("/tmp/qira_log_filtered", ds)

View File

@ -19,3 +19,12 @@ def read_log(fn):
return ret
def write_log(fn, dat):
ss = []
for (address, data, clnum, flags) in dat:
ss.append(struct.pack("QQII", address, data, clnum, flags))
f = open(fn, "wb")
f.write(''.join(ss))
f.close()

View File

@ -6,6 +6,7 @@ cd ~/build/qemu
make -j32
popd
rm -rf /tmp/qira*
~/build/qemu/i386-linux-user/qemu-i386 -singlestep -d in_asm $@ 2> /tmp/qira_disasm
ls -l /tmp/qira*

BIN
tests/ctf/ezhp Executable file

Binary file not shown.

View File

@ -140,7 +140,7 @@ Template.regviewer.datatype = function() {
Template.datachanges.memactions = function() {
var clnum = Session.get("clnum");
var cur = Change.find({clnum: clnum,
$or: [{type: "L"}, {type: "S"}]});
$or: [{type: "L"}, {type: "S"}]}, {limit: 3});
return cur;
};

View File

@ -77,16 +77,21 @@ body {
#regviewer {
height: 80px;
border: 1px solid gray;
background-color: #DDDDDD;
padding: 2px;
border: 1px solid black;
width: 600px;
width: 620px;
}
#datachanges {
font-family: monospace;
padding: 2px;
height: 20px;
min-height: 20px;
width: 620px;
}
.datachanges {
display: inline-block;
}
.change {

View File

@ -62,11 +62,11 @@
<template name="datachanges">
{{#each memactions}}
<span class="datachanges {{typeclass}}">
<div class="datachanges {{typeclass}}">
<span class="{{addrtype}}">{{hexaddress}}</span>
&lt;--
<span class="{{datatype}}">{{hexdata}}</span>
</span>
</div>
{{/each}}
</template>

View File

@ -45,7 +45,7 @@ function map_getbelow(map, a) {
}
}
Meteor.startup(function () {
function read_memdb() {
fs.readFile("/tmp/qira_memdb", function(err, data) {
if (err) throw err;
console.log("read memdb");
@ -54,6 +54,19 @@ Meteor.startup(function () {
mem = map_create(dat['mem']);
console.log("parsed memdb");
});
}
var tmout = undefined;
Meteor.startup(function () {
read_memdb();
fs.watch("/tmp/qira_memdb", {}, function(e, fn) {
console.log("watch tripped "+e+" "+fn);
if (tmout !== undefined) {
clearTimeout(tmout);
tmout = undefined;
}
tmout = setTimeout(read_memdb, 200);
});
});
// shouldn't be here