コード例 #1
0
 @Override
 public String getOriginalAssembly() {
   return "sget-wide "
       + regTo1.getOriginalIndexString()
       + "|"
       + regTo2.getOriginalIndexString()
       + ", "
       + fieldClass.getPrettyName()
       + "."
       + fieldName;
 }
コード例 #2
0
  @Override
  public void instrument(DexCode_InstrumentationState state) {
    val code = getMethodCode();
    val classHierarchy = getParentFile().getHierarchy();

    val defClass = classHierarchy.getBaseClassDefinition(fieldClass);
    val defField = defClass.getAccessedStaticField(new DexFieldId(fieldName, fieldType));

    if (defField == null)
      System.err.println(
          "warning: cannot find accessed static field "
              + fieldClass.getPrettyName()
              + "."
              + fieldName);

    val fieldDeclaringClass = defField.getParentClass();

    if (fieldDeclaringClass.isInternal()) {
      // FIELD OF PRIMITIVE TYPE DEFINED INTERNALLY
      // retrieve taint from the adjoined field
      val field =
          DexUtils.getField(
              getParentFile(), fieldDeclaringClass.getClassType(), fieldName, fieldType);
      code.replace(
          this,
          new DexCodeElement[] {
            this,
            new DexInstruction_StaticGet(
                code, state.getTaintRegister(regTo1), state.getCache().getTaintField(field))
          });
    } else {
      // FIELD OF PRIMITIVE TYPE DEFINED EXTERNALLY
      // get the taint from adjoined field in special global class
      code.replace(
          this,
          new DexCodeElement[] {
            this,
            new DexInstruction_StaticGet(
                code,
                state.getTaintRegister(regTo1),
                state
                    .getCache()
                    .getTaintField_ExternalStatic(
                        fieldClass, (DexPrimitiveType) fieldType, fieldName))
          });
    }
  }
コード例 #3
0
  public DexInstruction_StaticGetWide(
      DexCode methodCode, Instruction insn, DexCode_ParsingState parsingState)
      throws InstructionParsingException, UnknownTypeException {
    super(methodCode);

    if (insn instanceof Instruction21c && insn.opcode == Opcode.SGET_WIDE) {

      val insnStaticGet = (Instruction21c) insn;
      val refItem = (FieldIdItem) insnStaticGet.getReferencedItem();
      regTo1 = parsingState.getRegister(insnStaticGet.getRegisterA());
      regTo2 = parsingState.getRegister(insnStaticGet.getRegisterA() + 1);
      fieldClass =
          DexClassType.parse(
              refItem.getContainingClass().getTypeDescriptor(), parsingState.getCache());
      fieldType =
          DexRegisterType.parse(
              refItem.getFieldType().getTypeDescriptor(), parsingState.getCache());
      fieldName = refItem.getFieldName().getStringValue();

    } else throw FORMAT_EXCEPTION;

    Opcode_GetPutWide.checkTypeIsWide(this.fieldType);
  }