-
Notifications
You must be signed in to change notification settings - Fork 271
Feature/dirty cow #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iRave
wants to merge
9
commits into
AndroidVTS:master
Choose a base branch
from
iRave:feature/DirtyCow
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature/dirty cow #139
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e61f9c3
update grade to version 2.2.2
iRave aeab923
Add CMake to project (temporarily, to make code debuggable), Update t…
iRave 2ba2ab8
Add dirtyCow vulnerability test
iRave 5df2c4b
Change Loop run-count, to speed up speed test. new value should still…
iRave bb94ead
Remove unnecessary comments from dirtycow.c
iRave 4b4598c
Add logging to DirtyCOW C code
iRave f2e4141
Fix DirtyCOW memory leaks (files not closed)
iRave 50f7adc
Fix dirtyCow filename mismatch (dirtyCow.c=>dirtycow.c)
S-trace 70cb5ce
Merge pull request #1 from S-trace/feature/DirtyCow
iRave File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Sets the minimum version of CMake required to build the native | ||
# library. You should either keep the default value or only pass a | ||
# value of 3.4.0 or lower. | ||
|
||
cmake_minimum_required(VERSION 3.4.1) | ||
|
||
# set binary output folder to libs folder | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/main/libs/${ANDROID_ABI}") | ||
|
||
add_library( dirtyCow | ||
SHARED | ||
src/main/jni/dirtycow.c ) | ||
target_link_libraries( dirtyCow | ||
log) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
app/src/main/java/fuzion24/device/vulnerability/vulnerabilities/kernel/CVE_2016_5195.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package fuzion24.device.vulnerability.vulnerabilities.kernel; | ||
|
||
import android.content.Context; | ||
|
||
import java.io.*; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import fuzion24.device.vulnerability.util.CPUArch; | ||
import fuzion24.device.vulnerability.vulnerabilities.VulnerabilityTest; | ||
|
||
/** | ||
* Created by Till Busse on 21/11/16. | ||
* Java implementation to test dirtyCow vulnerability. | ||
*/ | ||
|
||
public class CVE_2016_5195 implements VulnerabilityTest { | ||
static { | ||
System.loadLibrary("dirtyCow"); | ||
} | ||
private final String file1Name = "file1"; | ||
private final String file2Name = "file2"; | ||
private final String file1Content = "This is File one."; | ||
private final String file2Content = "Mo0h"; | ||
@Override | ||
public String getCVEorID() { | ||
return "CVE-2016-5195"; | ||
} | ||
|
||
private native int runDirtyCow(Object [] paths); | ||
|
||
@Override | ||
public boolean isVulnerable(Context context) throws Exception { | ||
try{ | ||
|
||
List<Object> paths = createFiles(context); | ||
boolean isWritten = checkFileContent(context, file1Name, file1Content); | ||
if (!isWritten) | ||
throw new Exception("Error running test. File could not be created with specific content"); | ||
|
||
int checkVal = runDirtyCow(paths.toArray()); | ||
if (checkVal == 0){ | ||
isWritten = checkFileContent(context, file1Name, file2Content); | ||
return isWritten; | ||
}else { | ||
throw new Exception("Error running test. Errno: " + checkVal); | ||
} | ||
}finally { | ||
// delete files when done | ||
File file; | ||
file = new File(context.getFilesDir(), file1Name); | ||
file.delete(); | ||
file = new File(context.getFilesDir(), file1Name); | ||
file.delete(); | ||
} | ||
} | ||
|
||
@Override | ||
public List<CPUArch> getSupportedArchitectures() { | ||
ArrayList<CPUArch> archs = new ArrayList<>(); | ||
archs.add(CPUArch.ALL); | ||
return archs; | ||
} | ||
|
||
private List<Object> createFiles(Context context){ | ||
List<Object> paths = new ArrayList<>(); | ||
paths.add(0, context.getFilesDir().getAbsolutePath() + "/" + file1Name); | ||
paths.add(1, context.getFilesDir().getAbsolutePath() + "/" + file2Name); | ||
FileOutputStream outputStream; | ||
|
||
try { | ||
outputStream = context.openFileOutput(file1Name, Context.MODE_PRIVATE); | ||
outputStream.write(file1Content.getBytes()); | ||
outputStream = context.openFileOutput(file2Name, Context.MODE_PRIVATE); | ||
outputStream.write(file2Content.getBytes()); | ||
outputStream.close(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return paths; | ||
} | ||
private boolean checkFileContent(Context context, String filename, String content){ | ||
File fileCheck = context.getFilesDir(); | ||
//Get the text file | ||
File file = new File(fileCheck,filename); | ||
//Read text from file | ||
StringBuilder text = new StringBuilder(); | ||
try { | ||
BufferedReader br = new BufferedReader(new FileReader(file)); | ||
String line; | ||
|
||
while ((line = br.readLine()) != null) { | ||
text.append(line); | ||
//text.append('\n'); | ||
} | ||
br.close(); | ||
}catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
return content.equals(text.substring(0, content.length())); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
file2Name
I think (yeah, I know that this repo is pretty dead, but still 😉 )There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks =D