pfgpastebin

Code to be run on nodejs server for quality server editing a

Aug 8th, 2017
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*global exec*/
  2.  
  3. // we have a certified certificate of pure raw clean clientside trust. anything your client says, we believe.
  4. const http = require('http')  ;
  5. const port = process.env.PORT || 3000;
  6. const fs = require('fs');
  7.  
  8. var i = 0;
  9. var recents = ["none found"]; //
  10. function execu(text, file){
  11.   text = decodeURIComponent(text);
  12.   recents.push(
  13.     `<a href="?runfile=CODE`+i+`.js">`+text+`</a>`
  14.     );
  15. i++;
  16.   fs.writeFileSync('CODE'+i+'.js', text, 'utf8');//, () => {
  17.   try{
  18.     return require("./CODE"+i).result;
  19.   }catch(err){
  20.     return new Error("ur codez r badz");
  21.   }
  22. }
  23.  
  24. const requestHandler = (req, res) => {  
  25. "use strict";
  26.   res.setHeader('X-Powered-By', 'smart coders inc.orp');
  27. if(req.url.indexOf("admin") > -1){
  28.   res.end(`
  29.   <html>
  30.   <body>
  31.   <form>
  32.   <input type="text" placeholder="Username (admin)" />
  33.   <input type="text" placeholder="Password (password)" />
  34.   <button><a href="javascript:(function()%7Blocation.href%20%3D%20%22https%3A%2F%2Fevalbot-pfgc9.c9users.io%2F%3Fshell%3D%22%2BencodeURIComponent(prompt(%22code%20here%3A%22%2C%22echo%20%5C%22hello%2C%20world%5C%22'%22))%7D)()">Access Shell</a></button>
  35.   </form>
  36.   </body>
  37.   </html>
  38.   `);
  39.   return;
  40. }
  41. if(req.url.indexOf("/?shell=") > -1) {
  42.   res.end(`
  43.   <html>
  44.   <body>
  45.   <b>Connected Securely to Secure Shell</b>
  46.   <tt>
  47. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  48. @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
  49. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  50. IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
  51. Someone could be eavesdropping on you right now (man-in-the-middle attack)!
  52. It is also possible that a host key has just been changed.
  53. The fingerprint for the ECDSA key sent by the remote host is
  54. 82:90:11:b4:gg:a4:92:0p:ll:m6:23:he:x5:28:aa:a9.
  55. Please contact your system administrator.
  56. $>
  57. </tt>
  58. <form action="/" method="get">
  59.   <input type="text" placeholder="> Command..." name="command" />
  60.   <button><a href="javascript:(function()%7Blocation.href%20%3D%20%22https%3A%2F%2Fevalbot-pfgc9.c9users.io%2F%3Fcommand%3D%22%2BencodeURIComponent(prompt(%22code%20here%3A%22%2C%22module.exports.result%3D'hello%2C%20world'%22))%7D)()">Send</a></button>
  61.   </form>
  62.   </body>
  63.   </html>
  64.   `);
  65.   return;
  66. }
  67.   console.log(req.url, req.url.split('/?command=')[1]);
  68.   let output = ``;
  69.   if(req.url.split('/?command=')[1]) output = execu(req.url.split('/?command=')[1]);
  70.   if(req.url.split('/?command=')[1] || req.url.split('/?runfile=')[1]){
  71.     if(req.url.split('/?runfile=')[1]){
  72.        
  73.       res.end(`Ran Code: $(`+"something, reading file contents is hard"+`). <b>Result</b>: (module.exports.result) \n\n`+(() => {try{
  74.     return require(req.url.split('/?runfile=')[1]).result;
  75.   }catch(err){
  76.     return new Error("ur codez r badz");
  77.   }})());
  78.      
  79.     }
  80.     res.end(`Ran Code: $(`+decodeURIComponent(req.url.split('/?command=')[1])+`). <b>Result</b>: (module.exports.result) \n\n`+output);
  81.     return;
  82.   }
  83.   void(req.url.split('/?command=')[1]); // req.url.split('/?command=')[1]
  84.   res.end('<html>Append ?command=[encodeURIComponent("js code...")] to write your js. You may also click <a href='+`javascript:(function()%7Blocation.href%20%3D%20%22https%3A%2F%2Fevalbot-pfgc9.c9users.io%2F%3Fcommand%3D%22%2BencodeURIComponent(prompt(%22code%20here%3A%22%2C%22module.exports.result%3D'hello%2C%20world'%22))%7D)()`+'>this link</a><h1>Recent scripts: </h1><br><ul><li>'+recents.join("</li><li>")+'</li></ul> <!-- admin cp at /controlpanel/login/secure/admin.php --></html>');
  85. };
  86.  
  87. const server = http.createServer(requestHandler);
  88.  
  89. server.listen(port, (err) => {  
  90.   if (err) {
  91.     return console.log('something bad happened', err);
  92.   }
  93.  
  94.   console.log(`server is listening on ${port}`);
  95. })
Advertisement
Add Comment
Please, Sign In to add comment