Set up testing infrastructure ("make test")
This commit is contained in:
@@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
Nguyen Tan Cong <shenlongbk@gmail.com>
|
||||
*/
|
||||
|
||||
package samples;
|
||||
|
||||
import unicorn.*;
|
||||
import java.util.*;
|
||||
|
||||
@@ -430,7 +432,7 @@ public class SampleNetworkAuditing {
|
||||
}
|
||||
// end utilities
|
||||
|
||||
static void test_i386(byte[] code) {
|
||||
public static void test_i386(byte[] code) {
|
||||
fd_chains.clean();
|
||||
System.out.printf("Emulate i386 code\n");
|
||||
try {
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
/* Sample code to demonstrate how to emulate ARM code */
|
||||
|
||||
package samples;
|
||||
|
||||
import unicorn.*;
|
||||
|
||||
public class Sample_arm {
|
||||
@@ -41,7 +43,7 @@ public class Sample_arm {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_arm() {
|
||||
public static void test_arm() {
|
||||
|
||||
Long r0 = 0x1234L; // R0 register
|
||||
Long r2 = 0x6789L; // R1 register
|
||||
@@ -85,7 +87,7 @@ public class Sample_arm {
|
||||
u.close();
|
||||
}
|
||||
|
||||
static void test_thumb() {
|
||||
public static void test_thumb() {
|
||||
|
||||
Long sp = 0x1234L; // R0 register
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
/* Sample code to demonstrate how to emulate ARM64 code */
|
||||
|
||||
package samples;
|
||||
|
||||
import unicorn.*;
|
||||
|
||||
public class Sample_arm64 {
|
||||
@@ -70,7 +72,7 @@ public class Sample_arm64 {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_arm64() {
|
||||
public static void test_arm64() {
|
||||
|
||||
Long x11 = 0x1234L; // X11 register
|
||||
Long x13 = 0x6789L; // X13 register
|
||||
|
||||
@@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
/* Sample code to demonstrate how to emulate m68k code */
|
||||
|
||||
package samples;
|
||||
|
||||
import unicorn.*;
|
||||
|
||||
public class Sample_m68k {
|
||||
@@ -70,7 +72,7 @@ public class Sample_m68k {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_m68k() {
|
||||
public static void test_m68k() {
|
||||
Long d0 = 0x0000L; // d0 data register
|
||||
Long d1 = 0x0000L; // d1 data register
|
||||
Long d2 = 0x0000L; // d2 data register
|
||||
|
||||
@@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
/* Sample code to demonstrate how to emulate Mips code (big endian) */
|
||||
|
||||
package samples;
|
||||
|
||||
import unicorn.*;
|
||||
|
||||
public class Sample_mips {
|
||||
@@ -71,7 +73,7 @@ public class Sample_mips {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_mips_eb() {
|
||||
public static void test_mips_eb() {
|
||||
|
||||
Long r1 = 0x6789L; // R1 register
|
||||
|
||||
@@ -109,7 +111,7 @@ public class Sample_mips {
|
||||
u.close();
|
||||
}
|
||||
|
||||
static void test_mips_el() {
|
||||
public static void test_mips_el() {
|
||||
Long r1 = 0x6789L; // R1 register
|
||||
|
||||
System.out.print("===========================\n");
|
||||
|
||||
@@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
/* Sample code to demonstrate how to emulate Sparc code */
|
||||
|
||||
package samples;
|
||||
|
||||
import unicorn.*;
|
||||
|
||||
public class Sample_sparc {
|
||||
@@ -71,7 +73,7 @@ public class Sample_sparc {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_sparc() {
|
||||
public static void test_sparc() {
|
||||
Long g1 = 0x1230L; // G1 register
|
||||
Long g2 = 0x6789L; // G2 register
|
||||
Long g3 = 0x5555L; // G3 register
|
||||
|
||||
@@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
/* Sample code to demonstrate how to emulate X86 code */
|
||||
|
||||
package samples;
|
||||
|
||||
import unicorn.*;
|
||||
|
||||
public class Sample_x86 {
|
||||
@@ -200,7 +202,7 @@ public class Sample_x86 {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_i386() {
|
||||
public static void test_i386() {
|
||||
Long r_ecx = 0x1234L; // ECX register
|
||||
Long r_edx = 0x7890L; // EDX register
|
||||
|
||||
@@ -266,7 +268,7 @@ public class Sample_x86 {
|
||||
uc.close();
|
||||
}
|
||||
|
||||
static void test_i386_inout() {
|
||||
public static void test_i386_inout() {
|
||||
Long r_eax = 0x1234L; // ECX register
|
||||
Long r_ecx = 0x6789L; // EDX register
|
||||
|
||||
@@ -311,7 +313,7 @@ public class Sample_x86 {
|
||||
u.close();
|
||||
}
|
||||
|
||||
static void test_i386_jump() {
|
||||
public static void test_i386_jump() {
|
||||
System.out.print("===================================\n");
|
||||
System.out.print("Emulate i386 code with jump\n");
|
||||
|
||||
@@ -339,7 +341,7 @@ public class Sample_x86 {
|
||||
}
|
||||
|
||||
// emulate code that loop forever
|
||||
static void test_i386_loop() {
|
||||
public static void test_i386_loop() {
|
||||
Long r_ecx = 0x1234L; // ECX register
|
||||
Long r_edx = 0x7890L; // EDX register
|
||||
|
||||
@@ -376,7 +378,7 @@ public class Sample_x86 {
|
||||
}
|
||||
|
||||
// emulate code that read invalid memory
|
||||
static void test_i386_invalid_mem_read() {
|
||||
public static void test_i386_invalid_mem_read() {
|
||||
Long r_ecx = 0x1234L; // ECX register
|
||||
Long r_edx = 0x7890L; // EDX register
|
||||
|
||||
@@ -424,7 +426,7 @@ public class Sample_x86 {
|
||||
}
|
||||
|
||||
// emulate code that read invalid memory
|
||||
static void test_i386_invalid_mem_write() {
|
||||
public static void test_i386_invalid_mem_write() {
|
||||
Long r_ecx = 0x1234L; // ECX register
|
||||
Long r_edx = 0x7890L; // EDX register
|
||||
|
||||
@@ -489,7 +491,7 @@ public class Sample_x86 {
|
||||
}
|
||||
|
||||
// emulate code that jump to invalid memory
|
||||
static void test_i386_jump_invalid() {
|
||||
public static void test_i386_jump_invalid() {
|
||||
Long r_ecx = 0x1234L; // ECX register
|
||||
Long r_edx = 0x7890L; // EDX register
|
||||
|
||||
@@ -535,7 +537,7 @@ public class Sample_x86 {
|
||||
u.close();
|
||||
}
|
||||
|
||||
static void test_x86_64() {
|
||||
public static void test_x86_64() {
|
||||
long rax = 0x71f3029efd49d41dL;
|
||||
long rbx = 0xd87b45277f133ddbL;
|
||||
long rcx = 0xab40d1ffd8afc461L;
|
||||
@@ -634,7 +636,7 @@ public class Sample_x86 {
|
||||
u.close();
|
||||
}
|
||||
|
||||
static void test_x86_16() {
|
||||
public static void test_x86_16() {
|
||||
Long eax = 7L;
|
||||
Long ebx = 5L;
|
||||
Long esi = 6L;
|
||||
|
||||
@@ -21,11 +21,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
/* Sample code to demonstrate how to register read/write API */
|
||||
|
||||
package samples;
|
||||
|
||||
import unicorn.*;
|
||||
|
||||
public class Sample_x86_mmr {
|
||||
|
||||
static void test_x86_mmr() {
|
||||
public static void test_x86_mmr() {
|
||||
// Initialize emulator in X86-32bit mode
|
||||
Unicorn uc;
|
||||
try {
|
||||
|
||||
@@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
/* Sample code to trace code with Linux code with syscall */
|
||||
|
||||
package samples;
|
||||
|
||||
import unicorn.*;
|
||||
|
||||
public class Shellcode {
|
||||
@@ -125,7 +127,7 @@ public class Shellcode {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_i386() {
|
||||
public static void test_i386() {
|
||||
Long r_esp = ADDRESS + 0x200000L; // ESP register
|
||||
|
||||
System.out.print("Emulate i386 code\n");
|
||||
|
||||
Reference in New Issue
Block a user