Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bci/browser/configuration/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ def _get_terminal_args(self) -> list[str]:
def get_navigation_sleep_duration(self) -> int:
pass

@abstractmethod
def get_open_console_hotkey(self) -> list[str]:
pass

@staticmethod
def get_browser(
browser_config: BrowserConfiguration, eval_config: EvaluationConfiguration, state: State
Expand Down
3 changes: 3 additions & 0 deletions bci/browser/configuration/chromium.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class Chromium(Browser):
def get_navigation_sleep_duration(self) -> int:
return 1

def get_open_console_hotkey(self) -> list[str]:
return ["ctrl", "shift", "j"]

def _get_terminal_args(self) -> list[str]:
assert self._profile_path is not None

Expand Down
3 changes: 3 additions & 0 deletions bci/browser/configuration/firefox.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class Firefox(Browser):
def get_navigation_sleep_duration(self) -> int:
return 2

def get_open_console_hotkey(self) -> list[str]:
return ["ctrl", "shift", "k"]

def _get_terminal_args(self) -> list[str]:
assert self._profile_path is not None

Expand Down
7 changes: 6 additions & 1 deletion bci/browser/interaction/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Simulation:
'report_leak',
'assert_file_contains',
'open_file',
'open_console',
]

def __init__(self, browser_config: BrowserConfig, params: TestParameters):
Expand All @@ -54,9 +55,9 @@ def navigate(self, url: str):
self.browser_config.terminate()
self.browser_config.open(url)
self.sleep(str(self.browser_config.get_navigation_sleep_duration()))
self.click_position("100", "50%") # focus the browser window

def new_tab(self, url: str):
self.click_position("100", "50%") # focus the browser window
self.hotkey("ctrl", "t")
self.sleep("0.5")
self.write(url)
Expand Down Expand Up @@ -112,3 +113,7 @@ def assert_file_contains(self, filename: str, content: str):

def open_file(self, filename: str):
self.navigate(f'file:///root/Downloads/{filename}')

def open_console(self):
self.hotkey(*self.browser_config.get_open_console_hotkey())
self.sleep("1.5")
8 changes: 4 additions & 4 deletions bci/evaluations/custom/default_files/py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from flask import Request
from typing import Callable

# Make sure that your page directory starts with 'py-'

def main(req: Request):
def main(req: Request, report_leak: Callable[[], None]):
# TODO - implement your functionality and return a Flask response

# If you need to report a leak, call report_leak()

return {
"agent": req.headers.get("User-Agent"),
"cookies": req.cookies,
Expand Down
3 changes: 2 additions & 1 deletion bci/evaluations/custom/default_files/script.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@

### Debugging commands
# SCREENSHOT file_name
# OPEN_FILE file
# OPEN_FILE file
# OPEN_CONSOLE
13 changes: 12 additions & 1 deletion bci/web/blueprints/experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,15 @@ def python_evaluation(project: str, experiment: str, file_name: str):
sys.modules[module_name] = module
spec.loader.exec_module(module)

return module.main(request)
def report_leak() -> None:
remote_ip = request.headers.get("X-Real-IP")
response_data = {
"url": url_for("experiments.report_endpoint", leak=experiment),
"method": request.method,
"headers": dict(request.headers),
"content": request.data.decode("utf-8"),
}

requests.post(f"http://{remote_ip}:5001/report/", json=response_data, timeout=5)

return module.main(request, report_leak)
2 changes: 1 addition & 1 deletion bci/web/vue/src/interaction_script_mode.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const KEYWORDS = "NAVIGATE|NEW_TAB|CLICK_POSITION|CLICK|WRITE|PRESS|HOLD|RELEASE|HOTKEY|SLEEP|SCREENSHOT|REPORT_LEAK|ASSERT_FILE_CONTAINS|OPEN_FILE";
const KEYWORDS = "NAVIGATE|NEW_TAB|CLICK_POSITION|CLICK|WRITE|PRESS|HOLD|RELEASE|HOTKEY|SLEEP|SCREENSHOT|REPORT_LEAK|ASSERT_FILE_CONTAINS|OPEN_FILE|OPEN_CONSOLE";

ace.define("ace/mode/interaction_script_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
const oop = require("../lib/oop");
Expand Down
2 changes: 2 additions & 0 deletions experiments/pages/Support/AutoGUI/script.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
NAVIGATE https://a.test/Support/AutoGUI/main

OPEN_CONSOLE

SCREENSHOT click1
CLICK one
WRITE AutoGUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<body>
<script>
(async () => {
const res = await fetch('https://a.test/Support/PythonServer/py-server/');
const res = await fetch('https://a.test/Support/PythonServer/server.py?leaked_secret');
const x = await res.text();
document.location = `https://a.test/report/?leak=PythonServer&response=${encodeURIComponent(JSON.stringify(x))}`;
})();
Expand Down
8 changes: 4 additions & 4 deletions experiments/pages/Support/PythonServer/a.test/server.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from flask import Request
from typing import Callable

# Make sure that your file ends with '.py'

def main(req: Request):
# TODO - implement your functionality and return a Flask response
def main(req: Request, report_leak: Callable[[], None]):
if "leaked_secret" in req.url:
report_leak()

return {
"agent": req.headers.get("User-Agent"),
Expand Down
Binary file added experiments/res/black-transparent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added experiments/res/btc.pdf
Binary file not shown.
Binary file added experiments/res/bw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added experiments/res/font.woff
Binary file not shown.
Binary file added experiments/res/horse.ogg
Binary file not shown.
Binary file added experiments/res/rgb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions experiments/res/subtitles.vtt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
WEBVTT

1
00:00:00.000 --> 00:00:01.000
LOREM

2
00:00:01.000 --> 00:00:02.000
IPSUM

3
00:00:02.000 --> 00:00:03.000
DOLOR

4
00:00:03.000 --> 00:00:04.000
SIT

5
00:00:04.000 --> 00:00:59.000
AMET
Binary file added experiments/res/video.webm
Binary file not shown.