Clean up a few interface things, for humans
This commit is contained in:
parent
02667774f3
commit
e23cacfcbe
@ -5,4 +5,4 @@ export DISPLAY=:1337
|
|||||||
cd /breach/Into*
|
cd /breach/Into*
|
||||||
xvfb-run -n 1337 -s "-screen 0 1280x720x24" ./Breach &
|
xvfb-run -n 1337 -s "-screen 0 1280x720x24" ./Breach &
|
||||||
|
|
||||||
/interface/flaskstuff.py
|
/interface/main.py
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Flask Screenshot & Click</title>
|
<title>Into The Breach as a Service</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
font-family: Arial, sans-serif;
|
font-family: Arial, sans-serif;
|
||||||
@ -18,21 +18,7 @@
|
|||||||
color: green;
|
color: green;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<h1>Flask Screenshot & Click App</h1>
|
|
||||||
<p><strong>Take a Screenshot:</strong></p>
|
|
||||||
<button onclick="takeScreenshot()">Take Screenshot</button>
|
|
||||||
<div id="screenshot-div">
|
|
||||||
<p><strong>Click on the Image to Trigger Click at X, Y:</strong></p>
|
|
||||||
<img id="screenshot" width='1280px' height='720px' style="display:none;" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="message" id="click-message"></div>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Function to take a screenshot by calling the Flask /screenshot endpoint
|
|
||||||
function takeScreenshot() {
|
function takeScreenshot() {
|
||||||
fetch('/screenshot')
|
fetch('/screenshot')
|
||||||
.then(response => response.blob())
|
.then(response => response.blob())
|
||||||
@ -47,27 +33,38 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to simulate a click at the (x, y) coordinates of the image
|
function handleClick(event) {
|
||||||
const clickableImage = document.getElementById('screenshot');
|
|
||||||
clickableImage.addEventListener('click', function(event) {
|
|
||||||
const x = event.pageX - this.offsetLeft;
|
const x = event.pageX - this.offsetLeft;
|
||||||
const y = event.pageY - this.offsetTop;
|
const y = event.pageY - this.offsetTop;
|
||||||
|
|
||||||
// Trigger the Flask /click/x/y endpoint using the x and y coordinates of the click
|
|
||||||
fetch(`/click/${x}/${y}`)
|
fetch(`/click/${x}/${y}`)
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(message => {
|
.then(message => {
|
||||||
document.getElementById('click-message').innerText = message;
|
document.getElementById('click-message').innerText = message;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
|
||||||
console.error('Error triggering click:', error);
|
|
||||||
})
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
takeScreenshot();
|
takeScreenshot();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error triggering click:', error);
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
</script>
|
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
const clickableImage = document.getElementById('screenshot');
|
||||||
|
clickableImage.addEventListener('click', handleClick);
|
||||||
|
takeScreenshot();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body onload="init()">
|
||||||
|
<button onclick="takeScreenshot()">Refresh Screenshot</button>
|
||||||
|
<div id="screenshot-div">
|
||||||
|
<p><strong>Click on the Image to Trigger Click at X, Y:</strong></p>
|
||||||
|
<img id="screenshot" width='1280px' height='720px' style="display:none;" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="message" id="click-message"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -7,41 +7,27 @@ from datetime import datetime
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
# Folder to store the screenshots
|
|
||||||
SCREENSHOT_DIR = "/tmp/screenshots"
|
SCREENSHOT_DIR = "/tmp/screenshots"
|
||||||
if not os.path.exists(SCREENSHOT_DIR):
|
if not os.path.exists(SCREENSHOT_DIR):
|
||||||
os.makedirs(SCREENSHOT_DIR)
|
os.makedirs(SCREENSHOT_DIR)
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
return '''
|
return send_file('index.html', mimetype='text/html')
|
||||||
<h1>Flask Screenshot & Click App</h1>
|
|
||||||
<p>Take a screenshot: <a href="/screenshot">/screenshot</a></p>
|
|
||||||
<p>Click at position (x, y): <a href="/click/100/100">/click/x/y</a></p>
|
|
||||||
'''
|
|
||||||
|
|
||||||
@app.route('/screenshot')
|
@app.route('/screenshot')
|
||||||
def screenshot():
|
def screenshot():
|
||||||
# Generate a screenshot file name
|
|
||||||
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
||||||
screenshot_path = os.path.join(SCREENSHOT_DIR, f'screenshot_{timestamp}.png')
|
screenshot_path = os.path.join(SCREENSHOT_DIR, f'screenshot_{timestamp}.png')
|
||||||
|
|
||||||
# Capture the screenshot using `scrot`
|
|
||||||
subprocess.run(['scrot', screenshot_path])
|
subprocess.run(['scrot', screenshot_path])
|
||||||
|
|
||||||
# Return the screenshot file as response
|
|
||||||
return send_file(screenshot_path, mimetype='image/png')
|
return send_file(screenshot_path, mimetype='image/png')
|
||||||
|
|
||||||
@app.route('/click/<int:x>/<int:y>')
|
@app.route('/click/<int:x>/<int:y>')
|
||||||
def click(x, y):
|
def click(x, y):
|
||||||
# Perform a click at the specified (x, y) position using `xdotool`
|
|
||||||
subprocess.run(['xdotool', 'mousemove', str(x), str(y), 'click', '1'])
|
subprocess.run(['xdotool', 'mousemove', str(x), str(y), 'click', '1'])
|
||||||
|
|
||||||
return f'Click performed at position ({x}, {y})'
|
return f'Click performed at position ({x}, {y})'
|
||||||
|
|
||||||
@app.route('/htmlthing')
|
|
||||||
def htmlstuff():
|
|
||||||
return send_file('htmlthing.html', mimetype='text/html')
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True, host='0.0.0.0', port=5000)
|
app.run(debug=True, host='0.0.0.0', port=5000)
|
Loading…
Reference in New Issue
Block a user