Skip to content

Commit bd705c1

Browse files
committed
Merge pull request #82 from Fuzion24/feature/cve-2015-1528
Add check for CVE-2015-1528
2 parents c24a423 + 4b3bca9 commit bd705c1

File tree

5 files changed

+169
-1
lines changed

5 files changed

+169
-1
lines changed

app/src/main/java/fuzion24/device/vulnerability/vulnerabilities/VulnerabilityOrganizer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import fuzion24.device.vulnerability.vulnerabilities.kernel.CVE_2014_3153;
2424
import fuzion24.device.vulnerability.vulnerabilities.kernel.CVE_2014_4943;
2525
import fuzion24.device.vulnerability.vulnerabilities.kernel.CVE_2015_3636;
26+
import fuzion24.device.vulnerability.vulnerabilities.system.CVE20151528;
2627
import fuzion24.device.vulnerability.vulnerabilities.system.SamsungCREDzip;
2728

2829
public class VulnerabilityOrganizer {
@@ -50,6 +51,7 @@ public static List<VulnerabilityTest> getTests(Context ctx){
5051
//tests.add(new ZergRush()); // Hide super old bugs?
5152
allTests.add(new SamsungCREDzip());
5253
allTests.add(new CVE_2015_6608());
54+
allTests.add(new CVE20151528());
5355

5456
List<VulnerabilityTest> filteredTest = new ArrayList<VulnerabilityTest>();
5557
String cpuArch1 = SystemUtils.propertyGet(ctx, "ro.product.cpu.abi");
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package fuzion24.device.vulnerability.vulnerabilities.system;
2+
3+
import android.content.Context;
4+
import android.util.Log;
5+
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
9+
import fuzion24.device.vulnerability.util.CPUArch;
10+
import fuzion24.device.vulnerability.vulnerabilities.VulnerabilityTest;
11+
12+
/**
13+
* Created by fuzion24 on 11/23/15.
14+
*/
15+
public class CVE20151528 implements VulnerabilityTest {
16+
17+
private final static String TAG = "CVE-2015-1528";
18+
19+
static {
20+
System.loadLibrary("cve20151528");
21+
}
22+
23+
@Override
24+
public String getCVEorID() {
25+
return "CVE-2015-1528";
26+
}
27+
28+
private native int doCheck();
29+
30+
@Override
31+
public boolean isVulnerable(Context context) throws Exception {
32+
int checkVal = doCheck();
33+
34+
if(checkVal == 0) {
35+
return false;
36+
}else if(checkVal == 1) {
37+
return true;
38+
}else {
39+
Log.d(TAG, "Got a return value of " + checkVal);
40+
//TODO: grab more information about failure, errno and error string
41+
throw new Exception("Error running test");
42+
}
43+
}
44+
45+
@Override
46+
public List<CPUArch> getSupportedArchitectures() {
47+
List<CPUArch> supportedArchs = new ArrayList<>();
48+
supportedArchs.add(CPUArch.ARM);
49+
supportedArchs.add(CPUArch.ARM7);
50+
supportedArchs.add(CPUArch.X86);
51+
return supportedArchs;
52+
}
53+
}

app/src/main/jni/Android.mk

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,30 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/
168168
include $(BUILD_EXECUTABLE)
169169
################################
170170

171+
172+
################################
173+
include $(CLEAR_VARS)
174+
175+
LOCAL_MODULE := cve20151528
176+
LOCAL_SRC_FILES := cve20151528.c
177+
LOCAL_LDFLAGS := -llog
178+
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/
179+
180+
include $(BUILD_SHARED_LIBRARY)
181+
################################
182+
183+
################################
184+
include $(CLEAR_VARS)
185+
186+
LOCAL_MODULE := cve20151528check
187+
LOCAL_SRC_FILES := cve20151528.c
188+
LOCAL_CFLAGS := -fpie -pie
189+
LOCAL_LDFLAGS := -pie -llog
190+
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/
191+
192+
include $(BUILD_EXECUTABLE)
193+
################################
194+
171195
################################
172196
include $(CLEAR_VARS)
173197

app/src/main/jni/Application.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ LOCAL_PATH := $(call my-dir)
22

33
include $(CLEAR_VARS)
44

5-
APP_ABI := armeabi armeabi-v7a
5+
APP_ABI := armeabi armeabi-v7a x86
66

77
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
88
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include-all

app/src/main/jni/cve20151528.c

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#include <dlfcn.h>
2+
#include <errno.h>
3+
#include <limits.h>
4+
5+
#include <stdio.h>
6+
#include <stdlib.h>
7+
#include <jni.h>
8+
#include <android/log.h>
9+
10+
//#include <cutils/native_handle.h>
11+
12+
#define LOG_TAG "CVE_2015_1528"
13+
#define LOG_D(...) do{ __android_log_print( ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__); printf( __VA_ARGS__ ); }while( 0 )
14+
15+
16+
int Check_CVE_2015_1528()
17+
{
18+
const char *libname = "libcutils.so";
19+
size_t * ( *native_handle_create )( int numFds, int numInts ) = NULL;
20+
21+
void *handle = dlopen( libname, RTLD_NOW | RTLD_GLOBAL );
22+
if( !handle )
23+
{
24+
printf( "error opening %s: %s\n", libname, dlerror() );
25+
return -1;
26+
}
27+
28+
native_handle_create = dlsym( handle, "native_handle_create" );
29+
if( !native_handle_create )
30+
{
31+
printf( "missing native_handle_create\n" );
32+
return -2;
33+
}
34+
35+
int ret = -3;
36+
37+
int numFds = 1025;
38+
int numInts = 1;
39+
size_t *bla = native_handle_create( numFds, numInts );
40+
if( !bla )
41+
{
42+
// fixed
43+
printf( "looks fixed to me\n" );
44+
ret = 0;
45+
goto done;
46+
}
47+
48+
// sanity checks
49+
switch(bla[0])// version
50+
{
51+
case 12://android wear 5.0.2 LWX49K
52+
if( bla[1] != numFds || bla[2] != numInts )
53+
{
54+
LOG_D( "got back unexpected values\n" );
55+
}
56+
else
57+
{
58+
LOG_D( "its vulnerable\n" );
59+
return 1;
60+
}
61+
break;
62+
default:
63+
LOG_D( "failed. version %d %d %d\n", bla[0], bla[1], bla[2] );
64+
break;
65+
}
66+
67+
68+
done:
69+
// done with this
70+
dlclose( handle );
71+
72+
// should be allocated with malloc
73+
//! if its already null, then free does nothing
74+
free( bla );
75+
76+
return ret;
77+
}
78+
79+
80+
JNIEXPORT jint JNICALL Java_fuzion24_device_vulnerability_vulnerabilities_system_CVE20151528_doCheck(JNIEnv *env, jobject obj)
81+
{
82+
return Check_CVE_2015_1528();
83+
}
84+
85+
86+
int main( int argc, char *argv[] )
87+
{
88+
return Check_CVE_2015_1528();
89+
}

0 commit comments

Comments
 (0)