def model_File_getAbsolutePath(call, resolved_this, resolved_params_list): resolve_dict = dict() obj_list = None if isinstance(resolved_this.value, values.MultiValue): obj_list = resolved_this.value.assignment_list else: obj_list = [resolved_this.value] ret_list = [] for obj in obj_list: if isinstance(obj, values.ObjectValue) and FILE_STATE in obj.state: ret_list.append(obj.state[FILE_STATE]) else: ret_list.append(obj) if len(ret_list) > 1: ret = values.MultiValue(ret_list) else: ret = ret_list[0] resolve_dict[RETURN] = ret return resolve_dict
def model_StringBuilder_append(call, resolved_this, resolved_params_list): resolve_dict = dict() obj_list = None if isinstance(resolved_this.value, values.MultiValue): obj_list = resolved_this.value.assignment_list else: obj_list = [resolved_this.value] for obj in obj_list: if not isinstance(obj, values.ObjectValue): raise Exception("Not an object value! {}".format(obj)) for param in resolved_params_list: if isinstance(param.value, values.ObjectValue ) and STRINGBUILDER_STATE in param.value.state: obj.state[STRINGBUILDER_STATE].extend( param.value.state[STRINGBUILDER_STATE]) else: obj.state[STRINGBUILDER_STATE].append(param.value) if len(obj_list) > 1: obj = values.MultiValue(obj_list) else: obj = obj_list[0] resolve_dict[resolved_this.reg] = obj resolve_dict[RETURN] = obj return resolve_dict
def model_File_getParentFile(call, resolved_this, resolved_params_list): resolve_dict = dict() obj_list = None if isinstance(resolved_this.value, values.MultiValue): obj_list = resolved_this.value.assignment_list else: obj_list = [resolved_this.value] ret_list = [] for obj in obj_list: if not isinstance(obj, values.ObjectValue): ret_list.append("Parent({})".format(obj)) else: ret_list.append("Parent({})".format(obj.state[FILE_STATE])) if len(ret_list) > 1: ret = values.MultiValue(ret_list) else: ret = ret_list[0] resolve_dict[RETURN] = ret return resolve_dict
def model_File_init(call, resolved_this, resolved_params_list): resolve_dict = dict() obj_list = None if isinstance(resolved_this.value, values.MultiValue): obj_list = resolved_this.value.assignment_list else: obj_list = [resolved_this.value] for obj in obj_list: if not isinstance(obj, values.ObjectValue): raise Exception("Not an object value! {}".format(obj)) obj.state[FILE_STATE] = values.AppendValue([], type=None) for param in resolved_params_list: if isinstance( param.value, values.ObjectValue) and FILE_STATE in param.value.state: obj.state[FILE_STATE].extend(param.value.state[FILE_STATE]) else: obj.state[FILE_STATE].append(param.value) if len(obj_list) > 1: obj = values.MultiValue(obj_list) else: obj = obj_list[0] resolve_dict[resolved_this.reg] = obj return resolve_dict
def model_String_toLowerCase(call, resolved_this, resolved_params_list): resolve_dict = dict() str_list = None if isinstance(resolved_this.value, values.MultiValue): str_list = resolved_this.value.assignment_list else: str_list = [resolved_this.value] val_list = list() for s in str_list: if not isinstance(s, str): raise Exception("Not a string! {}".format(s)) val_list.append(s.lower()) if len(val_list) > 1: val = values.MultiValue(val_list) else: val = val_list[0] resolve_dict[RETURN] = val return resolve_dict
def model_StringBuilder_init(call, resolved_this, resolved_params_list): resolve_dict = dict() obj_list = None if isinstance(resolved_this.value, values.MultiValue): obj_list = resolved_this.value.assignment_list else: obj_list = [resolved_this.value] for obj in obj_list: if not isinstance(obj, values.ObjectValue): raise Exception("Not an object value! {} - {}".format( obj, type(obj))) obj.state[STRINGBUILDER_STATE] = list() if re.match("Ljava/lang/StringBuilder;\.<init>\(I\)V", str(call.dex_method) ) is None: # ignore the integer capacity init # any further params are just appends for param in resolved_params_list: obj.state[STRINGBUILDER_STATE].append(param.value) if len(obj_list) > 1: obj = values.MultiValue(obj_list) else: obj = obj_list[0] resolve_dict[resolved_this.reg] = obj resolve_dict[RETURN] = obj return resolve_dict
def model_String_concat(call, resolved_this, resolved_params_list): resolve_dict = dict() str_list = None if isinstance(resolved_this.value, values.MultiValue): str_list = resolved_this.value.assignment_list else: str_list = [resolved_this.value] val_list = list() for s in str_list: if isinstance(s, dextypes.dex_string): s = str(s) if not isinstance(s, str): raise Exception("Not a string! {} - {}".format(s, type(s))) if isinstance(resolved_params_list[0].value, values.MultiValue): for concat in resolved_params_list[0].value.assignment_list: val_list.append( values.AppendValue([s, concat], "Ljava/lang/String;")) else: val_list.append( values.AppendValue([s, resolved_params_list[0].value], "Ljava/lang/String;")) if len(val_list) > 1: val = values.MultiValue(val_list) else: val = val_list[0] resolve_dict[RETURN] = val return resolve_dict
def model_String_init(call, resolved_this, resolved_params_list): resolve_dict = dict() # first param is the string obj_list = None if isinstance(resolved_params_list[0].value, values.MultiValue): obj_list = resolved_params_list[0].value.assignment_list else: obj_list = [resolved_params_list[0].value] if len(obj_list) > 1: obj = values.MultiValue(obj_list) else: obj = obj_list[0] resolve_dict[resolved_params_list[0].reg] = obj resolve_dict[RETURN] = obj return resolve_dict
def model_StringBuilder_toString(call, resolved_this, resolved_params_list): resolve_dict = dict() obj_list = None if isinstance(resolved_this.value, values.MultiValue): obj_list = resolved_this.value.assignment_list else: obj_list = [resolved_this.value] val_list = list() for obj in obj_list: if not isinstance(obj, values.ObjectValue): raise Exception("Not an object value! {}".format(obj)) built_string = list() for idx, chunk in enumerate(obj.state[STRINGBUILDER_STATE]): if isinstance(chunk, values.Value): # need to add some print markers #if idx != 0: # built_string += " + " built_string.append(chunk) else: # string #if idx != 0: # if isinstance(obj.state[STRINGBUILDER_STATE][idx-1], Value): # # previous chunk was not a string - add a plus # built_string += " + " built_string.append(chunk) val_list.append(values.AppendValue(built_string, "Ljava/lang/String;")) if len(val_list) > 1: val = values.MultiValue(val_list) else: val = val_list[0] resolve_dict[RETURN] = val return resolve_dict