Skip to content

Commit

Permalink
add notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
gijzelaerr committed Oct 7, 2018
1 parent 5469136 commit e28f8d4
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
67 changes: 67 additions & 0 deletions notebooks/os.detection.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"def detect_distro():\n",
" params = {}\n",
" with open('/etc/os-release', 'r') as f:\n",
" for line in f.readlines():\n",
" key, value = line.strip().split('=')\n",
" params[key] = value.strip('\"\"')\n",
" return params['ID'], params['VERSION_ID']"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"('ubuntu', '18.04')"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"detect_distro()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
1 change: 1 addition & 0 deletions notebooks/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
notebook
77 changes: 77 additions & 0 deletions notebooks/secure_dns_spoofing.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import eduvpn.other_nm as NetworkManager\n",
"import dbus\n",
"import subprocess"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"type_tun = 16 # NM_DEVICE_TYPE_TUN\n",
"state_acticated = 100 # NM_DEVICE_STATE_ACTIVATED\n",
"devices = NetworkManager.NetworkManager.GetDevices() \n",
"interfaces = [x.Interface for x in devices if x.State == state_acticated and x.DeviceType == type_tun]\n",
"assert(len(interfaces) == 1)\n",
"interface = interfaces[0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"link = int(subprocess.check_output(['/sbin/ip', 'link', 'show', 'dev', interface]).decode('ascii').split()[0][:-1])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"bus = dbus.SystemBus()\n",
"\n",
"node = \"/org/freedesktop/resolve1\"\n",
"bus_name = 'org.freedesktop.resolve1'\n",
"interface = \"org.freedesktop.resolve1.Manager\"\n",
"\n",
"resolve_proxy = bus.get_object(bus_name=bus_name, object_path=node)\n",
"resolve_iface = dbus.Interface(object=resolve_proxy, dbus_interface=interface)\n",
"\n",
"resolve_iface.SetLinkDomains(link, ((\".\", True),))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit e28f8d4

Please sign in to comment.