mirror of
https://github.com/geohot/qira
synced 2025-03-13 10:33:30 +03:00
fixed bugs in the qemu build script
This commit is contained in:
parent
f50dd6a9a1
commit
3555dba946
24
fetchqemu.sh
24
fetchqemu.sh
@ -1,12 +1,20 @@
|
||||
#!/bin/bash
|
||||
rm -rf qemu
|
||||
mkdir -p qemu
|
||||
cd qemu
|
||||
wget http://wiki.qemu-project.org/download/qemu-2.0.0.tar.bz2
|
||||
tar xf qemu-2.0.0.tar.bz2
|
||||
cd qemu-2.0.0
|
||||
mv tci.c tci.c.bak
|
||||
|
||||
if [ ! -d qemu/qemu-latest ]; then
|
||||
rm -rf qemu
|
||||
mkdir -p qemu
|
||||
cd qemu
|
||||
wget http://wiki.qemu-project.org/download/qemu-2.1.0-rc0.tar.bz2
|
||||
tar xf qemu-2.1.0-rc0.tar.bz2
|
||||
ln -s qemu-2.1.0-rc0 qemu-latest
|
||||
cd qemu-latest
|
||||
mv tci.c tci.c.bak
|
||||
cd ../../
|
||||
fi
|
||||
|
||||
cd qemu/qemu-latest
|
||||
rm -f tci.c
|
||||
ln -s ../../qemu_mods/tci.c tci.c
|
||||
./configure --target-list=i386-linux-user
|
||||
./configure --target-list=i386-linux-user --enable-tcg-interpreter --enable-debug-tcg --cpu=unknown
|
||||
make -j32
|
||||
|
||||
|
12
go.sh
12
go.sh
@ -1,10 +1,10 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
BIN=../tests/ctf/ezhp
|
||||
#BIN=../tests/ctf/ezhp
|
||||
#BIN=../tests/ctf/hudak
|
||||
#BIN=../tests/ctf/simple
|
||||
#SRC=../tests/hello.c
|
||||
SRC=../tests/hello.c
|
||||
#SRC=../tests/algo.c
|
||||
|
||||
if [ $SRC != "" ]; then
|
||||
@ -15,11 +15,16 @@ if [ $SRC != "" ]; then
|
||||
cd ../
|
||||
fi
|
||||
|
||||
|
||||
cd scripts
|
||||
rm -f /tmp/qira_binary
|
||||
ln -s $(realpath $BIN) /tmp/qira_binary
|
||||
#echo "hello" | ./run_qemu.sh $BIN
|
||||
#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 /tmp/qira_binary
|
||||
|
||||
: <<'END'
|
||||
echo "*** build the Program database"
|
||||
time python db_commit_asm.py $BIN $SRC
|
||||
#echo "*** filter the Change database"
|
||||
@ -30,6 +35,7 @@ echo "*** build the memory json"
|
||||
time python mem_json_extract.py
|
||||
echo "*** build the pmaps database"
|
||||
time python segment_extract.py
|
||||
END
|
||||
|
||||
#python db_commit_blocks.py
|
||||
#python memory_server.py
|
||||
|
@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
pushd .
|
||||
cd ~/build/qemu
|
||||
make -j32
|
||||
popd
|
||||
|
||||
#rm -rf /tmp/qira*
|
||||
~/build/qemu/i386-linux-user/qemu-i386 -singlestep $@
|
||||
ls -l /tmp/qira*
|
||||
|
@ -6,7 +6,7 @@ import sys
|
||||
|
||||
from pymongo import MongoClient
|
||||
|
||||
disasm = {}
|
||||
instructions = {}
|
||||
|
||||
regs = Memory()
|
||||
mem = Memory()
|
||||
@ -22,9 +22,11 @@ def process(log_entries):
|
||||
new_pmaps = pmaps.copy()
|
||||
for (address, data, clnum, flags) in dat:
|
||||
# Changes database
|
||||
db_changes.append({
|
||||
'address': address, 'type': flag_to_type(flags),
|
||||
'size': flags&SIZE_MASK, 'clnum': clnum, 'data': data})
|
||||
this_change = {'address': address, 'type': flag_to_type(flags),
|
||||
'size': flags&SIZE_MASK, 'clnum': clnum, 'data': data}
|
||||
if address in instructions:
|
||||
this_change['instruction'] = instructions[address]
|
||||
db_changes.append(this_change)
|
||||
|
||||
# update local regs and mem database
|
||||
if flags & IS_WRITE and flags & IS_MEM:
|
||||
@ -65,16 +67,19 @@ def process(log_entries):
|
||||
if __name__ == '__main__':
|
||||
print "starting QIRA middleware"
|
||||
objdump_out = subprocess.Popen(
|
||||
["objdump", "-d", sys.argv[1]],
|
||||
["objdump", "-d", "/tmp/qira_binary"],
|
||||
stdout = subprocess.PIPE).communicate()[0]
|
||||
for line in objdump_out.split("\n"):
|
||||
line = line.split("\t")
|
||||
if len(line) == 3:
|
||||
addr = int(line[0].strip(" :"), 16)
|
||||
print hex(addr), line[2]
|
||||
instructions[addr] = line[2]
|
||||
#print hex(addr), line[2]
|
||||
else:
|
||||
print line
|
||||
exit(0)
|
||||
# could get names here too, but maybe useless for now
|
||||
#print line
|
||||
pass
|
||||
print "objdump parse got",len(instructions),"instructions"
|
||||
|
||||
# connect to db, set up collections, and drop
|
||||
db = MongoClient('localhost', 3001).meteor
|
||||
|
@ -2,11 +2,12 @@
|
||||
set -e
|
||||
|
||||
pushd .
|
||||
cd ../qemu/qemu-2.0.0/
|
||||
cd ../qemu/qemu-latest/
|
||||
make -j32
|
||||
popd
|
||||
|
||||
#rm -rf /tmp/qira*
|
||||
../qemu/qemu-2.0.0/i386-linux-user/qemu-i386 -singlestep -d in_asm $@ 2> /tmp/qira_disasm
|
||||
#../qemu/qemu-latest/i386-linux-user/qemu-i386 -singlestep -d in_asm $@ 2> /tmp/qira_disasm
|
||||
../qemu/qemu-latest/i386-linux-user/qemu-i386 -singlestep $@
|
||||
ls -l /tmp/qira*
|
||||
|
||||
|
@ -26,11 +26,6 @@ Template.idump.instructions = function() {
|
||||
return changes;
|
||||
};
|
||||
|
||||
Template.idump.program_instruction = function() {
|
||||
var progdat = Program.findOne({address: this.address});
|
||||
return progdat;
|
||||
};
|
||||
|
||||
Template.idump.hexaddress = function() {
|
||||
return hex(this.address);
|
||||
};
|
||||
|
@ -37,11 +37,7 @@
|
||||
<div class="instruction">
|
||||
<div class="change {{ischange}}">{{clnum}}</div>
|
||||
<span class="datainstruction {{isiaddr}}">{{hexaddress}}</span>
|
||||
{{#with program_instruction}}
|
||||
<span class="name">{{name}}</span>
|
||||
{{instruction}}
|
||||
<span class="comment">{{comment}}</span>
|
||||
{{/with}}
|
||||
{{instruction}}
|
||||
</div>
|
||||
{{/each}}
|
||||
</template>
|
||||
|
@ -18,12 +18,7 @@ Meteor.publish('dat_clnum', function(clnum) {
|
||||
|
||||
Meteor.publish('instructions', function(clnum) {
|
||||
var changes = Change.find({clnum: {$gt: clnum-4, $lt: clnum+8}, type: "I"}, {sort: {clnum:1}});
|
||||
var query = [];
|
||||
changes.forEach(function(post) { query.push({address: post.address}); });
|
||||
if (query.length == 0) { console.log("ins query failed"); return; }
|
||||
var progdat = Program.find({$or: query});
|
||||
// we need to send the program data back here as well...
|
||||
return [changes, progdat];
|
||||
return changes;
|
||||
});
|
||||
|
||||
Meteor.publish('dat_iaddr', function(iaddr) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user