-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFuzzingDroid.java
197 lines (169 loc) · 7.58 KB
/
FuzzingDroid.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
package android.fuzzingDroid;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.Random;
import android.app.ActivityManagerNative;
import android.app.IActivityManager;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageParser;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.Parcelable;
import android.util.Slog;
public class FuzzingDroid {
public static Random randomGenerator = new Random();
public static boolean getBooleanValue() {
boolean[] candidates = {true, false};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static boolean[] getBooleanArrayValue() {
boolean[][] candidates = {{true,false}, {}, null};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static char getCharValue() {
char[] candidates = {'\0', 'A', 'a', '*', '0', (char)1, (char)255};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static char[] getCharArrayValue() {
char[][] candidates = {{'1','0','0','8','6'}, {'!','@','#','$','%','^','&','*','(',')','\"'}, {}, null};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static byte getByteValue() {
byte[] candidates = {(byte)1, (byte)8, (byte)255};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static byte[] getByteArrayValue() {
byte[][] candidates = {{(byte)1, (byte)8, (byte)255}, {}, null};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static double getDoubleValue() {
double[] candidates = {Double.MAX_VALUE, Double.MIN_VALUE, Double.NaN};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static double[] getDoubleArrayValue() {
double[][] candidates = {{Double.MAX_VALUE, Double.MIN_VALUE, Double.NaN}, {}, null};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static float getFloatValue() {
float[] candidates = {Float.MAX_VALUE, Float.MIN_VALUE, Float.NaN};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static float[] getFloatArrayValue() {
float[][] candidates = {{Float.MAX_VALUE, Float.MIN_VALUE, Float.NaN}, {}, null};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static int getIntValue() {
int[] candidates = {Integer.MAX_VALUE, Integer.MIN_VALUE, 0};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static int[] getIntArrayValue() {
int[][] candidates = {{Integer.MAX_VALUE, Integer.MIN_VALUE, 0}, {}, null};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static ArrayList<Integer> getIntegerArrayListValue() {
ArrayList<ArrayList<Integer>> candidates = new ArrayList<ArrayList<Integer>>();
ArrayList<Integer> list1 = new ArrayList<Integer>();
list1.add(Integer.MAX_VALUE);list1.add(Integer.MIN_VALUE);list1.add(0);
ArrayList<Integer> list2 = new ArrayList<Integer>();
candidates.add(list1);
candidates.add(list2);
candidates.add(null);
int index = randomGenerator.nextInt(candidates.size());
return candidates.get(index);
}
public static CharSequence getCharSequenceValue() {
CharSequence[] candidates = {"asdf!@#$%^&*()[]{}<>123?\"\'", ""};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static CharSequence[] getCharSequenceArrayValue() {
CharSequence[][] candidates = {{"asdf!@#$%^&*()[]{}<>123?\"\'", ""}, {}, null};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static ArrayList<CharSequence> getCharSequenceArrayListValue() {
ArrayList<ArrayList<CharSequence>> candidates = new ArrayList<ArrayList<CharSequence>>();
ArrayList<CharSequence> list1 = new ArrayList<CharSequence>();
list1.add("asdf!@#$%^&*()[]{}<>123?\"\'");list1.add("");
ArrayList<CharSequence> list2 = new ArrayList<CharSequence>();
candidates.add(list1);
candidates.add(list2);
candidates.add(null);
int index = randomGenerator.nextInt(candidates.size());
return candidates.get(index);
}
public static long getLongValue() {
long[] candidates = {Long.MAX_VALUE, Long.MIN_VALUE, (long) 0};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static long[] getLongArrayValue() {
long[][] candidates = {{Long.MAX_VALUE, Long.MIN_VALUE, (long) 0}, {}, null};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static short getShortValue() {
short[] candidates = {Short.MAX_VALUE, Short.MIN_VALUE, (short) 0};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static short[] getShortArrayValue() {
short[][] candidates = {{Short.MAX_VALUE, Short.MIN_VALUE, (short) 0}, {}, null};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static String getStringValue() {
String[] candidates = {"214-499-6577", "[email protected]", "07/01/1990", ""};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static String[] getStringArrayValue() {
String[][] candidates = {{"214-499-6577", "[email protected]", "07/01/1990", ""}, {}, null};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static ArrayList<String> getStringArrayListValue() {
ArrayList<ArrayList<String>> candidates = new ArrayList<ArrayList<String>>();
ArrayList<String> list1 = new ArrayList<String>();
list1.add("asdf!@#$%^&*()[]{}<>123?\"\'");list1.add("214-499-6577");list1.add("[email protected]");list1.add("07/01/1990");list1.add("");
ArrayList<String> list2 = new ArrayList<String>();
candidates.add(list1);
candidates.add(list2);
candidates.add(null);
int index = randomGenerator.nextInt(candidates.size());
return candidates.get(index);
}
public static Parcelable[] getParcelableArrayValue() {
Parcelable[][] candidates = {{null, null, null, null}, {}, null};
int index = randomGenerator.nextInt(candidates.length);
return candidates[index];
}
public static <T extends Parcelable> ArrayList<T> getParcelableArrayListValue() {
ArrayList<ArrayList<T>> candidates = new ArrayList<ArrayList<T>>();
ArrayList<T> list1 = new ArrayList<T>();
list1.add(null);list1.add(null);list1.add(null);list1.add(null);
ArrayList<T> list2 = new ArrayList<T>();
candidates.add(list1);
candidates.add(list2);
candidates.add(null);
int index = randomGenerator.nextInt(candidates.size());
return candidates.get(index);
}
}