From da6b7a53322813fc87712b2e6d5dfbef37f8fa5a Mon Sep 17 00:00:00 2001 From: George Hotz Date: Wed, 2 Jul 2014 00:19:44 -0700 Subject: [PATCH] half builds at home, missing meteor dir --- .gitignore | 1 + deps.sh | 4 +++ fetchqemu.sh | 12 ++++++++ go.sh | 2 +- scripts/db_commit_asm.py | 57 ++++++++++++++++++++---------------- mongo.sh => scripts/mongo.sh | 2 +- scripts/run_qemu.sh | 6 ++-- 7 files changed, 54 insertions(+), 30 deletions(-) create mode 100755 deps.sh create mode 100755 fetchqemu.sh rename mongo.sh => scripts/mongo.sh (90%) diff --git a/.gitignore b/.gitignore index a73dee70..b0b0091e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ ida_plugin/qira.plx tests/idb qiradb/qiradb db/ +qemu/ diff --git a/deps.sh b/deps.sh new file mode 100755 index 00000000..e2b0d12a --- /dev/null +++ b/deps.sh @@ -0,0 +1,4 @@ +#!/bin/bash +sudo pip install pymongo +curl -k https://install.meteor.com | /bin/sh + diff --git a/fetchqemu.sh b/fetchqemu.sh new file mode 100755 index 00000000..f2599fac --- /dev/null +++ b/fetchqemu.sh @@ -0,0 +1,12 @@ +#!/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 +ln -s ../../qemu_mods/tci.c tci.c +./configure --target-list=i386-linux-user +make -j32 + diff --git a/go.sh b/go.sh index 8c6a7714..ebb216da 100755 --- a/go.sh +++ b/go.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e BIN=../tests/ctf/ezhp diff --git a/scripts/db_commit_asm.py b/scripts/db_commit_asm.py index 49594eaa..427f46e1 100644 --- a/scripts/db_commit_asm.py +++ b/scripts/db_commit_asm.py @@ -1,5 +1,4 @@ from pymongo import MongoClient -from elftools.elf.elffile import ELFFile import sys db = MongoClient('localhost', 3001).meteor @@ -8,31 +7,39 @@ ds = [] sdict = {} cdict = {} -elf = ELFFile(open(sys.argv[1])) -for section in elf.iter_sections(): - try: - for symbol in section.iter_symbols(): - if len(symbol.name) > 0: - sdict[symbol['st_value']] = symbol.name - except: - pass +has_elf_tools = 0 +try: + from elftools.elf.elffile import ELFFile + has_elf_tools = 1 +except: + print "no elf tools found" -if elf.has_dwarf_info() and len(sys.argv) > 2: - src = open(sys.argv[2]).read().split("\n") - di = elf.get_dwarf_info() - for CU in di.iter_CUs(): - for DIE in CU.iter_DIEs(): - #print DIE - if DIE.tag == 'DW_TAG_subprogram': - try: - lowpc = DIE.attributes['DW_AT_low_pc'].value - highpc = DIE.attributes['DW_AT_high_pc'].value - fil = DIE.attributes['DW_AT_decl_file'] - line = DIE.attributes['DW_AT_decl_line'].value - except: - pass - print lowpc, highpc, fil, line, src[line] - cdict[lowpc] = src[line] +if has_elf_tools: + elf = ELFFile(open(sys.argv[1])) + for section in elf.iter_sections(): + try: + for symbol in section.iter_symbols(): + if len(symbol.name) > 0: + sdict[symbol['st_value']] = symbol.name + except: + pass + + if elf.has_dwarf_info() and len(sys.argv) > 2: + src = open(sys.argv[2]).read().split("\n") + di = elf.get_dwarf_info() + for CU in di.iter_CUs(): + for DIE in CU.iter_DIEs(): + #print DIE + if DIE.tag == 'DW_TAG_subprogram': + try: + lowpc = DIE.attributes['DW_AT_low_pc'].value + highpc = DIE.attributes['DW_AT_high_pc'].value + fil = DIE.attributes['DW_AT_decl_file'] + line = DIE.attributes['DW_AT_decl_line'].value + except: + pass + print lowpc, highpc, fil, line, src[line] + cdict[lowpc] = src[line] dat = open("/tmp/qira_disasm").read().split("\n") for d in dat: diff --git a/mongo.sh b/scripts/mongo.sh similarity index 90% rename from mongo.sh rename to scripts/mongo.sh index 3fec9f4a..2bce3c86 100755 --- a/mongo.sh +++ b/scripts/mongo.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e numactl --interleave=all ~/build/mongodb-linux-x86_64-2.6.3/bin/mongod --dbpath=$(pwd)/db --bind_ip 127.0.0.1 diff --git a/scripts/run_qemu.sh b/scripts/run_qemu.sh index 0e67a44a..768b6c9d 100755 --- a/scripts/run_qemu.sh +++ b/scripts/run_qemu.sh @@ -1,12 +1,12 @@ -#!/bin/sh +#!/bin/bash set -e pushd . -cd ~/build/qemu +cd ../qemu/qemu-2.0.0/ make -j32 popd #rm -rf /tmp/qira* -~/build/qemu/i386-linux-user/qemu-i386 -singlestep -d in_asm $@ 2> /tmp/qira_disasm +../qemu/qemu-2.0.0/i386-linux-user/qemu-i386 -singlestep -d in_asm $@ 2> /tmp/qira_disasm ls -l /tmp/qira*