Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lcdsantos/b0ad33c0be3f026c8a87829c64a0c0ad to your computer and use it in GitHub Desktop.
Save lcdsantos/b0ad33c0be3f026c8a87829c64a0c0ad to your computer and use it in GitHub Desktop.
// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split("");
function f() {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1
var shift = XK_Shift_L; // To help with minification
function key(keycode, down) {
i=i.concat(RFB.messages.keyEvent(keycode, down));
}
if (needs_shift) {
key(shift,1);
}
key(code,1);
key(code,0);
if (needs_shift) {
key(shift,0);
}
rfb._sock.send(i);
if (t.length > 0) {
setTimeout(f, 10);
}
}
f();
})();
// Minified version:
!function(){function t(){function n(t,e){s=s.concat(RFB.messages.keyEvent(t,e))}var o=e.shift(),s=[],i=o.charCodeAt(),c=-1!=='!@#$%^&*()_+{}:"<>?~|'.indexOf(o),r=XK_Shift_L;c&&n(r,1),n(i,1),n(i,0),c&&n(r,0),rfb._sock.send(s),e.length>0&&setTimeout(t,10)}var e=prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split("");t()}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment