Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge commit '671f6f70d99bbd1d30ca339f76e778a4bf61e850' as 'Sandbox'
- Loading branch information
Showing
53 changed files
with
2,011 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*~ | ||
package-lock.json | ||
.eslintrc.json | ||
package.json | ||
tsconfig.all.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM cueh/flask | ||
|
||
|
||
|
||
USER root | ||
ADD REQUIREMENTS.txt /tmp | ||
RUN pip install -r /tmp/REQUIREMENTS.txt | ||
|
||
USER flask | ||
WORKDIR /opt | ||
ADD ./opt /opt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
flask-socketio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: "3.8" | ||
services: | ||
sandbox: | ||
build: . | ||
ports: | ||
- "5000:5000" | ||
volumes: | ||
- ./opt:/opt | ||
environment: | ||
- FLASK_ENV=development | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: "3.8" | ||
services: | ||
sandbox: | ||
build: . | ||
ports: | ||
- "5000:5000" | ||
expose: | ||
- 5000 | ||
# deploy: | ||
# restart_policy: | ||
# condition: any | ||
# delay: 5s | ||
# max_attempts: 5 | ||
# window: 120s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
Very simple Flask App. For Testing | ||
""" | ||
|
||
import sys | ||
|
||
import flask | ||
from flask_socketio import SocketIO | ||
|
||
import logging | ||
log = logging.getLogger("APP") | ||
|
||
|
||
app = flask.Flask(__name__) | ||
socketio = SocketIO(app) | ||
|
||
|
||
@app.route('/', methods=["GET","POST"]) | ||
def main(): | ||
return flask.render_template('index.html') | ||
|
||
@socketio.on("connect") | ||
def connect(): | ||
version = sys.version | ||
socketio.send("Python {0}".format(version)) | ||
|
||
@socketio.on('message') | ||
def handle_message(message): | ||
try: | ||
out = eval(message) | ||
if type(out) == bytes: | ||
socketio.send(out.decode()) | ||
else: | ||
socketio.send(out) | ||
except Exception as ex: | ||
socketio.send("{}".format(ex)) | ||
|
||
@app.route('/debug') | ||
def debug(): | ||
return flask.Response(open(__file__).read(), mimetype='text/plain') | ||
|
||
|
||
if __name__ == "__main__": | ||
socketio.run(app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CUEH{DEMO FLAG} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
201 changes: 201 additions & 0 deletions
201
Sandbox/Development/opt/static/node_modules/xterm/README.md
Large diffs are not rendered by default.
Oops, something went wrong.
171 changes: 171 additions & 0 deletions
171
Sandbox/Development/opt/static/node_modules/xterm/css/xterm.css
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
Sandbox/Development/opt/static/node_modules/xterm/lib/xterm.js
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
Sandbox/Development/opt/static/node_modules/xterm/lib/xterm.js.map
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
var term = new Terminal({cursorBlink: true, | ||
cursorStyle: 'underline'}); | ||
|
||
var thePrompt = ">>> "; | ||
|
||
term.open(document.getElementById('terminal')); | ||
//term.write(thePrompt); | ||
|
||
var index = 0; | ||
var buffer = ""; | ||
var socket = io.connect(); | ||
|
||
function ab2str(buf) { | ||
return String.fromCharCode.apply(null, new Uint16Array(buf)); | ||
} | ||
|
||
|
||
socket.on('connect', () => { | ||
//console.log("CONNECTED"); | ||
}); | ||
|
||
// handle the event sent with socket.send() | ||
socket.on('message', data => { | ||
if (typeof(data) == "string"){ | ||
var parts = data.split("\n"); | ||
for (i=0; i<parts.length; i++){ | ||
term.write(parts[i]+"\r\n"); | ||
} | ||
} | ||
else{ | ||
term.write(data + "\r\n"); | ||
} | ||
term.write(thePrompt); | ||
}); | ||
|
||
|
||
term.onData(data => { | ||
//First the lower contoll chars | ||
var ord = data.charCodeAt(0); | ||
//Values lower than 32 are controll. | ||
//Also 127 is Delete | ||
if (ord < 32 || ord ==127) { | ||
//Deal with individual codes | ||
if (ord == 13){ //Newline | ||
socket.send(buffer); | ||
index = 0; | ||
buffer = ""; | ||
term.write("\r\n"); | ||
//term.write(thePrompt); | ||
} | ||
else if (ord == 27) { //Ascii Controll Chars | ||
//So the next part is the interesting bit | ||
var ctlChar = data.substr(1) //Strip of the first part | ||
if (ctlChar == "[C") {//Right Arrow | ||
//Sanity check | ||
if (index < buffer.length){ | ||
index += 1; | ||
term.write(data); | ||
} | ||
else{ | ||
term.write("\x07"); | ||
} | ||
}else if (ctlChar == "[D") { //leftArrow | ||
if (index > 0){ | ||
index -= 1; | ||
term.write(data); | ||
} | ||
else{ | ||
//Ring that Bell | ||
term.write("\x07"); | ||
} | ||
} | ||
} | ||
else if (ord == 127){ //Deletes | ||
//Decrement | ||
index -= 1; | ||
|
||
//Remove the character from the buffer | ||
buffer = buffer.substring(0,index) + buffer.substring(index+1); | ||
//And we can move the text backwards with Ascii Control sequences | ||
term.write("\b\x1b[P"); | ||
} | ||
return; | ||
} | ||
else{ | ||
//Anything else we stash in the buffer | ||
if (index == buffer.length){ | ||
buffer += data; | ||
} | ||
else{ | ||
//Strings are immutable | ||
buffer = buffer.substring(0,index) + data + buffer.substring(index+1); | ||
} | ||
index += 1; | ||
term.write(data); | ||
} | ||
|
||
}); | ||
|
||
/* Linefeeds happen (But based on input linefeeds */ | ||
/* | ||
term.onLineFeed(data => { | ||
console.log("LINEFEED"); | ||
//term.write("\n"); | ||
}); | ||
*/ |
Oops, something went wrong.