duck2py.html (2601B)
1 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 6 <meta name="viewport" content="width=device-width, initial-scale=1"> 7 <meta name="description" content="duck2py"> 8 <meta name="author" content="xfnw"> 9 <meta name="theme-color" content="#00cc00"> 10 <title>duck2py</title> 11 <link rel="stylesheet" type="text/css" href="https://tilde.team/css/hacker.css"> 12 13 14 <script> 15 function takeInput() { 16 return document.getElementById('inputbox').value.split('\n') 17 } 18 19 function sendOutput(text) { 20 document.getElementById('outputbox').value=text.join('\n') 21 } 22 23 function convert() { 24 sendOutput(duck2py(takeInput())) 25 } 26 27 function duck2py(input) { 28 var output = `# duck2py, created by xfnw 29 import usb_hid 30 from time import sleep 31 from adafruit_hid.keyboard import Keyboard 32 from adafruit_hid.keycode import Keycode as k 33 from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS 34 35 sleep(1) # wait for initilization 36 kb = Keyboard(usb_hid.devices) 37 l = KeyboardLayoutUS(kb) 38 sleep(0.5) 39 `.split('\n') 40 41 input.forEach( (c, p) => { 42 43 args = c.split(' ') 44 c = [args.shift()] 45 orig = c.concat(args) 46 c = c.shift() 47 switch(c) { 48 case 'DELAY': 49 output.push('sleep('+args.join(' ')+'/1000)') 50 51 break 52 case 'REM': 53 output.push('#'+args.join(' ')) 54 break 55 56 case 'STRING': 57 output.push('sleep(0.05);l.write("'+args.join(' ').replace('"','\\"')+'")') 58 break 59 60 case 'REPEAT': 61 for (var i=0; i<args[0]; i++) { 62 output.push(output[output.length -1]) 63 } 64 break 65 66 default: 67 output.push('') 68 orig.forEach( (v, n) => { 69 output[output.length -1] += ('sleep(0.05);kb.press(k.'+v.toUpperCase()+');') 70 }) 71 output[output.length -1] += ('sleep(0.05);kb.release_all()') 72 } 73 74 }) 75 76 return output 77 } 78 79 </script> 80 81 82 </head> 83 <body> 84 <div class="container"> 85 <div class="page-header"> 86 <div class="pull-right"> 87 <p><a href="https://tilde.team/"><- back to tilde.team</a></p> 88 </div> 89 <h1><strong>duck2py</strong></h1> 90 </div> 91 <p> 92 a converter that converts a simple implimentation of hak5's duckyscript 93 to circuitpyhon-compatable code. 94 </p> 95 96 <input type="button" value="Quack!" class="btn btn-primary pull-right" onclick="convert()"> 97 98 <br> 99 <hr> 100 <div class="row"> 101 102 <div class='col-md-6'> 103 <textarea id="inputbox" class="form-control" rows="15"></textarea> 104 </div> 105 <div class='col-md-6'> 106 <textarea id="outputbox" class="form-control" rows="15"></textarea> 107 </div> 108 </div> 109 <hr> 110 <small>the ui was hacked together with ~team bootstrap, dont judge me lol</small> 111 112 113 <br><br><br> 114 </body> 115 </html> 116