Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup selenium automation test #13

Merged
merged 19 commits into from
Nov 9, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,4 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
client_scripts/BigBuckBunny.mp4
26 changes: 26 additions & 0 deletions RTP_packet_capture/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Capturing non encrypted RTP packets from a WebRTC session
Following this [guide](https://blog.mozilla.org/webrtc/debugging-encrypted-rtp-is-more-fun-than-it-used-to-be/)
for setting up firefox (ff) or the same procedure for the ff geckodriver.
You would want to set these logging settings:

```
Current Log Modules to timestamp,signaling:5,jsep:5,RtpLogger:5
The log file name to: /tmp/logs/moz.log
```
They can be set as env variables or from this [configuration](about:networking#logging) page in firefox.

Then you can start a webrtc session and find the log files that you set.
When you have found the log files you can use the command:

```shell
egrep '(RTP_PACKET|RTCP_PACKET)' moz.log | cut -d '|' -f 2 | cut -d ' ' -f 5- | text2pcap -D -n -l 1 -i 17 -u 1234,1235 -t '%H:%M:%S.' - rtp_packets.pcap
```

To obtain a pcap file with the RTP packets. The packets do not show any jitter or loss,
but it is possible to see the RTP headers.

The example packet file is from a webrtc session between a test client using ff and normal ff browser.
The ff test client browser was running on an ubuntu VM with the ff geckodriver.
The webrtc session was initiated from the normal ff browser.


Binary file added RTP_packet_capture/rtp_packets.pcap
Binary file not shown.
Binary file added Selenium/Onion_browser_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions Selenium/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

## Fake video and audio stream

To simulate a Video and audio call, we create a fake webcame and microphone, which the browser can get as a input stream and use for the WebRTC stream/application. See the script [**setup_fake_webcam.sh**](../client_scripts/setup_fake_webcam.sh) for setting it up in ubuntu.

The script requires an input video which can be fetched from the script [**get_bigbunny_video.sh**](../client_scripts/get_bigbunny_video.sh).

To make sure that the selenium script uses the correct "fake" microphone, we need to make sure that any other microphone is disabled. In the VM running ubuntu it can be done by following the solution [here](https://askubuntu.com/questions/146654/how-can-i-completely-disable-internal-mic-and-webcam), by blacklisting "snd_hda_intel".

## Development

When developing in a VM with ssh in vs code, you can enable x11 Forwarding, by running an ssh session in another terminal window by running the command:

```shell
ssh -X user@VM
```




## Tor and Firefox setup

The client should have installed and setup a running instance of tor.
See the script [**setup_tor.sh**](../client_scripts/setup_tor.sh) for ubuntu instructions

We also need to install firefox, which the geckodriver uses. This should also be in the script.

Now the following command should show the install path of firefox:

```shell
$ which firefox
/usr/bin/firefox
```

Because of the possible privacy leaks in using STUN and WebRTC, WebRTC has been disabled from the Tor Browser. So the project uses the firefox Browser, and sets the proxy settings to point at the local Tor proxy. A ff addon is needed for quick access to setting the Tor proxy. The [addon](https://addons.mozilla.org/en-US/firefox/addon/tortm-browser-button/) simply adds a button for toggling the tor proxy on and off. This can be used when testing manually in the browser.

![](Onion_browser_button.png)

When setting up the addon, it will ask for permisson to also run in "Private Window", press Allow and press Okay.

![](onion.png)

When the addon has been added, you simply need to press start and wait for the "Connected to 127.0.0.1:9050" message. Now you are connected to the Tor network.

![](button.png)
Binary file added Selenium/button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions Selenium/misc/stem1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from stem import CircStatus
from stem.control import Controller
from hurry.filesize import size

with Controller.from_port(port = 9051) as controller:
controller.authenticate("kode112")

bytes_read = controller.get_info("traffic/read")
bytes_written = controller.get_info("traffic/written")
traffic_downloaded = size(int(bytes_read))
traffic_uploaded = size(int(bytes_written))

print("I have downloaded:",traffic_downloaded,"\nI Have uploaded: ",traffic_uploaded)

for circ in sorted(controller.get_circuits()):
if circ.status != CircStatus.BUILT:
continue

print("")
print("Circuit %s (%s)" % (circ.id, circ.purpose))


for i, entry in enumerate(circ.path):
div = '+' if (i == len(circ.path) - 1) else '|'
fingerprint, nickname = entry

desc = controller.get_network_status(fingerprint, None)
address = desc.address if desc else 'unknown'

print(" %s- %s (%s, %s)" % (div, fingerprint, nickname, address))
35 changes: 35 additions & 0 deletions Selenium/misc/stem2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import functools

from stem import StreamStatus
from stem.control import EventType, Controller

def main():
print("Tracking requests for tor exits. Press 'enter' to end.")
print("")

with Controller.from_port(port=9051) as controller:
controller.authenticate("kode112")

stream_listener = functools.partial(stream_event, controller)
controller.add_event_listener(stream_listener, EventType.STREAM)

input() # wait for user to press enter


def stream_event(controller, event):
if event.status == StreamStatus.SUCCEEDED and event.circ_id:
circ = controller.get_circuit(event.circ_id)

exit_fingerprint = circ.path[-1][0]
exit_relay = controller.get_network_status(exit_fingerprint)

print("Exit relay for our connection to %s" % (event.target))
print(" address: %s:%i" % (exit_relay.address, exit_relay.or_port))
print(" fingerprint: %s" % exit_relay.fingerprint)
print(" nickname: %s" % exit_relay.nickname)
print(" locale: %s" % controller.get_info("ip-to-country/%s" % exit_relay.address, 'unknown'))
print("")


if __name__ == '__main__':
main()
Binary file added Selenium/onion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading