Skip to content
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

Hotfix #879

Open
wants to merge 33 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
77020cc
Define the floating button at the end of the RelativeLayout,
tux-mind Dec 25, 2015
8c5a9cc
version bump
tux-mind Dec 25, 2015
539f982
use stable version of gradle android plugin
tux-mind Dec 25, 2015
d29597b
fixes #555
tux-mind Jan 7, 2016
5a120d7
version bump
tux-mind Jan 7, 2016
f92cde5
force user to choose empty or old directories.
tux-mind Jan 16, 2016
cc50526
version bump
tux-mind Jan 16, 2016
014b641
[ExploitFinder] fix #612
tux-mind Mar 27, 2016
1144ea6
[ExploitFinder] parsed paged may return null
tux-mind Mar 27, 2016
1860d4f
partially fixes #428
tux-mind Oct 14, 2015
cdfd4ea
fixes #429
tux-mind Oct 18, 2015
ccda980
fixes #437
tux-mind Oct 18, 2015
b157c24
display activity when dumping traffic to a pcap file.
gainan Oct 16, 2015
4339b93
Update gradle to 2.8
fat-tire Oct 30, 2015
70d9a70
Extract charset encoding from HTTP headers or html headers.
gainan Oct 30, 2015
e755957
some websites put the charset encoding names between '' characters, s…
gainan Nov 1, 2015
81a014b
if we get a not valid charset, send the request with the default char…
gainan Nov 4, 2015
7d983d5
parse TopLevelDomains correctly.
gainan Nov 1, 2015
319d148
parse TopLevelDomains better.
gainan Nov 5, 2015
9c996cb
TLD array updated with latest domains from www.publicsuffix.org
gainan Nov 10, 2015
f3f3c95
put the items: network, gateway and our own device, on top of the hos…
gainan Nov 11, 2015
a7d2bec
use Comparable interface to sort our targets.
tux-mind Nov 19, 2015
b986abe
improved singleton pattern
tux-mind Nov 19, 2015
fa3f672
make cache thread safe.
tux-mind Nov 19, 2015
96de421
little speed up
tux-mind Nov 19, 2015
e4a12c8
update libraries, gradle, gradle plugin
fat-tire Nov 20, 2015
662cbd3
version bump
tux-mind Mar 28, 2016
469a574
pcap storage permission fix
asdasdasdasdasdd Apr 1, 2016
47714a9
[Sniffer] use IOUtils for deal with cached files.
tux-mind Apr 6, 2016
388d6cf
[Sniffer] moving a file implies it's removal...
tux-mind Apr 6, 2016
41d6e3a
[ExploitFinder] Rapid7 now force to HTTPS.
tux-mind Jun 18, 2016
34092c1
[ExploitFinder] follow HTTP redirects.
tux-mind Jun 18, 2016
0ff1883
version bump
tux-mind Jun 18, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.4.0-beta6'
classpath 'com.android.tools.build:gradle:1.5.0'
}
}

Expand Down
16 changes: 8 additions & 8 deletions cSploit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.4.0-beta6'
classpath 'com.android.tools.build:gradle:1.5.0'
}
}

Expand All @@ -21,10 +21,10 @@ allprojects {
apply plugin: 'com.android.application'

dependencies {
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:preference-v7:23.0.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:preference-v7:23.1.1'
compile 'org.apache.commons:commons-compress:1.10'
compile 'commons-net:commons-net:3.3'
compile 'com.github.zafarkhaja:java-semver:0.9.0'
Expand All @@ -37,7 +37,7 @@ dependencies {

android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
buildToolsVersion '23.0.2'

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
Expand All @@ -52,8 +52,8 @@ android {
defaultConfig {
minSdkVersion 9
targetSdkVersion 22
versionCode 4
versionName "1.6.2"
versionCode 6
versionName "1.6.6-rc.2"
if(System.getenv("NIGHTLY_BUILD")) {
versionName += "+" + System.getenv("NIGHTLY_BUILD_COMMIT").substring(0, 7)
}
Expand Down
30 changes: 17 additions & 13 deletions cSploit/res/layout/plugin_inspector.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@
android:paddingTop="16sp"
android:id="@+id/whatever">

<android.support.design.widget.FloatingActionButton
android:id="@+id/inspectToggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:src="@drawable/ic_play_arrow_24dp"
android:checked="false"
android:translationZ="8dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="20dp"
android:focusableInTouchMode="true" />

<ProgressBar
android:id="@+id/inspectActivity"
android:layout_width="wrap_content"
Expand Down Expand Up @@ -156,4 +143,21 @@
android:gravity="center_vertical"
/>
</ScrollView>

<!--
Later children in a RelativeLayout tend to float over earlier children in a RelativeLayout.
https://www.stackoverflow.com/a/28651543
-->
<android.support.design.widget.FloatingActionButton
android:id="@+id/inspectToggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:src="@drawable/ic_play_arrow_24dp"
android:checked="false"
android:translationZ="8dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="20dp"
android:focusableInTouchMode="true" />
</RelativeLayout>
1 change: 1 addition & 0 deletions cSploit/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -529,4 +529,5 @@
<string name="mitm_ss_select_target_prompt">Select %s ?</string>
<string name="github_issues_url" translatable="false">https://github.com/cSploit/android/issues</string>
<string name="issue_message"><![CDATA[<p>Before opening a new issue, please, take the time to read the already <a href="%1$s">open issues</a>, probably it\' s already open. If it\' s not open we\'ll need as much information as you can get, so please, read <a href="%2$s">this guide</a> in order to know how to report a bug properly.</p>]]></string>
<string name="pref_err_empty_or_old">must be empty or an old installation directory.</string>
</resources>
64 changes: 41 additions & 23 deletions cSploit/src/org/csploit/android/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ private void onCoreBeating() {
}

private void onCoreUpdated() {
System.onCoreInstalled();

if (startCore()) {
onCoreBeating();
} else if (isRootMissing) {
Expand Down Expand Up @@ -612,7 +614,6 @@ public void onInputEntered(String input) {
@Override
public void run() {
System.addOrderedTarget(target);
mTargetAdapter.update(null, null);
}
});
} else
Expand Down Expand Up @@ -887,16 +888,20 @@ public View getView(int position, View convertView, ViewGroup parent) {
}

public void clearSelection() {
for (Target t : list)
t.setSelected(false);
synchronized (this) {
for (Target t : list)
t.setSelected(false);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always use curly braces
for (Target t : list){
t.setSelected(false);
}

}
notifyDataSetChanged();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not mandatory to use notifyDataSetChanged always. if you want to update only one item in the list then you can use notifyItemChanged(position)

if (mActionMode != null)
mActionMode.finish();
}

public void toggleSelection(int position) {
Target t = list.get(position);
t.setSelected(!t.isSelected());
synchronized (this) {
Target t = list.get(position);
t.setSelected(!t.isSelected());
}
notifyDataSetChanged();
if (mActionMode != null) {
if (getSelectedCount() > 0)
Expand All @@ -908,27 +913,34 @@ public void toggleSelection(int position) {

public int getSelectedCount() {
int i = 0;
for (Target t : list)
if (t.isSelected())
i++;
synchronized (this) {
for (Target t : list)
if (t.isSelected())
i++;
}
return i;
}

public ArrayList<Target> getSelected() {
ArrayList<Target> result = new ArrayList<Target>();
for (Target t : list)
if (t.isSelected())
result.add(t);
synchronized (this) {
for (Target t : list)
if (t.isSelected())
result.add(t);
}
return result;
}

public int[] getSelectedPositions() {
int[] res = new int[getSelectedCount()];
int[] res;
int j = 0;

for (int i = 0; i < list.size(); i++)
if (list.get(i).isSelected())
res[j++] = i;
synchronized (this) {
res = new int[getSelectedCount()];
for (int i = 0; i < list.size(); i++)
if (list.get(i).isSelected())
res[j++] = i;
}
return res;
}

Expand All @@ -948,21 +960,27 @@ public void update(Observable observable, Object data) {
public void run() {
if(lv == null)
return;
int start = lv.getFirstVisiblePosition();
for(int i=start, j=lv.getLastVisiblePosition();i<=j;i++)
if(target==list.get(i)){
View view = lv.getChildAt(i-start);
getView(i, view, lv);
break;
}

synchronized (this) {
int start = lv.getFirstVisiblePosition();
int end = Math.min(lv.getLastVisiblePosition(), list.size());
for (int i = start; i <= end; i++)
if (target == list.get(i)) {
View view = lv.getChildAt(i - start);
getView(i, view, lv);
break;
}
}
}
});

}

@Override
public void run() {
list = System.getTargets();
synchronized (this) {
list = System.getTargets();
}
notifyDataSetChanged();
}

Expand Down
107 changes: 80 additions & 27 deletions cSploit/src/org/csploit/android/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,84 @@ public void onEnd(int exitCode) {
}
}

private boolean isDirectoryEmptyOrWithVersion(File folder) {
String[] files = folder.list();

if(files.length > 0) {
for(String fname : files) {
if("VERSION".equals(fname)) {
return true;
}
}
return false;
}

return true;
}

private ExecChecker getCheckerForKey(String key) {
switch (key) {
case "RUBY_DIR":
return ExecChecker.ruby();
case "MSF_DIR":
return ExecChecker.msf();
}
return null;
}

private String getCurrentPathForKey(String key) {
switch (key) {
case "RUBY_DIR":
return System.getRubyPath();
case "MSF_DIR":
return System.getMsfPath();
}
return null;
}

private boolean shallAskForDelete(String key) {
return key.equals("RUBY_DIR") || key.equals("MSF_DIR");
}

/**
* check if selected directory is valid for the given key.
* @param key to be updated
* @param path of the chosen directory
* @return true if {@code path} is valid, false otherwise
*/
private boolean canChangeDirectoryTo(String key, String path) {
File folder = new File(path);
ExecChecker checker = getCheckerForKey(key);
String oldPath = getCurrentPathForKey(key);
String toastMessage = null;
boolean valid = false;
boolean checkEmptyOrVersion = shallAskForDelete(key);

if (!folder.exists()) {
toastMessage = getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_exists);
} else if (!folder.canWrite()) {
toastMessage = getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_writable);
} else if (checker != null && !checker.canExecuteInDir(path)) {
toastMessage = getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_executable);
} else if (checkEmptyOrVersion && !isDirectoryEmptyOrWithVersion(folder)) {
toastMessage = getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_empty_or_old);
} else if (oldPath == null || !oldPath.equals(path)) {
valid = true;
}

if(toastMessage != null) {
Toast.makeText(getContext(), toastMessage, Toast.LENGTH_LONG).show();
}

return valid;
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == DirectoryPicker.PICK_DIRECTORY && resultCode != RESULT_CANCELED) {
Bundle extras = intent.getExtras();
String path;
String key;
File folder;
String oldPath = null;

if (extras == null) {
Logger.debug("null extra: " + intent);
Expand All @@ -236,35 +306,18 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) {
return;
}

folder = new File(path);
ExecChecker checker = null;


if (key.equals("RUBY_DIR")) {
oldPath = System.getRubyPath();
checker = ExecChecker.ruby();
} else if (key.equals("MSF_DIR")) {
oldPath = System.getMsfPath();
checker = ExecChecker.msf();
}

if (!folder.exists())
Toast.makeText(getActivity(), getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_exists), Toast.LENGTH_SHORT).show();

else if (!folder.canWrite())
Toast.makeText(getActivity(), getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_writable), Toast.LENGTH_SHORT).show();
if(canChangeDirectoryTo(key, path)) {

else if (checker != null && !checker.canExecuteInDir(path))
Toast.makeText(getActivity(), getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_executable), Toast.LENGTH_LONG).show();

else {
//noinspection ConstantConditions
getPreferenceManager().getSharedPreferences().edit().putString(key, path).commit();
if (oldPath != null && !oldPath.equals(path)) {
File current = new File(oldPath);

if (current.exists() && current.isDirectory() && current.listFiles().length > 2) {
wipe_prompt_older(current);
if(shallAskForDelete(key)) {
String oldPath = getCurrentPathForKey(key);
if(oldPath != null) {
File current = new File(oldPath);
if(current.exists() && current.isDirectory() && current.list().length > 0) {
wipe_prompt_older(current);
}
}
}
}
Expand Down
Loading