mirror of
https://github.com/geohot/qira
synced 2024-12-24 13:06:48 +03:00
Touchups for Mac and twilight (#262)
* update socket.io
* add no-run and enable debugging
* Revert "update socket.io"
This reverts commit f26dad9e62
.
* support no_delete_runs
* disable js debugging
* don't use is, add debugging to Trace
* fix bug with dot using tabs
This commit is contained in:
parent
080e6b18fd
commit
5f34406410
@ -28,6 +28,8 @@ if __name__ == '__main__':
|
||||
parser.add_argument("--web-port", metavar="PORT", help="listen port for web interface. 3002 by default", type=int, default=qira_config.WEB_PORT)
|
||||
parser.add_argument("--socat-port", metavar="PORT", help="listen port for socat. 4000 by default", type=int, default=qira_config.SOCAT_PORT)
|
||||
parser.add_argument('-S', '--static', help="enable static2", action="store_true")
|
||||
parser.add_argument('--no-run', help="don't run the program", action="store_true")
|
||||
parser.add_argument('--no-delete-runs', help="don't clear the logs", action="store_true")
|
||||
#capstone flag in qira_config for now
|
||||
|
||||
# parse arguments, first try
|
||||
@ -89,14 +91,15 @@ if __name__ == '__main__':
|
||||
except:
|
||||
is_qira_running = 0
|
||||
print("no qira server found, starting it")
|
||||
program.clear()
|
||||
program.clear(not args.no_delete_runs)
|
||||
|
||||
# start the binary runner
|
||||
if args.server:
|
||||
qira_socat.start_bindserver(program, qira_config.SOCAT_PORT, -1, 1, True)
|
||||
else:
|
||||
print("**** running",program.program)
|
||||
program.execqira(shouldfork=not is_qira_running)
|
||||
if not args.no_run:
|
||||
print("**** running",program.program)
|
||||
program.execqira(shouldfork=not is_qira_running)
|
||||
|
||||
if not is_qira_running:
|
||||
# start the http server
|
||||
|
@ -373,16 +373,16 @@ def analyse_calls(trace):
|
||||
rchanges = filter(lambda x:x['type'] in "RW",trace.db.fetch_changes_by_clnum(cl, -1))
|
||||
for rchange in rchanges:
|
||||
regnum = rchange['address']//rsize
|
||||
if rchange['type'] is 'W' and regnum < nregs:
|
||||
if rchange['type'] == 'W' and regnum < nregs:
|
||||
init_regs.add(regnum)
|
||||
if ((regnum) in uninit_regs) and (rchange['data'] == regs[regnum]):
|
||||
#if we thought they did an uninitialized read and they just clobbered it and wrote it later,
|
||||
#don't consider this a possible argument
|
||||
uninit_regs.remove(regnum)
|
||||
elif (rchange['type'] is 'R' and regnum < nregs) and (regnum not in init_regs):
|
||||
elif (rchange['type'] == 'R' and regnum < nregs) and (regnum not in init_regs):
|
||||
uninit_regs.add(regnum)
|
||||
abi,nargs = guess_calling_conv(program,uninit_regs,((seen-esp)/rsize) if (seen > 0) else 0)
|
||||
if func.abi is 'UNKNOWN':
|
||||
if func.abi == 'UNKNOWN':
|
||||
func.abi = abi
|
||||
func.nargs = max(nargs,func.nargs)
|
||||
|
||||
@ -394,7 +394,7 @@ def display_call_args(instr,trace,clnum):
|
||||
program.static.analyzer.make_function_at(program.static,iptr)
|
||||
|
||||
func = program.static[iptr]['function']
|
||||
if func.abi is 'UNKNOWN':
|
||||
if func.abi == 'UNKNOWN':
|
||||
return ""
|
||||
|
||||
endclnum = get_last_instr(trace.dmap,clnum)
|
||||
|
@ -285,10 +285,11 @@ class Program:
|
||||
else:
|
||||
raise Exception("unknown binary type")
|
||||
|
||||
def clear(self):
|
||||
def clear(self, delete_old_runs=True):
|
||||
# probably always good to do except in development of middleware
|
||||
print("*** deleting old runs")
|
||||
self.delete_old_runs()
|
||||
if delete_old_runs:
|
||||
print("*** deleting old runs")
|
||||
self.delete_old_runs()
|
||||
|
||||
# getting asm from qemu
|
||||
self.create_asm_file()
|
||||
|
@ -18,6 +18,8 @@
|
||||
#define PAGE_MASK 0xFFFFFFFFFFFFF000LL
|
||||
#define INVALID_CLNUM 0xFFFFFFFF
|
||||
|
||||
int DEBUG_TRACE = getenv("DEBUG_TRACE") != NULL ? atoi(getenv("DEBUG_TRACE")) : 0;
|
||||
|
||||
void *thread_entry(void *trace_class) {
|
||||
Trace *t = (Trace *)trace_class; // best c++ casting
|
||||
|
||||
@ -74,12 +76,13 @@ char Trace::get_type_from_flags(uint32_t flags) {
|
||||
}
|
||||
|
||||
inline void Trace::commit_memory(Clnum clnum, Address a, uint8_t d) {
|
||||
if (DEBUG_TRACE) printf("DEBUG_TRACE: commit_memory at %u address: %llx data: %x\n", clnum, a, d);
|
||||
pair<map<Address, MemoryCell>::iterator, bool> ret = memory_.insert(MP(a, MemoryCell()));
|
||||
ret.first->second[clnum] = d;
|
||||
}
|
||||
|
||||
inline MemoryWithValid Trace::get_byte(Clnum clnum, Address a) {
|
||||
//printf("get_byte %u %llx\n", clnum, a);
|
||||
if (DEBUG_TRACE >= 2) printf("DEBUG_TRACE: get_byte %u %llx\n", clnum, a);
|
||||
map<Address, MemoryCell>::iterator it = memory_.find(a);
|
||||
if (it == memory_.end()) return 0;
|
||||
|
||||
@ -130,6 +133,8 @@ bool Trace::remap_backing(uint64_t new_size) {
|
||||
}
|
||||
|
||||
bool Trace::ConnectToFileAndStart(char *filename, unsigned int trace_index, int register_size, int register_count, bool is_big_endian) {
|
||||
if (DEBUG_TRACE) printf("DEBUG_TRACE: constructing Trace with file %s\n", filename);
|
||||
|
||||
trace_index_ = trace_index;
|
||||
is_big_endian_ = is_big_endian;
|
||||
register_size_ = register_size;
|
||||
@ -184,6 +189,7 @@ void Trace::process() {
|
||||
// no need to lock this here, because this is the only thread that changes it
|
||||
const struct change *c = &backing_[entries_done_];
|
||||
char type = get_type_from_flags(c->flags);
|
||||
if (DEBUG_TRACE >= 2) printf("DEBUG_TRACE: parsing change %d with type %c\n", c->clnum, type);
|
||||
|
||||
RWLOCK_WRLOCK(db_lock_);
|
||||
// clnum_to_entry_number_, instruction_pages_
|
||||
|
@ -190,10 +190,9 @@ Graph.prototype.render = function() {
|
||||
|
||||
} else {
|
||||
// this is a vertex
|
||||
var addr = resp[i].split(' ')[0].split('N')[1].trim();
|
||||
var addr = resp[i].split(' ')[0].split('N')[1].split('\t')[0].trim();
|
||||
var pos = resp[i].slice(resp[i].indexOf('pos=')).split('"')[1].split(',');
|
||||
|
||||
//p(addr);
|
||||
var r = this.vertices[addr].rendered;
|
||||
|
||||
if (r !== undefined) {
|
||||
|
Loading…
Reference in New Issue
Block a user