DataOutputStream request = new DataOutputStream( httpUrlConnection.getOutputStream()); request.writeBytes(this.twoHyphens + this.boundary + this.crlf); request.writeBytes("Content-Disposition: form-data; name=\"" + this.attachmentName + "\";filename=\"" + this.attachmentFileName + "\"" + this.crlf); request.writeBytes(this.crlf);
private void sendToSubprocess(String str) throws IOException { _processin.writeBytes(str + "\n"); _processin.writeBytes("end\n"); _processin.flush(); }
public void RunAsRoot(String[] cmds){ Process p = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(p.getOutputStream()); for (String tmpCmd : cmds) { os.writeBytes(tmpCmd+"\n"); } os.writeBytes("exit\n"); os.flush(); }
URL url = new URL(targetURL); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); DataOutputStream wr = new DataOutputStream ( connection.getOutputStream()); wr.writeBytes(urlParameters); wr.close();
Process process = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(process.getOutputStream()); String cmd = "/system/bin/input tap 100 200\n"; os.writeBytes(cmd); os.writeBytes("exit\n"); os.flush(); os.close(); process.waitFor();
DataOutputStream os = new DataOutputStream(this.socket.getOutputStream()); os.writeBytes("200"); os.close(); br.close(); socket.close();
public void callCouchbaseRestAPI(String url, String payload) throws IOException { String fullUrl = urlBase + url; @Cleanup("disconnect") HttpURLConnection httpConnection = (HttpURLConnection) ((new URL(fullUrl).openConnection())); httpConnection.setDoOutput(true); httpConnection.setRequestMethod("POST"); httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); String encoded = Base64.encode((clusterUsername + ":" + clusterPassword).getBytes("UTF-8")); httpConnection.setRequestProperty("Authorization", "Basic " + encoded); @Cleanup DataOutputStream out = new DataOutputStream(httpConnection.getOutputStream()); out.writeBytes(payload); out.flush(); httpConnection.getResponseCode(); }
try{ Process su = Runtime.getRuntime().exec("su"); DataOutputStream outputStream = new DataOutputStream(su.getOutputStream()); outputStream.writeBytes("screenrecord --time-limit 10 /sdcard/MyVideo.mp4\n"); outputStream.flush(); outputStream.writeBytes("exit\n"); outputStream.flush(); su.waitFor(); }catch(IOException e){ throw new Exception(e); }catch(InterruptedException e){ throw new Exception(e); }
DataOutputStream dos = new DataOutputStream(baos); dos.writeBytes(twoHyphens + boundary + lineEnd); dos.writeBytes("Content-Disposition: form-data; name=\"param1\"" + lineEnd); dos.writeBytes("Content-Type: text/plain; charset=US-ASCII" + lineEnd); dos.writeBytes("Content-Transfer-Encoding: 8bit" + lineEnd); dos.writeBytes(lineEnd); dos.writeBytes(myStringData + lineEnd); dos.writeBytes(twoHyphens + boundary + lineEnd); dos.writeBytes("Content-Disposition: form-data; name=\"param3\";filename=\"test_file.dat\"" + lineEnd); dos.writeBytes("Content-Type: application/octet-stream" + lineEnd); dos.writeBytes("Content-Transfer-Encoding: binary" + lineEnd); dos.writeBytes(lineEnd); dos.write(buffer); dos.writeBytes(lineEnd); dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd); dos.flush(); dos.close();
public void save(OutputStream output) throws IOException { try (DataOutputStream out = new DataOutputStream(output)) { out.writeBytes(JADX_CLS_SET_HEADER); out.writeByte(VERSION); LOG.info("Classes count: {}", classes.length); out.writeInt(classes.length); for (NClass cls : classes) { writeString(out, cls.getName()); } for (NClass cls : classes) { NClass[] parents = cls.getParents(); out.writeByte(parents.length); for (NClass parent : parents) { out.writeInt(parent.getId()); } } } }
private void writeString(String str) throws IOException { byte[] strBytes = str.getBytes("UTF-8"); processIn.write(strBytes, 0, strBytes.length); processIn.writeBytes("\nend\n"); processIn.flush(); }
private String sendPost(String urlParams) { try { HttpURLConnection con = (HttpURLConnection) rpcUrl.openConnection(); //add reuqest header con.setRequestMethod("POST"); // Send post request con.setDoOutput(true); try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) { wr.writeBytes(urlParams); wr.flush(); } int responseCode = con.getResponseCode(); if (responseCode != 200) { throw new RuntimeException("HTTP Response: " + responseCode); } final StringBuffer response; try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) { String inputLine; response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } } return response.toString(); } catch (IOException e) { throw new RuntimeException("Error sending POST to " + rpcUrl, e); } }
try { Process proc = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(proc.getOutputStream()); os.writeBytes("service call phone 5\n"); os.flush(); os.writeBytes("exit\n"); os.flush(); if (proc.waitFor() == 255) { // TODO handle being declined root access // 255 is the standard code for being declined root for SU } } catch (IOException e) { // TODO handle I/O going wrong // this probably means that the device isn't rooted } catch (InterruptedException e) { // don't swallow interruptions Thread.currentThread().interrupt(); }
public static void doCmds(List<String> cmds) throws Exception { Process process = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(process.getOutputStream()); for (String tmpCmd : cmds) { os.writeBytes(tmpCmd+"\n"); } os.writeBytes("exit\n"); os.flush(); os.close(); process.waitFor(); }
Process p = Runtime.getRuntime().exec(new String[]{"su", "-c", "system/bin/sh"}); DataOutputStream stdin = new DataOutputStream(p.getOutputStream()); //from here all commands are executed with su permissions stdin.writeBytes("ls /data\n"); // \n executes the command InputStream stdout = p.getInputStream(); byte[] buffer = new byte[BUFF_LEN]; int read; String out = new String(); //read method will wait forever if there is nothing in the stream //so we need to read it in another way than while((read=stdout.read(buffer))>0) while(true){ read = stdout.read(buffer); out += new String(buffer, 0, read); if(read<BUFF_LEN){ //we have read everything break; } } //do something with the output
public String writeCommand(String command, Argument args) throws IOException, ProtocolException { // assert Thread.holdsLock(this); // can't assert because it's called from constructor String tag = "A" + Integer.toString(tagCounter++, 10); // unique tag output.writeBytes(tag + " " + command); if (args != null) { output.write(' '); args.write(this); } output.write(CRLF); output.flush(); return tag; }
URL url = new URL(urlString); conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setRequestProperty("Connection", "Keep-Alive"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary); dos = new DataOutputStream(conn.getOutputStream()); dos.writeBytes(twoHyphens + boundary + lineEnd); dos.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + existingFileName + "\"" + lineEnd); dos.writeBytes(lineEnd); dos.writeBytes(lineEnd); dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd); dos.flush(); dos.close();
public static void appendToFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext ) { if ( !isNull( ArgList ) && !isUndefined( ArgList ) ) { try { FileOutputStream file = new FileOutputStream( (String) ArgList[0], true ); DataOutputStream out = new DataOutputStream( file ); out.writeBytes( (String) ArgList[1] ); out.flush(); out.close(); } catch ( Exception er ) { throw new RuntimeException( er.toString() ); } } else { throw new RuntimeException( "The function call appendToFile requires arguments." ); } }
DataOutputStream outputStream = new DataOutputStream(conn.getOutputStream()); outputStream.writeBytes(json); outputStream.flush(); outputStream.close();
final DataOutputStream data = new DataOutputStream(out); data.writeBytes(this.getType().toString()); data.writeBytes(headers.get("Encryption")); data.writeBytes(headers.get("Comment"));