<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://elvis.hcw.ac.at/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=DAmon</id>
	<title>Elvis Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://elvis.hcw.ac.at/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=DAmon"/>
	<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php/Special:Contributions/DAmon"/>
	<updated>2026-09-10T16:17:20Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.5</generator>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Pass-the-Hash_(PtH)&amp;diff=5343</id>
		<title>Pass-the-Hash (PtH)</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Pass-the-Hash_(PtH)&amp;diff=5343"/>
		<updated>2020-12-20T23:43:54Z</updated>

		<summary type="html">&lt;p&gt;DAmon: Updated the document&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[Disclamer: this Wiki page is just an explanation of how Pass-The-Hash attack works and how it can be carried out and is done only for educational purposes. &lt;br /&gt;
The author does not hold any responsibility for any misuse of the information included in this Wiki page and advises not to use it for any illegal actions nor in any way that could be harmful to any person or entity.]&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
Pass-the-hash is a method used by hackers to authenticate themselves to servers even if they do not have the password! The technique makes use of a flaw in the user-authentication protocols, such as NTLM and LM.&lt;br /&gt;
&lt;br /&gt;
The authentication protocols authenticate the user by checking the hash of the password instead of the password itself. Hence the hashing algorithm always resolves to the same hash as long as the password is not changed. &lt;br /&gt;
&lt;br /&gt;
This allows the attackers to focus on obtaining the hash, which is a lot easier than trying to get the password using brute-force.&lt;br /&gt;
&lt;br /&gt;
While the attack is more common on windows servers environments, it is still possible to attack, for example, a Linux server that is using the same vulnerable protocols that we are going to discuss.&lt;br /&gt;
&lt;br /&gt;
== Pass-the-Hash Attack ==&lt;br /&gt;
&lt;br /&gt;
It is almost a day-to-day activity these days that administrators and even regular users authenticate to remote servers. &lt;br /&gt;
Since remote servers nowadays are most likely to have valuable information stored, it is only natural to allow access only to authorized users.&lt;br /&gt;
 &lt;br /&gt;
To do this, engineers have to come up with protocols that authenticate and challenge users to prove that they are whom they say they are, usually by providing a password.&lt;br /&gt;
&lt;br /&gt;
Most of these protocols would hash the password on the client-side and then send the hashed password over the network to authenticate. &lt;br /&gt;
The flaw here is that a mere hashing of a password would yield the same hash every time, as long as both the password and the hashing algorithm remain the same.&lt;br /&gt;
&lt;br /&gt;
This would turn the hash itself into an equivalent of that password, and it would lose its meaning. Before we start having a look at how this attack works and how can we mitigate it, let us have a look at the protocols themselves and how they work.&lt;br /&gt;
&lt;br /&gt;
=== NTLM ===&lt;br /&gt;
&lt;br /&gt;
NTLM stands for NT LAN Manager, and was developed by Microsoft, therefore it is mostly implemented in Microsoft products. &lt;br /&gt;
It is an authentication protocol that authenticate users to remote servers, so they can access them. The first version of NTLM turned out to have many issues that made it very insecure over the time.&lt;br /&gt;
&lt;br /&gt;
Some of these vulnerabilities in its algorithms and protocols were:&lt;br /&gt;
&lt;br /&gt;
* No distinguishing between capital and small letters, i.e., case-insensitive.&lt;br /&gt;
* It did not allow long passwords, but only up to 14 chars.&lt;br /&gt;
* Only 56 Bit out of a 128 Bit where used for the key&lt;br /&gt;
&lt;br /&gt;
As we can see, by knowing today&#039;s security standards, there is no need to say why the entire protocol was weak and prone to attacks.&lt;br /&gt;
All this and more have lead to the development of a successor called NTLMv2. It is used for Single-Sign-On (SSO), so User only need to enter the password once in order to access the network resource.&lt;br /&gt;
&lt;br /&gt;
With Windows 10, NTLMv2 was used by default.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Authentication Steps - Network Resource ===&lt;br /&gt;
&lt;br /&gt;
This setup uses an authentication server, here called Domain Controller, which knows all the users and their corresponding hash value of the password, in order to verify them.&lt;br /&gt;
&lt;br /&gt;
[[File:Ntlm-authentication-steps.jpg|850px]]&lt;br /&gt;
&lt;br /&gt;
# The user enters the password of the account&lt;br /&gt;
# The username and the hash of the password get stored in RAM in a process called LSASS (more to that later)&lt;br /&gt;
# The client now sends a request to the network resource in order to access it&lt;br /&gt;
# The server responds with a CHALLENGE message (usually a 16-bit number) to identify the client &lt;br /&gt;
# The client encrypts the challenge with the NTLM hash of the password and sends it back to the server&lt;br /&gt;
# The server sends the username, the encrypted challenge and the plain challenge to the authentication server&lt;br /&gt;
# The authentication server decrypts the message from the client and compares the values&lt;br /&gt;
# If the challenges match, the authentication server informs the server, which then grants the client access&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways to do a PtH attack:&lt;br /&gt;
&lt;br /&gt;
* Compromising a Host and reading out Hashes locally&lt;br /&gt;
** Windows stores hashes of currently logged in domain and local users in memory, in a process called Local Security Authority Subsystem Service (LSASS)&lt;br /&gt;
** The hashes of currently logged out local users are stored in a registry file or also called the Security Account Manager (SAM)&lt;br /&gt;
* Sniffing the network for any hashes that are being transferred&lt;br /&gt;
&lt;br /&gt;
To readout the LSASS process or the SAM, the program needs local admin rights. Thus, the user has to be tricked into executing it with the according rights.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
&lt;br /&gt;
PtH attack can be carried out using a set of tools.&lt;br /&gt;
Some of the most popular tools to carry out the PtH attack are:&lt;br /&gt;
&lt;br /&gt;
* samdump2&lt;br /&gt;
* mimikatz&lt;br /&gt;
&lt;br /&gt;
=== samdump2 ===&lt;br /&gt;
&lt;br /&gt;
samdump2 tool was designed to get dumps of Windows password hashes, namely Windows XP, NT, and 2k, and as the name suggests it does this by taking a dump of the SAM file using something called syskey, which is a feature in Windows that is supposed to strengthen the SAM database by adding and an additional layer of encryption.&lt;br /&gt;
&lt;br /&gt;
=== mimikatz ===&lt;br /&gt;
&lt;br /&gt;
Mimikatz tool, on the other hand, tries to extract hashes, PIN codes, as well as passwords in plain text from memory.&lt;br /&gt;
It is a much stronger tool since it allows a wider variety of other attacks that are mainly focused on playing with the weak security of Windows systems that use the protocols mentioned above.&lt;br /&gt;
Mimikatz is also one of few tools that got updated, after Windows Defender Credential Guard (WDCG) was enabled by default with Windows 10. WDCG made the access to the LSASS process extremely difficult.&lt;br /&gt;
This concludes the set of tools that are going to be used in the accompanying demonstration of this essay to demonstrate how PtH attack works when using these tools.&lt;br /&gt;
&lt;br /&gt;
== Mitigation ==&lt;br /&gt;
&lt;br /&gt;
Over the years, many improvements to the vulnerable protocols in question have been released, and more and more studies are being done by Microsoft [5] and other institutions to mitigate this attack.&lt;br /&gt;
Some of the mitigation techniques that are mentioned in these studies are:&lt;br /&gt;
&lt;br /&gt;
# Protecting the accounts that have high-privileges by adding more restrictions to them.&lt;br /&gt;
# Removing administrative privileges to local accounts and then restricting these accounts to help to prevent the attackers from taking advantage of such accounts.&lt;br /&gt;
# Adding firewall rules that would restrict the incoming traffic to the server.&lt;br /&gt;
# Correlating Authentication Services.&lt;br /&gt;
&lt;br /&gt;
== Demonstration using mimikatz ==&lt;br /&gt;
&lt;br /&gt;
In our scenario, we have two computers that belong to different domains but are inside the same intranet network, let us say one belongs to the administrators&#039; domain, and the second one belongs to the employees&#039; domain.&lt;br /&gt;
&lt;br /&gt;
All that is left now is for someone from the employee domain, to ask someone from the administrators&#039; domain to install something on their PC using their admin account. &lt;br /&gt;
&lt;br /&gt;
When the administrator logs in to the employee&#039;s pc, the hash value is saved locally in the LSASS process. Now the attack is ready to be carried out.&lt;br /&gt;
&lt;br /&gt;
Because the employee knows a way to become local admin he downloads mimikatz, executes it and types the following:&lt;br /&gt;
&lt;br /&gt;
 privilege::debug;&lt;br /&gt;
&lt;br /&gt;
This command grant mimikatz debug rights which are also needed.&lt;br /&gt;
&lt;br /&gt;
 sekurlsa::logonpasswords;&lt;br /&gt;
&lt;br /&gt;
This would then show a dump of all the NTLM hashes that are stored on the system, and of course, it also includes the NTLM hash of the domain administrator.&lt;br /&gt;
&lt;br /&gt;
Now the employee can use the information of that admin (username, domain, and NTLM hash) to authenticate to other clients and servers in that domain. &lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
The pass-the-hash attack can be a horrifying attack given what kind of privileges it gives the attacker in the case of a successful attack, but this is not the end of the mitigation methods that were implemented with a regular update to the system it should mitigate the attack and protect servers against it. Also, there is a server lining, in that it pushes forward the security of Windows servers and let the developers focus on improving them to let system administrators have much more secure servers to deal with.&lt;br /&gt;
&lt;br /&gt;
== Sources ==&lt;br /&gt;
&lt;br /&gt;
* https://github.com/gentilkiwi/mimikatz&lt;br /&gt;
* https://linux.die.net/man/1/samdump2&lt;br /&gt;
* https://www.sans.org/reading-room/whitepapers/testing/pass-the-hash-attacks-tools-mitigation-33283&lt;br /&gt;
* https://www.microsoft.com/en-us/download/details.aspx?id=36036&lt;br /&gt;
* https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-nlmp/a4f28e01-3df1-4fd1-80b2-df1fbc183f21&lt;br /&gt;
* https://docs.microsoft.com/en-us/security-updates/SecurityAdvisories/2016/2871997?redirectedfrom=MSDN&lt;br /&gt;
* https://ieeexplore.ieee.org/document/7474171&lt;br /&gt;
* https://www.sans.org/reading-room/whitepapers/testing/pass-the-hash-windows-10-39170&lt;br /&gt;
* &lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Ntlm-authentication-steps.jpg&amp;diff=5337</id>
		<title>File:Ntlm-authentication-steps.jpg</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Ntlm-authentication-steps.jpg&amp;diff=5337"/>
		<updated>2020-12-20T22:13:09Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=4312</id>
		<title>Install c&#039;t&#039;-Raspion on Raspberry PI</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=4312"/>
		<updated>2020-06-27T11:22:28Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
* Raspberry PI with Raspbian OS&lt;br /&gt;
* Internet connection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
=== Step 1: System Update ===&lt;br /&gt;
&lt;br /&gt;
In the command line interface enter:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Download ===&lt;br /&gt;
Download the latest version of Raspion:&lt;br /&gt;
&lt;br /&gt;
 wget ct.de/s/x5Pm -O raspion.zip &lt;br /&gt;
&lt;br /&gt;
=== Step 3: Installation ===&lt;br /&gt;
Unzip:&lt;br /&gt;
 unzip raspion.zip&lt;br /&gt;
&lt;br /&gt;
Install:&lt;br /&gt;
 cd raspion&lt;br /&gt;
 ./install.sh or bash install.sh&lt;br /&gt;
&lt;br /&gt;
[[File:Install_Raspion.png]]&lt;br /&gt;
&lt;br /&gt;
At the end of the installation there is the wifi name and password of the c&#039;t-Raspion.&lt;br /&gt;
&lt;br /&gt;
=== Launch c&#039;t-Raspion web interface ===&lt;br /&gt;
Atfer connecting to the wifi of the c&#039;t&#039;-Raspion go to http://&amp;lt;ip-address of your Raspberry-PI&amp;gt;:81&lt;br /&gt;
&lt;br /&gt;
[[File:Raspion_webinterface.png]]&lt;br /&gt;
&lt;br /&gt;
== Services of the c&#039;t-Raspion ==&lt;br /&gt;
&lt;br /&gt;
=== Pi-hole ===&lt;br /&gt;
Pi-hole shows DNS-Requests. They can also be blocked.&lt;br /&gt;
&lt;br /&gt;
[[File:Pi-hole.png]]&lt;br /&gt;
&lt;br /&gt;
=== ntopng ===&lt;br /&gt;
They include the&lt;br /&gt;
involved communication partners, the network protocol and information on duration and volume. ntopng does not show the contents of the packages. But it analyses the flows and provides information about which application is communicating, such as Skype, BitTorrent etc., and provides statistics.&lt;br /&gt;
&lt;br /&gt;
=== Wireshark ===&lt;br /&gt;
Wireshark offers a deeper analysis of the network traffic as ntopng.  The program allows recording and analyzing network traffic down to the last bit and can be operated via browser as a special feature of c&#039;t-Raspion. The recorded network traffic will be saved in pcap-files.&lt;br /&gt;
 &lt;br /&gt;
=== mitmproxy ===&lt;br /&gt;
The mitm-Proxy can loop into the communication between the local and remote devices by the c&#039;t-Raspion redirecting all access from the internal network on TCP ports 80 and 443 to the mitm-Proxy. It takes the redirected accesses to port&lt;br /&gt;
8080 towards. The redirection is handled by firewall rules, which  can be activated and deactivated as required by clicking in the c&#039;t-Raspion web interface.&lt;br /&gt;
&lt;br /&gt;
== Ikea Tradfri Setup Sniff ==&lt;br /&gt;
For testing purposes an iphone was cleaned as far as possible. All uninstalable services were erased and synchronization plans were deactivated.&lt;br /&gt;
However iphones are not that good for this kind of tests because after all cleaning there were still some connections to apple servers.&lt;br /&gt;
&lt;br /&gt;
To use pihole for capturing the dns queries of the Tradfri Gateway itself you may use an USB networkadapter or an external router as wifi bride. Otherwise you cannot use the Tradfri Gateway due to the lack of connection possibilities. As an workaround outside the Raspion software package classic arpspoofing was used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Preliminary overview IP addressess:&lt;br /&gt;
&lt;br /&gt;
[[File:ip-config.png|900px]]&lt;br /&gt;
&lt;br /&gt;
Immediately after power on the app is sending dns requests to get ip addresses for fw.ota.homesmart.ikea.net. In the dns answer the ip&#039;s to d262cmbxmzphsu.cloudfront.net were included which is an address belonging to amazons aws.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap1.png|700px]]&lt;br /&gt;
[[File:wireshark-cap2.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Also an http get request can be found:&lt;br /&gt;
[[File:wireshark-cap-http.png|600px]]&lt;br /&gt;
&lt;br /&gt;
The data from fw.ota.homesmart.ikea.net/feed/version_info.json are not that spectacular. As the name implies it only consists of version information.&lt;br /&gt;
&lt;br /&gt;
As soon as the Ikea Smart Home App starts the setup it tries to find a Tradfri Gateway with mDNS queries.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-mDNS.png|550px]]&lt;br /&gt;
&lt;br /&gt;
The mDNS queries are not forwarded through our pihole setup so this technique finding the Tradfri Gateway fails. The app itself provides another way to find the Tradfri Gateway by entering the ip address directly. After submitting the input the app finds the gateway and asks you to scan the QR code on the bottom side of the divce or to enter the security code which can be found near the QR code.&lt;br /&gt;
&lt;br /&gt;
The QR code contains the security code which is used as the pre shared key of the DTLS connection. As soon as the app gets the security code the app and the gateway are initiating the DTLS connection. All applicationdata is send over this encrypted connection.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls.png|550px]]&lt;br /&gt;
&lt;br /&gt;
Same implies to connections of additional smart home devices: All data is sent over the encrypted connection.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls-snap.png|550px]]&lt;br /&gt;
&lt;br /&gt;
As far as the initial setup goes there are only a few connections to the internet. This connections are all from app to some aws cloud addresses. It seems this is relating to the setup of a new device:&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-aws.png|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Data Transmission when using TRADFRI ==&lt;br /&gt;
&lt;br /&gt;
The IKEA TRADFRI Gateway was connected via LAN cable while the mobile phone running the IKEA app was connected wirelessly to the same network.&lt;br /&gt;
Overview of IP addresses used:&lt;br /&gt;
&lt;br /&gt;
[[File:ip_overview_muzik.png|550px]]&lt;br /&gt;
&lt;br /&gt;
Wireshark was used to record the traffic (using arpspoof because the IKEA TRADFRI Gateway requires a LAN connection so it is not possible to just monitor the Raspion WiFi) which was then filtered.&lt;br /&gt;
&lt;br /&gt;
It turns out that TRADFRI is rather well-behaved when it comes to sending data.&lt;br /&gt;
&lt;br /&gt;
For the most part it uses encrypted (DTLS) communication internally between the Gateway and the mobile phone. To initially find the Gateway after opening the mobile app, an MDNS request is sent out via multicast (224.x.x.x).&lt;br /&gt;
&lt;br /&gt;
However, 2 external connections or destinations could also be found:&lt;br /&gt;
&lt;br /&gt;
* IP address 13.227.156.82 / privacypolicy.config.homesmart.ikea.net (as the url indicates, this has the current policy one has to agree to before using the app)&lt;br /&gt;
* IP address 13.227.156.50 / supportdetails.config.homesmart.ikea.net (this is where the secure certificates are located, apparently).&lt;br /&gt;
&lt;br /&gt;
=== Wireshark caps ===&lt;br /&gt;
privacypolicy.config.homesmart.ikea.net Client Hello:&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-privacy policy-clientHello.png|700px]]&lt;br /&gt;
&lt;br /&gt;
supportdetails.config.homesmart.ikea.net ServerHello:&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-supportdetails-serverHello.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== Certificate Information ===&lt;br /&gt;
The Server Hello contains the information regarding the .cer and .crl:&lt;br /&gt;
 http://ocsp.rootca1.amazontrust.com&lt;br /&gt;
 http://crt.rootca1.amazontrust.com/rootca1.cer&lt;br /&gt;
 http://crl.rootca1.amazontrust.com/rootca1.crl&lt;br /&gt;
Starfield Technologies, Inc.; Starfield Services Root Certificate Authority&lt;br /&gt;
&lt;br /&gt;
Also:&lt;br /&gt;
 http://crl.sca1b.amazontrust.com/sca1b.crl&lt;br /&gt;
 http://ocsp.sca1b.amazontrust.com&lt;br /&gt;
 http://crt.sca1b.amazontrust.com/sca1b.crt &lt;br /&gt;
&lt;br /&gt;
That&#039;s pretty much it. We couldn&#039;t find any unwanted connections.&lt;br /&gt;
&lt;br /&gt;
The app also checks for updates for the used devices, this is also indicated in the app when it happens, so this is very transparent. It is indicated in the app when an update is happening or when the app is checking for new updates as can be seen in the screenshot below. If a device happens to be unavailable, e.g. because it is currently disconnected/turned off, then the app does not report back the current version but instead says the device is unreachable (&#039;Nicht erreichbar&#039;)&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-tradfri-update.png|360px]]&lt;br /&gt;
&lt;br /&gt;
=== Turning devices on/off ===&lt;br /&gt;
When devices are turned on or off, the individual packet sequences are made up of packets that are the same in size but with some devices there are more packets sent when turning on than off. Let me illustrate this by comparing the on/off sequences of the light bulb (pretty much the same for on/off, although of course different packet content):&lt;br /&gt;
&lt;br /&gt;
Light Bulb ON&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-gluehbirne_ein.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Light Bulb OFF&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-gluehbirne_aus.png|700px]]&lt;br /&gt;
&lt;br /&gt;
As opposed to the smart plug where the on sequence is longer than the off sequence:&lt;br /&gt;
&lt;br /&gt;
Smart Plug ON&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-strom ein.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Smart Plug OFF&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-strom aus.png|700px]]&lt;br /&gt;
&lt;br /&gt;
(these were done using arpspoof on 192.168.0.106, 192.168.0.101 is the Internet Gateway, 192.168.0.104 is the TRADFRI Gateway, commands were sent via 192.168.0.103 - so keep in mind that you see duplicates of each packet in the Wireshark caps because they include the sniff and forward to the actual target device)&lt;br /&gt;
&lt;br /&gt;
== Interrupt Communication ==&lt;br /&gt;
This experiment will show if it is possible to interrupt or sniff the communication between the IKEA and the IKEA gateway. This is not possible with only a packet sniffer like Wireshark, because the communication is encrypted with DTLS. Two attacks were performed, a mitm proxy attack and a replay attack. For the mitm attack the mitm proxy from the c’t Raspion was used and for the replay attack a scapy script.  The network structure is as follows:&lt;br /&gt;
&lt;br /&gt;
IP overview:&lt;br /&gt;
&lt;br /&gt;
[[File:mitm_findings.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== Structure ===&lt;br /&gt;
[[File:mitm-top.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Android can be operated as a virtual machine, or you can also use a smart phone that has the IKEA Smarthome app installed. If it is operated as a virtual machine, make sure that bridge mode is used, since the VM will then have its own IP. This has the advantage that you only have to analyze the traffic generated by Android and not that of the host system.&lt;br /&gt;
&lt;br /&gt;
In order to be able to use the mitm, certificates must be added to the key store on the android os. This can be done by opening the website mitm.it in the browser of android. If you are in the right network, you will see the following window.&lt;br /&gt;
&lt;br /&gt;
[[File:mitmproxy-cert.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Here you choose the right operating system and download the certificates.&lt;br /&gt;
&lt;br /&gt;
The official documentation can be found here[https://docs.mitmproxy.org/stable/concepts-certificates/#quick-setup].&lt;br /&gt;
&lt;br /&gt;
=== MitM Proxy ===&lt;br /&gt;
When you start the app in Wireshark you can see that the handshake for the DTLS connection is being carried out.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-dtls.png]]&lt;br /&gt;
&lt;br /&gt;
You can also observe that there are several connections to different servers outside the network.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-tls.png]]&lt;br /&gt;
&lt;br /&gt;
The following messages can be decrypted.&lt;br /&gt;
&lt;br /&gt;
[[File:mitm-sniff.png]]&lt;br /&gt;
&lt;br /&gt;
Both include a JSON-file.&lt;br /&gt;
&lt;br /&gt;
[[File:Json-file-mitm.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* In the debug log, you can observe that there are additional TLS connections, but the mitm proxy couldn’t decrypt these.&lt;br /&gt;
&lt;br /&gt;
 192.168.24.241:59332: Client Handshake failed. The client may not trust the proxy&#039;s certificate for data.logentries.com.&lt;br /&gt;
 192.168.24.241:59332: ClientHandshakeException(&#039;Cannot establish TLS with client (sni: data.logentries.com): TlsException(&amp;quot;(-1, \&#039;Unexpected EOF\&#039;)&amp;quot;)&#039;)&lt;br /&gt;
 ::ffff:192.168.24.241:58971: serverdisconnect&lt;br /&gt;
  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
 192.168.24.241:59332: clientdisconnect&lt;br /&gt;
 ::ffff:192.168.24.241:40204: serverdisconnect&lt;br /&gt;
  -&amp;gt; (&#039;99.86.243.50&#039;, 443)&lt;br /&gt;
 192.168.24.241:58971: clientdisconnect&lt;br /&gt;
 192.168.24.241:40204: clientdisconnect&lt;br /&gt;
 192.168.24.241:41657: clientconnect&lt;br /&gt;
 ::ffff:192.168.24.241:41657: Establish TLS with client&lt;br /&gt;
 192.168.24.241:50453: clientconnect&lt;br /&gt;
 ::ffff:192.168.24.241:50453: serverconnect&lt;br /&gt;
  -&amp;gt; (&#039;99.86.243.36&#039;, 443)&lt;br /&gt;
 192.168.24.241:42222: clientconnect&lt;br /&gt;
 ::ffff:192.168.24.241:42222: serverconnect&lt;br /&gt;
  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
 ::ffff:192.168.24.241:42222: Establish TLS with server&lt;br /&gt;
 ::ffff:192.168.24.241:50453: Establish TLS with server&lt;br /&gt;
 ::ffff:192.168.24.241:42222: ALPN selected by server: -&lt;br /&gt;
 ::ffff:192.168.24.241:42222: Establish TLS with client&lt;br /&gt;
 ::ffff:192.168.24.241:50453: ALPN selected by server: -&lt;br /&gt;
 ::ffff:192.168.24.241:50453: Establish TLS with client&lt;br /&gt;
 ::ffff:192.168.24.241:42222: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
 ::ffff:192.168.24.241:50453: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
 ::ffff:192.168.24.241:50453: request&lt;br /&gt;
  -&amp;gt; Request(GET /US/en/getPolicyUpdate/?deviceType=android)&lt;br /&gt;
 ::ffff:192.168.24.241:42222: request&lt;br /&gt;
  -&amp;gt; Request(GET /AppDetails)&lt;br /&gt;
 ::ffff:192.168.24.241:42222: response&lt;br /&gt;
  -&amp;gt; Response(200 OK, application/json, 44b)&lt;br /&gt;
 ::ffff:192.168.24.241:50453: response&lt;br /&gt;
  -&amp;gt; Response(200 OK, application/json, 374b)&lt;br /&gt;
&lt;br /&gt;
The DTLS connection between the app and the gateway, however, does not appear in the mitm log.&lt;br /&gt;
&lt;br /&gt;
=== Replay-Attack ===&lt;br /&gt;
In order to be able to carry out a replay attack, the data traffic between the device on which the IKEA app is running and the IKEA gateway must be recorded. Every time you close the app and open it again, a new transmission must be recorded. This is because this is a new session, so the IKEA Gateway and the App have a new shared secret. Then the SRC and DST in IP and MAC have to be adjusted accordingly. In this particular example, a sequence number is available in the DTLS protocol. This must also be adjusted so that it is preliminary. Since the payload is also included in the UDP checksum, it must be recalculated too. This attack was performed on the TKEA Gateway, where a socket was connected to. In the socket was light plugged in to see what&#039;s happening.&lt;br /&gt;
&lt;br /&gt;
[[File:replay-attack.png]]&lt;br /&gt;
&lt;br /&gt;
As you can see, the attack is unsuccessful because no response is sent from the gateway, which is likely to drop the packets.&lt;br /&gt;
&lt;br /&gt;
This may be because DTLS also uses MAC (message authentication code). The sequence number is used to calculate the MAC value. Unfortunately, this value cannot be recalculated without knowing the encryption.&lt;br /&gt;
&lt;br /&gt;
=== Change Sequence Number ===&lt;br /&gt;
To change the sequence number, we used a workaround in Wireshark. In Wireshark you can select multiple Packets and then copy them as hex dump. &lt;br /&gt;
&lt;br /&gt;
[[File:Wireshark-save-hexdump.png|700px]]&lt;br /&gt;
&lt;br /&gt;
 0000   dc a6 32 7d 1d 37 c0 ee fb 4a 9b b5 08 00 45 00&lt;br /&gt;
 0010   00 69 57 0a 40 00 40 11 47 f6 c0 a8 18 f1 c0 a8&lt;br /&gt;
 0020   01 42 a4 1a 16 34 00 55 ff 2e 17 fe fd 00 01 00&lt;br /&gt;
 0030   00 00 00 00 34 00 40 00 00 00 00 00 00 00 16 21&lt;br /&gt;
 0040   39 8a 8a c5 dd c3 3d 67 ba de a5 5f 0a 10 8c e2&lt;br /&gt;
 0050   75 da ca a1 db ae a2 08 c6 e6 a6 94 32 db d0 cd&lt;br /&gt;
 0060   d1 63 e6 bd 32 db 2f 14 1a a1 08 be e9 ac ff 43&lt;br /&gt;
 0070   48 1b 54 a9 f9 f7 4f&lt;br /&gt;
&lt;br /&gt;
After you have copied the packet you can put it into a texteditor and edit the part of the packet you want. In our case we changed the 00 00 00 00 00 34 in line 0020 and 0030 to the appropriate sequence number. We found out that after each full communication the number raised by four. So, when the last recorded sequence number was 48 the next one is 52 and then 56 and so on. This is the decimal number you have to convert it so hex and change it in the text editor and save it.&lt;br /&gt;
&lt;br /&gt;
In wireshark it is possible to import packets from a textfile with hexdump in it. &lt;br /&gt;
&lt;br /&gt;
[[File:Wireshark-import-hexdump1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Wireshark-import-hexdump2.png]]&lt;br /&gt;
&lt;br /&gt;
After you have imported the hexdump save the file as pcap file.&lt;br /&gt;
&lt;br /&gt;
In order to send the packets, edit the marked parts in the python script.&lt;br /&gt;
&lt;br /&gt;
 #! /usr/bin/python3&lt;br /&gt;
 from scapy.all import *&lt;br /&gt;
 from scapy.utils import rdpcap&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 pkts=rdpcap(&amp;quot;path of the pcap file&amp;quot;)  # reads the pcap file and saves the list in the pkts var&lt;br /&gt;
 &lt;br /&gt;
 # iterates through the list&lt;br /&gt;
 for pkt in pkts:&lt;br /&gt;
      pkt[Ether].src = &amp;quot;&#039;&#039;&#039;sender mac&#039;&#039;&#039;&amp;quot;  # MAC of the sender&lt;br /&gt;
      pkt[Ether].dst= &amp;quot;&#039;&#039;&#039;target mac&#039;&#039;&#039;&amp;quot;  # MAC of the target&lt;br /&gt;
 &lt;br /&gt;
      pkt[IP].src= &amp;quot;&#039;&#039;&#039;sender ip&#039;&#039;&#039;&amp;quot; # IP of the sender&lt;br /&gt;
      pkt[IP].dst = &amp;quot;&#039;&#039;&#039;target ip&#039;&#039;&#039;&amp;quot;  # IP of the target&lt;br /&gt;
 &lt;br /&gt;
      del pkt.chksum # deletes the current checksum in the IP header&lt;br /&gt;
      del pkt[UDP].chksum # deletes the checksum in UDP header&lt;br /&gt;
      pkt = pkt.__class__(bytes(pkt)) # scapy builds the packet new and calculates the missing checksums new&lt;br /&gt;
 &lt;br /&gt;
      sendp(pkt) # sending packet&lt;br /&gt;
      time.sleep(2)&lt;br /&gt;
&lt;br /&gt;
After that the script can be executed.&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=4311</id>
		<title>Install c&#039;t&#039;-Raspion on Raspberry PI</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=4311"/>
		<updated>2020-06-27T11:21:14Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
* Raspberry PI with Raspbian OS&lt;br /&gt;
* Internet connection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
=== Step 1: System Update ===&lt;br /&gt;
&lt;br /&gt;
In the command line interface enter:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Download ===&lt;br /&gt;
Download the latest version of Raspion:&lt;br /&gt;
&lt;br /&gt;
 wget ct.de/s/x5Pm -O raspion.zip &lt;br /&gt;
&lt;br /&gt;
=== Step 3: Installation ===&lt;br /&gt;
Unzip:&lt;br /&gt;
 unzip raspion.zip&lt;br /&gt;
&lt;br /&gt;
Install:&lt;br /&gt;
 cd raspion&lt;br /&gt;
 ./install.sh or bash install.sh&lt;br /&gt;
&lt;br /&gt;
[[File:Install_Raspion.png]]&lt;br /&gt;
&lt;br /&gt;
At the end of the installation there is the wifi name and password of the c&#039;t-Raspion.&lt;br /&gt;
&lt;br /&gt;
=== Launch c&#039;t-Raspion web interface ===&lt;br /&gt;
Atfer connecting to the wifi of the c&#039;t&#039;-Raspion go to http://&amp;lt;ip-address of your Raspberry-PI&amp;gt;:81&lt;br /&gt;
&lt;br /&gt;
[[File:Raspion_webinterface.png]]&lt;br /&gt;
&lt;br /&gt;
== Services of the c&#039;t-Raspion ==&lt;br /&gt;
&lt;br /&gt;
=== Pi-hole ===&lt;br /&gt;
Pi-hole shows DNS-Requests. They can also be blocked.&lt;br /&gt;
&lt;br /&gt;
[[File:Pi-hole.png]]&lt;br /&gt;
&lt;br /&gt;
=== ntopng ===&lt;br /&gt;
They include the&lt;br /&gt;
involved communication partners, the network protocol and information on duration and volume. ntopng does not show the contents of the packages. But it analyses the flows and provides information about which application is communicating, such as Skype, BitTorrent etc., and provides statistics.&lt;br /&gt;
&lt;br /&gt;
=== Wireshark ===&lt;br /&gt;
Wireshark offers a deeper analysis of the network traffic as ntopng.  The program allows recording and analyzing network traffic down to the last bit and can be operated via browser as a special feature of c&#039;t-Raspion. The recorded network traffic will be saved in pcap-files.&lt;br /&gt;
 &lt;br /&gt;
=== mitmproxy ===&lt;br /&gt;
The mitm-Proxy can loop into the communication between the local and remote devices by the c&#039;t-Raspion redirecting all access from the internal network on TCP ports 80 and 443 to the mitm-Proxy. It takes the redirected accesses to port&lt;br /&gt;
8080 towards. The redirection is handled by firewall rules, which  can be activated and deactivated as required by clicking in the c&#039;t-Raspion web interface.&lt;br /&gt;
&lt;br /&gt;
== Ikea Tradfri Setup Sniff ==&lt;br /&gt;
For testing purposes an iphone was cleaned as far as possible. All uninstalable services were erased and synchronization plans were deactivated.&lt;br /&gt;
However iphones are not that good for this kind of tests because after all cleaning there were still some connections to apple servers.&lt;br /&gt;
&lt;br /&gt;
To use pihole for capturing the dns queries of the Tradfri Gateway itself you may use an USB networkadapter or an external router as wifi bride. Otherwise you cannot use the Tradfri Gateway due to the lack of connection possibilities. As an workaround outside the Raspion software package classic arpspoofing was used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Preliminary overview IP addressess:&lt;br /&gt;
&lt;br /&gt;
[[File:ip-config.png|900px]]&lt;br /&gt;
&lt;br /&gt;
Immediately after power on the app is sending dns requests to get ip addresses for fw.ota.homesmart.ikea.net. In the dns answer the ip&#039;s to d262cmbxmzphsu.cloudfront.net were included which is an address belonging to amazons aws.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap1.png|700px]]&lt;br /&gt;
[[File:wireshark-cap2.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Also an http get request can be found:&lt;br /&gt;
[[File:wireshark-cap-http.png|600px]]&lt;br /&gt;
&lt;br /&gt;
The data from fw.ota.homesmart.ikea.net/feed/version_info.json are not that spectacular. As the name implies it only consists of version information.&lt;br /&gt;
&lt;br /&gt;
As soon as the Ikea Smart Home App starts the setup it tries to find a Tradfri Gateway with mDNS queries.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-mDNS.png|550px]]&lt;br /&gt;
&lt;br /&gt;
The mDNS queries are not forwarded through our pihole setup so this technique finding the Tradfri Gateway fails. The app itself provides another way to find the Tradfri Gateway by entering the ip address directly. After submitting the input the app finds the gateway and asks you to scan the QR code on the bottom side of the divce or to enter the security code which can be found near the QR code.&lt;br /&gt;
&lt;br /&gt;
The QR code contains the security code which is used as the pre shared key of the DTLS connection. As soon as the app gets the security code the app and the gateway are initiating the DTLS connection. All applicationdata is send over this encrypted connection.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls.png|550px]]&lt;br /&gt;
&lt;br /&gt;
Same implies to connections of additional smart home devices: All data is sent over the encrypted connection.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls-snap.png|550px]]&lt;br /&gt;
&lt;br /&gt;
As far as the initial setup goes there are only a few connections to the internet. This connections are all from app to some aws cloud addresses. It seems this is relating to the setup of a new device:&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-aws.png|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Data Transmission when using TRADFRI ==&lt;br /&gt;
&lt;br /&gt;
The IKEA TRADFRI Gateway was connected via LAN cable while the mobile phone running the IKEA app was connected wirelessly to the same network.&lt;br /&gt;
Overview of IP addresses used:&lt;br /&gt;
&lt;br /&gt;
[[File:ip_overview_muzik.png|550px]]&lt;br /&gt;
&lt;br /&gt;
Wireshark was used to record the traffic (using arpspoof because the IKEA TRADFRI Gateway requires a LAN connection so it is not possible to just monitor the Raspion WiFi) which was then filtered.&lt;br /&gt;
&lt;br /&gt;
It turns out that TRADFRI is rather well-behaved when it comes to sending data.&lt;br /&gt;
&lt;br /&gt;
For the most part it uses encrypted (DTLS) communication internally between the Gateway and the mobile phone. To initially find the Gateway after opening the mobile app, an MDNS request is sent out via multicast (224.x.x.x).&lt;br /&gt;
&lt;br /&gt;
However, 2 external connections or destinations could also be found:&lt;br /&gt;
&lt;br /&gt;
* IP address 13.227.156.82 / privacypolicy.config.homesmart.ikea.net (as the url indicates, this has the current policy one has to agree to before using the app)&lt;br /&gt;
* IP address 13.227.156.50 / supportdetails.config.homesmart.ikea.net (this is where the secure certificates are located, apparently).&lt;br /&gt;
&lt;br /&gt;
=== Wireshark caps ===&lt;br /&gt;
privacypolicy.config.homesmart.ikea.net Client Hello:&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-privacy policy-clientHello.png|700px]]&lt;br /&gt;
&lt;br /&gt;
supportdetails.config.homesmart.ikea.net ServerHello:&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-supportdetails-serverHello.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== Certificate Information ===&lt;br /&gt;
The Server Hello contains the information regarding the .cer and .crl:&lt;br /&gt;
 http://ocsp.rootca1.amazontrust.com&lt;br /&gt;
 http://crt.rootca1.amazontrust.com/rootca1.cer&lt;br /&gt;
 http://crl.rootca1.amazontrust.com/rootca1.crl&lt;br /&gt;
Starfield Technologies, Inc.; Starfield Services Root Certificate Authority&lt;br /&gt;
&lt;br /&gt;
Also:&lt;br /&gt;
 http://crl.sca1b.amazontrust.com/sca1b.crl&lt;br /&gt;
 http://ocsp.sca1b.amazontrust.com&lt;br /&gt;
 http://crt.sca1b.amazontrust.com/sca1b.crt &lt;br /&gt;
&lt;br /&gt;
That&#039;s pretty much it. We couldn&#039;t find any unwanted connections.&lt;br /&gt;
&lt;br /&gt;
The app also checks for updates for the used devices, this is also indicated in the app when it happens, so this is very transparent. It is indicated in the app when an update is happening or when the app is checking for new updates as can be seen in the screenshot below. If a device happens to be unavailable, e.g. because it is currently disconnected/turned off, then the app does not report back the current version but instead says the device is unreachable (&#039;Nicht erreichbar&#039;)&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-tradfri-update.png|360px]]&lt;br /&gt;
&lt;br /&gt;
=== Turning devices on/off ===&lt;br /&gt;
When devices are turned on or off, the individual packet sequences are made up of packets that are the same in size but with some devices there are more packets sent when turning on than off. Let me illustrate this by comparing the on/off sequences of the light bulb (pretty much the same for on/off, although of course different packet content):&lt;br /&gt;
&lt;br /&gt;
Light Bulb ON&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-gluehbirne_ein.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Light Bulb OFF&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-gluehbirne_aus.png|700px]]&lt;br /&gt;
&lt;br /&gt;
As opposed to the smart plug where the on sequence is longer than the off sequence:&lt;br /&gt;
&lt;br /&gt;
Smart Plug ON&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-strom ein.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Smart Plug OFF&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-strom aus.png|700px]]&lt;br /&gt;
&lt;br /&gt;
(these were done using arpspoof on 192.168.0.106, 192.168.0.101 is the Internet Gateway, 192.168.0.104 is the TRADFRI Gateway, commands were sent via 192.168.0.103 - so keep in mind that you see duplicates of each packet in the Wireshark caps because they include the sniff and forward to the actual target device)&lt;br /&gt;
&lt;br /&gt;
== Interrupt Communication ==&lt;br /&gt;
This experiment will show if it is possible to interrupt or sniff the communication between the IKEA and the IKEA gateway. This is not possible with only a packet sniffer like Wireshark, because the communication is encrypted with DTLS. Two attacks were performed, a mitm proxy attack and a replay attack. For the mitm attack the mitm proxy from the c’t Raspion was used and for the replay attack a scapy script.  The network structure is as follows:&lt;br /&gt;
&lt;br /&gt;
IP overview:&lt;br /&gt;
&lt;br /&gt;
[[File:mitm_findings.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== Structure ===&lt;br /&gt;
[[File:mitm-top.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Android can be operated as a virtual machine, or you can also use a smart phone that has the IKEA Smarthome app installed. If it is operated as a virtual machine, make sure that bridge mode is used, since the VM will then have its own IP. This has the advantage that you only have to analyze the traffic generated by Android and not that of the host system.&lt;br /&gt;
&lt;br /&gt;
In order to be able to use the mitm, certificates must be added to the key store on the android os. This can be done by opening the website mitm.it in the browser of android. If you are in the right network, you will see the following window.&lt;br /&gt;
&lt;br /&gt;
[[File:mitmproxy-cert.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Here you choose the right operating system and download the certificates.&lt;br /&gt;
&lt;br /&gt;
The official documentation can be found here[https://docs.mitmproxy.org/stable/concepts-certificates/#quick-setup].&lt;br /&gt;
&lt;br /&gt;
=== MitM Proxy ===&lt;br /&gt;
When you start the app in Wireshark you can see that the handshake for the DTLS connection is being carried out.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-dtls.png]]&lt;br /&gt;
&lt;br /&gt;
You can also observe that there are several connections to different servers outside the network.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-tls.png]]&lt;br /&gt;
&lt;br /&gt;
The following messages can be decrypted.&lt;br /&gt;
&lt;br /&gt;
[[File:mitm-sniff.png]]&lt;br /&gt;
&lt;br /&gt;
Both include a JSON-file.&lt;br /&gt;
&lt;br /&gt;
[[File:Json-file-mitm.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* In the debug log, you can observe that there are additional TLS connections, but the mitm proxy couldn’t decrypt these.&lt;br /&gt;
&lt;br /&gt;
 192.168.24.241:59332: Client Handshake failed. The client may not trust the proxy&#039;s certificate for data.logentries.com.&lt;br /&gt;
 192.168.24.241:59332: ClientHandshakeException(&#039;Cannot establish TLS with client (sni: data.logentries.com): TlsException(&amp;quot;(-1, \&#039;Unexpected EOF\&#039;)&amp;quot;)&#039;)&lt;br /&gt;
 ::ffff:192.168.24.241:58971: serverdisconnect&lt;br /&gt;
  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
 192.168.24.241:59332: clientdisconnect&lt;br /&gt;
 ::ffff:192.168.24.241:40204: serverdisconnect&lt;br /&gt;
  -&amp;gt; (&#039;99.86.243.50&#039;, 443)&lt;br /&gt;
 192.168.24.241:58971: clientdisconnect&lt;br /&gt;
 192.168.24.241:40204: clientdisconnect&lt;br /&gt;
 192.168.24.241:41657: clientconnect&lt;br /&gt;
 ::ffff:192.168.24.241:41657: Establish TLS with client&lt;br /&gt;
 192.168.24.241:50453: clientconnect&lt;br /&gt;
 ::ffff:192.168.24.241:50453: serverconnect&lt;br /&gt;
  -&amp;gt; (&#039;99.86.243.36&#039;, 443)&lt;br /&gt;
 192.168.24.241:42222: clientconnect&lt;br /&gt;
 ::ffff:192.168.24.241:42222: serverconnect&lt;br /&gt;
  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
 ::ffff:192.168.24.241:42222: Establish TLS with server&lt;br /&gt;
 ::ffff:192.168.24.241:50453: Establish TLS with server&lt;br /&gt;
 ::ffff:192.168.24.241:42222: ALPN selected by server: -&lt;br /&gt;
 ::ffff:192.168.24.241:42222: Establish TLS with client&lt;br /&gt;
 ::ffff:192.168.24.241:50453: ALPN selected by server: -&lt;br /&gt;
 ::ffff:192.168.24.241:50453: Establish TLS with client&lt;br /&gt;
 ::ffff:192.168.24.241:42222: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
 ::ffff:192.168.24.241:50453: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
 ::ffff:192.168.24.241:50453: request&lt;br /&gt;
  -&amp;gt; Request(GET /US/en/getPolicyUpdate/?deviceType=android)&lt;br /&gt;
 ::ffff:192.168.24.241:42222: request&lt;br /&gt;
  -&amp;gt; Request(GET /AppDetails)&lt;br /&gt;
 ::ffff:192.168.24.241:42222: response&lt;br /&gt;
  -&amp;gt; Response(200 OK, application/json, 44b)&lt;br /&gt;
 ::ffff:192.168.24.241:50453: response&lt;br /&gt;
  -&amp;gt; Response(200 OK, application/json, 374b)&lt;br /&gt;
&lt;br /&gt;
The DTLS connection between the app and the gateway, however, does not appear in the mitm log.&lt;br /&gt;
&lt;br /&gt;
=== Replay-Attack ===&lt;br /&gt;
In order to be able to carry out a replay attack, the data traffic between the device on which the IKEA app is running and the IKEA gateway must be recorded. Every time you close the app and open it again, a new transmission must be recorded. This is because this is a new session, so the IKEA Gateway and the App have a new shared secret. Then the SRC and DST in IP and MAC have to be adjusted accordingly. In this particular example, a sequence number is available in the DTLS protocol. This must also be adjusted so that it is preliminary. Since the payload is also included in the UDP checksum, it must be recalculated too. This attack was performed on the TKEA Gateway, where a socket was connected to. In the socket was light plugged in to see what&#039;s happening.&lt;br /&gt;
&lt;br /&gt;
[[File:replay-attack.png]]&lt;br /&gt;
&lt;br /&gt;
As you can see, the attack is unsuccessful because no response is sent from the gateway, which is likely to drop the packets.&lt;br /&gt;
&lt;br /&gt;
This may be because DTLS also uses MAC (message authentication code). The sequence number is used to calculate the MAC value. Unfortunately, this value cannot be recalculated without knowing the encryption.&lt;br /&gt;
&lt;br /&gt;
=== Change Sequence Number ===&lt;br /&gt;
To change the sequence number, we used a workaround in Wireshark. In Wireshark you can select multiple Packets and then copy them as hex dump. &lt;br /&gt;
&lt;br /&gt;
[[File:Wireshark-save-hexdump.png|700px]]&lt;br /&gt;
&lt;br /&gt;
 0000   dc a6 32 7d 1d 37 c0 ee fb 4a 9b b5 08 00 45 00&lt;br /&gt;
 0010   00 69 57 0a 40 00 40 11 47 f6 c0 a8 18 f1 c0 a8&lt;br /&gt;
 0020   01 42 a4 1a 16 34 00 55 ff 2e 17 fe fd 00 01 00&lt;br /&gt;
 0030   00 00 00 00 34 00 40 00 00 00 00 00 00 00 16 21&lt;br /&gt;
 0040   39 8a 8a c5 dd c3 3d 67 ba de a5 5f 0a 10 8c e2&lt;br /&gt;
 0050   75 da ca a1 db ae a2 08 c6 e6 a6 94 32 db d0 cd&lt;br /&gt;
 0060   d1 63 e6 bd 32 db 2f 14 1a a1 08 be e9 ac ff 43&lt;br /&gt;
 0070   48 1b 54 a9 f9 f7 4f&lt;br /&gt;
&lt;br /&gt;
After you have copied the packet you can put it into a texteditor and edit the part of the packet you want. In our case we changed the 00 00 00 00 00 34 in line 0020 and 0030 to the appropriate sequence number. We found out that after each full communication the number raised by four. So, when the last recorded sequence number was 48 the next one is 52 and then 56 and so on. This is the decimal number you have to convert it so hex and change it in the text editor and save it.&lt;br /&gt;
&lt;br /&gt;
In wireshark it is possible to import packets from a textfile with hexdump in it. &lt;br /&gt;
&lt;br /&gt;
[[File:Wireshark-import-hexdump1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Wireshark-import-hexdump2.png]]&lt;br /&gt;
&lt;br /&gt;
After you have imported the hexdump save the file as pcap file.&lt;br /&gt;
&lt;br /&gt;
In order to send the packets, edit the missing fields in the python script.&lt;br /&gt;
&lt;br /&gt;
 #! /usr/bin/python3&lt;br /&gt;
 from scapy.all import *&lt;br /&gt;
 from scapy.utils import rdpcap&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 pkts=rdpcap(&amp;quot;path of the pcap file&amp;quot;)  # reads the pcap file and saves the list in the pkts var&lt;br /&gt;
 &lt;br /&gt;
 # iterates through the list&lt;br /&gt;
 for pkt in pkts:&lt;br /&gt;
      pkt[Ether].src = &amp;quot;sender mac&amp;quot;  # MAC of the sender&lt;br /&gt;
      pkt[Ether].dst= &amp;quot;target mac&amp;quot;  # MAC of the target&lt;br /&gt;
 &lt;br /&gt;
      pkt[IP].src= &amp;quot;sender ip&amp;quot; # IP of the sender&lt;br /&gt;
      pkt[IP].dst = &amp;quot;target ip&amp;quot;  # IP of the target&lt;br /&gt;
 &lt;br /&gt;
      del pkt.chksum # deletes the current checksum in the IP header&lt;br /&gt;
      del pkt[UDP].chksum # deletes the checksum in UDP header&lt;br /&gt;
      pkt = pkt.__class__(bytes(pkt)) # scapy builds the packet new and calculates the missing checksums new&lt;br /&gt;
 &lt;br /&gt;
      sendp(pkt) # sending packet&lt;br /&gt;
      time.sleep(2)&lt;br /&gt;
&lt;br /&gt;
After that the script can be executed.&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=4310</id>
		<title>Install c&#039;t&#039;-Raspion on Raspberry PI</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=4310"/>
		<updated>2020-06-27T11:16:54Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
* Raspberry PI with Raspbian OS&lt;br /&gt;
* Internet connection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
=== Step 1: System Update ===&lt;br /&gt;
&lt;br /&gt;
In the command line interface enter:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Download ===&lt;br /&gt;
Download the latest version of Raspion:&lt;br /&gt;
&lt;br /&gt;
 wget ct.de/s/x5Pm -O raspion.zip &lt;br /&gt;
&lt;br /&gt;
=== Step 3: Installation ===&lt;br /&gt;
Unzip:&lt;br /&gt;
 unzip raspion.zip&lt;br /&gt;
&lt;br /&gt;
Install:&lt;br /&gt;
 cd raspion&lt;br /&gt;
 ./install.sh or bash install.sh&lt;br /&gt;
&lt;br /&gt;
[[File:Install_Raspion.png]]&lt;br /&gt;
&lt;br /&gt;
At the end of the installation there is the wifi name and password of the c&#039;t-Raspion.&lt;br /&gt;
&lt;br /&gt;
=== Launch c&#039;t-Raspion web interface ===&lt;br /&gt;
Atfer connecting to the wifi of the c&#039;t&#039;-Raspion go to http://&amp;lt;ip-address of your Raspberry-PI&amp;gt;:81&lt;br /&gt;
&lt;br /&gt;
[[File:Raspion_webinterface.png]]&lt;br /&gt;
&lt;br /&gt;
== Services of the c&#039;t-Raspion ==&lt;br /&gt;
&lt;br /&gt;
=== Pi-hole ===&lt;br /&gt;
Pi-hole shows DNS-Requests. They can also be blocked.&lt;br /&gt;
&lt;br /&gt;
[[File:Pi-hole.png]]&lt;br /&gt;
&lt;br /&gt;
=== ntopng ===&lt;br /&gt;
They include the&lt;br /&gt;
involved communication partners, the network protocol and information on duration and volume. ntopng does not show the contents of the packages. But it analyses the flows and provides information about which application is communicating, such as Skype, BitTorrent etc., and provides statistics.&lt;br /&gt;
&lt;br /&gt;
=== Wireshark ===&lt;br /&gt;
Wireshark offers a deeper analysis of the network traffic as ntopng.  The program allows recording and analyzing network traffic down to the last bit and can be operated via browser as a special feature of c&#039;t-Raspion. The recorded network traffic will be saved in pcap-files.&lt;br /&gt;
 &lt;br /&gt;
=== mitmproxy ===&lt;br /&gt;
The mitm-Proxy can loop into the communication between the local and remote devices by the c&#039;t-Raspion redirecting all access from the internal network on TCP ports 80 and 443 to the mitm-Proxy. It takes the redirected accesses to port&lt;br /&gt;
8080 towards. The redirection is handled by firewall rules, which  can be activated and deactivated as required by clicking in the c&#039;t-Raspion web interface.&lt;br /&gt;
&lt;br /&gt;
== Ikea Tradfri Setup Sniff ==&lt;br /&gt;
For testing purposes an iphone was cleaned as far as possible. All uninstalable services were erased and synchronization plans were deactivated.&lt;br /&gt;
However iphones are not that good for this kind of tests because after all cleaning there were still some connections to apple servers.&lt;br /&gt;
&lt;br /&gt;
To use pihole for capturing the dns queries of the Tradfri Gateway itself you may use an USB networkadapter or an external router as wifi bride. Otherwise you cannot use the Tradfri Gateway due to the lack of connection possibilities. As an workaround outside the Raspion software package classic arpspoofing was used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Preliminary overview IP addressess:&lt;br /&gt;
&lt;br /&gt;
[[File:ip-config.png|900px]]&lt;br /&gt;
&lt;br /&gt;
Immediately after power on the app is sending dns requests to get ip addresses for fw.ota.homesmart.ikea.net. In the dns answer the ip&#039;s to d262cmbxmzphsu.cloudfront.net were included which is an address belonging to amazons aws.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap1.png|700px]]&lt;br /&gt;
[[File:wireshark-cap2.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Also an http get request can be found:&lt;br /&gt;
[[File:wireshark-cap-http.png|600px]]&lt;br /&gt;
&lt;br /&gt;
The data from fw.ota.homesmart.ikea.net/feed/version_info.json are not that spectacular. As the name implies it only consists of version information.&lt;br /&gt;
&lt;br /&gt;
As soon as the Ikea Smart Home App starts the setup it tries to find a Tradfri Gateway with mDNS queries.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-mDNS.png|550px]]&lt;br /&gt;
&lt;br /&gt;
The mDNS queries are not forwarded through our pihole setup so this technique finding the Tradfri Gateway fails. The app itself provides another way to find the Tradfri Gateway by entering the ip address directly. After submitting the input the app finds the gateway and asks you to scan the QR code on the bottom side of the divce or to enter the security code which can be found near the QR code.&lt;br /&gt;
&lt;br /&gt;
The QR code contains the security code which is used as the pre shared key of the DTLS connection. As soon as the app gets the security code the app and the gateway are initiating the DTLS connection. All applicationdata is send over this encrypted connection.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls.png|550px]]&lt;br /&gt;
&lt;br /&gt;
Same implies to connections of additional smart home devices: All data is sent over the encrypted connection.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls-snap.png|550px]]&lt;br /&gt;
&lt;br /&gt;
As far as the initial setup goes there are only a few connections to the internet. This connections are all from app to some aws cloud addresses. It seems this is relating to the setup of a new device:&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-aws.png|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Data Transmission when using TRADFRI ==&lt;br /&gt;
&lt;br /&gt;
The IKEA TRADFRI Gateway was connected via LAN cable while the mobile phone running the IKEA app was connected wirelessly to the same network.&lt;br /&gt;
Overview of IP addresses used:&lt;br /&gt;
&lt;br /&gt;
[[File:ip_overview_muzik.png|550px]]&lt;br /&gt;
&lt;br /&gt;
Wireshark was used to record the traffic (using arpspoof because the IKEA TRADFRI Gateway requires a LAN connection so it is not possible to just monitor the Raspion WiFi) which was then filtered.&lt;br /&gt;
&lt;br /&gt;
It turns out that TRADFRI is rather well-behaved when it comes to sending data.&lt;br /&gt;
&lt;br /&gt;
For the most part it uses encrypted (DTLS) communication internally between the Gateway and the mobile phone. To initially find the Gateway after opening the mobile app, an MDNS request is sent out via multicast (224.x.x.x).&lt;br /&gt;
&lt;br /&gt;
However, 2 external connections or destinations could also be found:&lt;br /&gt;
&lt;br /&gt;
* IP address 13.227.156.82 / privacypolicy.config.homesmart.ikea.net (as the url indicates, this has the current policy one has to agree to before using the app)&lt;br /&gt;
* IP address 13.227.156.50 / supportdetails.config.homesmart.ikea.net (this is where the secure certificates are located, apparently).&lt;br /&gt;
&lt;br /&gt;
=== Wireshark caps ===&lt;br /&gt;
privacypolicy.config.homesmart.ikea.net Client Hello:&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-privacy policy-clientHello.png|700px]]&lt;br /&gt;
&lt;br /&gt;
supportdetails.config.homesmart.ikea.net ServerHello:&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-supportdetails-serverHello.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== Certificate Information ===&lt;br /&gt;
The Server Hello contains the information regarding the .cer and .crl:&lt;br /&gt;
 http://ocsp.rootca1.amazontrust.com&lt;br /&gt;
 http://crt.rootca1.amazontrust.com/rootca1.cer&lt;br /&gt;
 http://crl.rootca1.amazontrust.com/rootca1.crl&lt;br /&gt;
Starfield Technologies, Inc.; Starfield Services Root Certificate Authority&lt;br /&gt;
&lt;br /&gt;
Also:&lt;br /&gt;
 http://crl.sca1b.amazontrust.com/sca1b.crl&lt;br /&gt;
 http://ocsp.sca1b.amazontrust.com&lt;br /&gt;
 http://crt.sca1b.amazontrust.com/sca1b.crt &lt;br /&gt;
&lt;br /&gt;
That&#039;s pretty much it. We couldn&#039;t find any unwanted connections.&lt;br /&gt;
&lt;br /&gt;
The app also checks for updates for the used devices, this is also indicated in the app when it happens, so this is very transparent. It is indicated in the app when an update is happening or when the app is checking for new updates as can be seen in the screenshot below. If a device happens to be unavailable, e.g. because it is currently disconnected/turned off, then the app does not report back the current version but instead says the device is unreachable (&#039;Nicht erreichbar&#039;)&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-tradfri-update.png|360px]]&lt;br /&gt;
&lt;br /&gt;
=== Turning devices on/off ===&lt;br /&gt;
When devices are turned on or off, the individual packet sequences are made up of packets that are the same in size but with some devices there are more packets sent when turning on than off. Let me illustrate this by comparing the on/off sequences of the light bulb (pretty much the same for on/off, although of course different packet content):&lt;br /&gt;
&lt;br /&gt;
Light Bulb ON&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-gluehbirne_ein.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Light Bulb OFF&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-gluehbirne_aus.png|700px]]&lt;br /&gt;
&lt;br /&gt;
As opposed to the smart plug where the on sequence is longer than the off sequence:&lt;br /&gt;
&lt;br /&gt;
Smart Plug ON&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-strom ein.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Smart Plug OFF&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-strom aus.png|700px]]&lt;br /&gt;
&lt;br /&gt;
(these were done using arpspoof on 192.168.0.106, 192.168.0.101 is the Internet Gateway, 192.168.0.104 is the TRADFRI Gateway, commands were sent via 192.168.0.103 - so keep in mind that you see duplicates of each packet in the Wireshark caps because they include the sniff and forward to the actual target device)&lt;br /&gt;
&lt;br /&gt;
== Interrupt Communication ==&lt;br /&gt;
This experiment will show if it is possible to interrupt or sniff the communication between the IKEA and the IKEA gateway. This is not possible with only a packet sniffer like Wireshark, because the communication is encrypted with DTLS. Two attacks were performed, a mitm proxy attack and a replay attack. For the mitm attack the mitm proxy from the c’t Raspion was used and for the replay attack a scapy script.  The network structure is as follows:&lt;br /&gt;
&lt;br /&gt;
IP overview:&lt;br /&gt;
&lt;br /&gt;
[[File:mitm_findings.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== Structure ===&lt;br /&gt;
[[File:mitm-top.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Android can be operated as a virtual machine, or you can also use a smart phone that has the IKEA Smarthome app installed. If it is operated as a virtual machine, make sure that bridge mode is used, since the VM will then have its own IP. This has the advantage that you only have to analyze the traffic generated by Android and not that of the host system.&lt;br /&gt;
&lt;br /&gt;
In order to be able to use the mitm, certificates must be added to the key store on the android os. This can be done by opening the website mitm.it in the browser of android. If you are in the right network, you will see the following window.&lt;br /&gt;
&lt;br /&gt;
[[File:mitmproxy-cert.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Here you choose the right operating system and download the certificates.&lt;br /&gt;
&lt;br /&gt;
The official documentation can be found here[https://docs.mitmproxy.org/stable/concepts-certificates/#quick-setup].&lt;br /&gt;
&lt;br /&gt;
=== MitM Proxy ===&lt;br /&gt;
When you start the app in Wireshark you can see that the handshake for the DTLS connection is being carried out.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-dtls.png]]&lt;br /&gt;
&lt;br /&gt;
You can also observe that there are several connections to different servers outside the network.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-tls.png]]&lt;br /&gt;
&lt;br /&gt;
The following messages can be decrypted.&lt;br /&gt;
&lt;br /&gt;
[[File:mitm-sniff.png]]&lt;br /&gt;
&lt;br /&gt;
Both include a JSON-file.&lt;br /&gt;
&lt;br /&gt;
[[File:Json-file-mitm.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* In the debug log, you can observe that there are additional TLS connections, but the mitm proxy couldn’t decrypt these.&lt;br /&gt;
&lt;br /&gt;
 192.168.24.241:59332: Client Handshake failed. The client may not trust the proxy&#039;s certificate for data.logentries.com.&lt;br /&gt;
 192.168.24.241:59332: ClientHandshakeException(&#039;Cannot establish TLS with client (sni: data.logentries.com): TlsException(&amp;quot;(-1, \&#039;Unexpected EOF\&#039;)&amp;quot;)&#039;)&lt;br /&gt;
 ::ffff:192.168.24.241:58971: serverdisconnect&lt;br /&gt;
  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
 192.168.24.241:59332: clientdisconnect&lt;br /&gt;
 ::ffff:192.168.24.241:40204: serverdisconnect&lt;br /&gt;
  -&amp;gt; (&#039;99.86.243.50&#039;, 443)&lt;br /&gt;
 192.168.24.241:58971: clientdisconnect&lt;br /&gt;
 192.168.24.241:40204: clientdisconnect&lt;br /&gt;
 192.168.24.241:41657: clientconnect&lt;br /&gt;
 ::ffff:192.168.24.241:41657: Establish TLS with client&lt;br /&gt;
 192.168.24.241:50453: clientconnect&lt;br /&gt;
 ::ffff:192.168.24.241:50453: serverconnect&lt;br /&gt;
  -&amp;gt; (&#039;99.86.243.36&#039;, 443)&lt;br /&gt;
 192.168.24.241:42222: clientconnect&lt;br /&gt;
 ::ffff:192.168.24.241:42222: serverconnect&lt;br /&gt;
  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
 ::ffff:192.168.24.241:42222: Establish TLS with server&lt;br /&gt;
 ::ffff:192.168.24.241:50453: Establish TLS with server&lt;br /&gt;
 ::ffff:192.168.24.241:42222: ALPN selected by server: -&lt;br /&gt;
 ::ffff:192.168.24.241:42222: Establish TLS with client&lt;br /&gt;
 ::ffff:192.168.24.241:50453: ALPN selected by server: -&lt;br /&gt;
 ::ffff:192.168.24.241:50453: Establish TLS with client&lt;br /&gt;
 ::ffff:192.168.24.241:42222: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
 ::ffff:192.168.24.241:50453: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
 ::ffff:192.168.24.241:50453: request&lt;br /&gt;
  -&amp;gt; Request(GET /US/en/getPolicyUpdate/?deviceType=android)&lt;br /&gt;
 ::ffff:192.168.24.241:42222: request&lt;br /&gt;
  -&amp;gt; Request(GET /AppDetails)&lt;br /&gt;
 ::ffff:192.168.24.241:42222: response&lt;br /&gt;
  -&amp;gt; Response(200 OK, application/json, 44b)&lt;br /&gt;
 ::ffff:192.168.24.241:50453: response&lt;br /&gt;
  -&amp;gt; Response(200 OK, application/json, 374b)&lt;br /&gt;
&lt;br /&gt;
The DTLS connection between the app and the gateway, however, does not appear in the mitm log.&lt;br /&gt;
&lt;br /&gt;
=== Replay-Attack ===&lt;br /&gt;
In order to be able to carry out a replay attack, the data traffic between the device on which the IKEA app is running and the IKEA gateway must be recorded. Then the SRC and DST in IP and MAC have to be adjusted accordingly. In this particular example, a sequence number is available in the DTLS protocol. This must also be adjusted so that it is preliminary. Since the payload is also included in the UDP checksum, it must be recalculated too. This attack was performed on the TKEA Gateway, where a socket was connected to. In the socket was light plugged in to see what&#039;s happening.&lt;br /&gt;
&lt;br /&gt;
[[File:replay-attack.png]]&lt;br /&gt;
&lt;br /&gt;
As you can see, the attack is unsuccessful because no response is sent from the gateway, which is likely to drop the packets.&lt;br /&gt;
&lt;br /&gt;
This may be because DTLS also uses MAC (message authentication code). The sequence number is used to calculate the MAC value. Unfortunately, this value cannot be recalculated without knowing the encryption.&lt;br /&gt;
&lt;br /&gt;
=== Change Sequence Number ===&lt;br /&gt;
To change the sequence number, we used a workaround in Wireshark. In Wireshark you can select multiple Packets and then copy them as hex dump. &lt;br /&gt;
&lt;br /&gt;
[[File:Wireshark-save-hexdump.png|700px]]&lt;br /&gt;
&lt;br /&gt;
 0000   dc a6 32 7d 1d 37 c0 ee fb 4a 9b b5 08 00 45 00&lt;br /&gt;
 0010   00 69 57 0a 40 00 40 11 47 f6 c0 a8 18 f1 c0 a8&lt;br /&gt;
 0020   01 42 a4 1a 16 34 00 55 ff 2e 17 fe fd 00 01 00&lt;br /&gt;
 0030   00 00 00 00 34 00 40 00 00 00 00 00 00 00 16 21&lt;br /&gt;
 0040   39 8a 8a c5 dd c3 3d 67 ba de a5 5f 0a 10 8c e2&lt;br /&gt;
 0050   75 da ca a1 db ae a2 08 c6 e6 a6 94 32 db d0 cd&lt;br /&gt;
 0060   d1 63 e6 bd 32 db 2f 14 1a a1 08 be e9 ac ff 43&lt;br /&gt;
 0070   48 1b 54 a9 f9 f7 4f&lt;br /&gt;
&lt;br /&gt;
After you have copied the packet you can put it into a texteditor and edit the part of the packet you want. In our case we changed the 00 00 00 00 00 34 in line 0020 and 0030 to the appropriate sequence number. We found out that after each full communication the number raised by four. So, when the last recorded sequence number was 48 the next one is 52 and then 56 and so on. This is the decimal number you have to convert it so hex and change it in the text editor and save it.&lt;br /&gt;
&lt;br /&gt;
In wireshark it is possible to import packets from a textfile with hexdump in it. &lt;br /&gt;
&lt;br /&gt;
[[File:Wireshark-import-hexdump1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Wireshark-import-hexdump2.png]]&lt;br /&gt;
&lt;br /&gt;
After you have imported the hexdump save the file as pcap file.&lt;br /&gt;
&lt;br /&gt;
In order to send the packets, edit the missing fields in the python script.&lt;br /&gt;
&lt;br /&gt;
 #! /usr/bin/python3&lt;br /&gt;
 from scapy.all import *&lt;br /&gt;
 from scapy.utils import rdpcap&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 pkts=rdpcap(&amp;quot;path of the pcap file&amp;quot;)  # reads the pcap file and saves the list in the pkts var&lt;br /&gt;
 &lt;br /&gt;
 # iterates through the list&lt;br /&gt;
 for pkt in pkts:&lt;br /&gt;
      pkt[Ether].src = &amp;quot;sender mac&amp;quot;  # MAC of the sender&lt;br /&gt;
      pkt[Ether].dst= &amp;quot;target mac&amp;quot;  # MAC of the target&lt;br /&gt;
 &lt;br /&gt;
      pkt[IP].src= &amp;quot;sender ip&amp;quot; # IP of the sender&lt;br /&gt;
      pkt[IP].dst = &amp;quot;target ip&amp;quot;  # IP of the target&lt;br /&gt;
 &lt;br /&gt;
      del pkt.chksum # deletes the current checksum in the IP header&lt;br /&gt;
      del pkt[UDP].chksum # deletes the checksum in UDP header&lt;br /&gt;
      pkt = pkt.__class__(bytes(pkt)) # scapy builds the packet new and calculates the missing checksums new&lt;br /&gt;
 &lt;br /&gt;
      sendp(pkt) # sending packet&lt;br /&gt;
      time.sleep(2)&lt;br /&gt;
&lt;br /&gt;
After that the script can be executed.&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-import-hexdump2.png&amp;diff=4309</id>
		<title>File:Wireshark-import-hexdump2.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-import-hexdump2.png&amp;diff=4309"/>
		<updated>2020-06-27T11:11:46Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-import-hexdump1.png&amp;diff=4308</id>
		<title>File:Wireshark-import-hexdump1.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-import-hexdump1.png&amp;diff=4308"/>
		<updated>2020-06-27T11:10:47Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-save-hexdump.png&amp;diff=4307</id>
		<title>File:Wireshark-save-hexdump.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-save-hexdump.png&amp;diff=4307"/>
		<updated>2020-06-27T11:08:55Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=4306</id>
		<title>Install c&#039;t&#039;-Raspion on Raspberry PI</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=4306"/>
		<updated>2020-06-27T10:03:02Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
* Raspberry PI with Raspbian OS&lt;br /&gt;
* Internet connection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
=== Step 1: System Update ===&lt;br /&gt;
&lt;br /&gt;
In the command line interface enter:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Download ===&lt;br /&gt;
Download the latest version of Raspion:&lt;br /&gt;
&lt;br /&gt;
 wget ct.de/s/x5Pm -O raspion.zip &lt;br /&gt;
&lt;br /&gt;
=== Step 3: Installation ===&lt;br /&gt;
Unzip:&lt;br /&gt;
 unzip raspion.zip&lt;br /&gt;
&lt;br /&gt;
Install:&lt;br /&gt;
 cd raspion&lt;br /&gt;
 ./install.sh or bash install.sh&lt;br /&gt;
&lt;br /&gt;
[[File:Install_Raspion.png]]&lt;br /&gt;
&lt;br /&gt;
At the end of the installation there is the wifi name and password of the c&#039;t-Raspion.&lt;br /&gt;
&lt;br /&gt;
=== Launch c&#039;t-Raspion web interface ===&lt;br /&gt;
Atfer connecting to the wifi of the c&#039;t&#039;-Raspion go to http://&amp;lt;ip-address of your Raspberry-PI&amp;gt;:81&lt;br /&gt;
&lt;br /&gt;
[[File:Raspion_webinterface.png]]&lt;br /&gt;
&lt;br /&gt;
== Services of the c&#039;t-Raspion ==&lt;br /&gt;
&lt;br /&gt;
=== Pi-hole ===&lt;br /&gt;
Pi-hole shows DNS-Requests. They can also be blocked.&lt;br /&gt;
&lt;br /&gt;
[[File:Pi-hole.png]]&lt;br /&gt;
&lt;br /&gt;
=== ntopng ===&lt;br /&gt;
They include the&lt;br /&gt;
involved communication partners, the network protocol and information on duration and volume. ntopng does not show the contents of the packages. But it analyses the flows and provides information about which application is communicating, such as Skype, BitTorrent etc., and provides statistics.&lt;br /&gt;
&lt;br /&gt;
=== Wireshark ===&lt;br /&gt;
Wireshark offers a deeper analysis of the network traffic as ntopng.  The program allows recording and analyzing network traffic down to the last bit and can be operated via browser as a special feature of c&#039;t-Raspion. The recorded network traffic will be saved in pcap-files.&lt;br /&gt;
 &lt;br /&gt;
=== mitmproxy ===&lt;br /&gt;
The mitm-Proxy can loop into the communication between the local and remote devices by the c&#039;t-Raspion redirecting all access from the internal network on TCP ports 80 and 443 to the mitm-Proxy. It takes the redirected accesses to port&lt;br /&gt;
8080 towards. The redirection is handled by firewall rules, which  can be activated and deactivated as required by clicking in the c&#039;t-Raspion web interface.&lt;br /&gt;
&lt;br /&gt;
== Ikea Tradfri Setup Sniff ==&lt;br /&gt;
For testing purposes an iphone was cleaned as far as possible. All uninstalable services were erased and synchronization plans were deactivated.&lt;br /&gt;
However iphones are not that good for this kind of tests because after all cleaning there were still some connections to apple servers.&lt;br /&gt;
&lt;br /&gt;
To use pihole for capturing the dns queries of the Tradfri Gateway itself you may use an USB networkadapter or an external router as wifi bride. Otherwise you cannot use the Tradfri Gateway due to the lack of connection possibilities. As an workaround outside the Raspion software package classic arpspoofing was used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Preliminary overview IP addressess:&lt;br /&gt;
&lt;br /&gt;
[[File:ip-config.png|900px]]&lt;br /&gt;
&lt;br /&gt;
Immediately after power on the app is sending dns requests to get ip addresses for fw.ota.homesmart.ikea.net. In the dns answer the ip&#039;s to d262cmbxmzphsu.cloudfront.net were included which is an address belonging to amazons aws.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap1.png|700px]]&lt;br /&gt;
[[File:wireshark-cap2.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Also an http get request can be found:&lt;br /&gt;
[[File:wireshark-cap-http.png|600px]]&lt;br /&gt;
&lt;br /&gt;
The data from fw.ota.homesmart.ikea.net/feed/version_info.json are not that spectacular. As the name implies it only consists of version information.&lt;br /&gt;
&lt;br /&gt;
As soon as the Ikea Smart Home App starts the setup it tries to find a Tradfri Gateway with mDNS queries.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-mDNS.png|550px]]&lt;br /&gt;
&lt;br /&gt;
The mDNS queries are not forwarded through our pihole setup so this technique finding the Tradfri Gateway fails. The app itself provides another way to find the Tradfri Gateway by entering the ip address directly. After submitting the input the app finds the gateway and asks you to scan the QR code on the bottom side of the divce or to enter the security code which can be found near the QR code.&lt;br /&gt;
&lt;br /&gt;
The QR code contains the security code which is used as the pre shared key of the DTLS connection. As soon as the app gets the security code the app and the gateway are initiating the DTLS connection. All applicationdata is send over this encrypted connection.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls.png|550px]]&lt;br /&gt;
&lt;br /&gt;
Same implies to connections of additional smart home devices: All data is sent over the encrypted connection.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls-snap.png|550px]]&lt;br /&gt;
&lt;br /&gt;
As far as the initial setup goes there are only a few connections to the internet. This connections are all from app to some aws cloud addresses. It seems this is relating to the setup of a new device:&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-aws.png|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Data Transmission when using TRADFRI ==&lt;br /&gt;
&lt;br /&gt;
The IKEA TRADFRI Gateway was connected via LAN cable while the mobile phone running the IKEA app was connected wirelessly to the same network.&lt;br /&gt;
Overview of IP addresses used:&lt;br /&gt;
&lt;br /&gt;
[[File:ip_overview_muzik.png|550px]]&lt;br /&gt;
&lt;br /&gt;
Wireshark was used to record the traffic (using arpspoof because the IKEA TRADFRI Gateway requires a LAN connection so it is not possible to just monitor the Raspion WiFi) which was then filtered.&lt;br /&gt;
&lt;br /&gt;
It turns out that TRADFRI is rather well-behaved when it comes to sending data.&lt;br /&gt;
&lt;br /&gt;
For the most part it uses encrypted (DTLS) communication internally between the Gateway and the mobile phone. To initially find the Gateway after opening the mobile app, an MDNS request is sent out via multicast (224.x.x.x).&lt;br /&gt;
&lt;br /&gt;
However, 2 external connections or destinations could also be found:&lt;br /&gt;
&lt;br /&gt;
* IP address 13.227.156.82 / privacypolicy.config.homesmart.ikea.net (as the url indicates, this has the current policy one has to agree to before using the app)&lt;br /&gt;
* IP address 13.227.156.50 / supportdetails.config.homesmart.ikea.net (this is where the secure certificates are located, apparently).&lt;br /&gt;
&lt;br /&gt;
=== Wireshark caps ===&lt;br /&gt;
privacypolicy.config.homesmart.ikea.net Client Hello:&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-privacy policy-clientHello.png|700px]]&lt;br /&gt;
&lt;br /&gt;
supportdetails.config.homesmart.ikea.net ServerHello:&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-supportdetails-serverHello.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== Certificate Information ===&lt;br /&gt;
The Server Hello contains the information regarding the .cer and .crl:&lt;br /&gt;
 http://ocsp.rootca1.amazontrust.com&lt;br /&gt;
 http://crt.rootca1.amazontrust.com/rootca1.cer&lt;br /&gt;
 http://crl.rootca1.amazontrust.com/rootca1.crl&lt;br /&gt;
Starfield Technologies, Inc.; Starfield Services Root Certificate Authority&lt;br /&gt;
&lt;br /&gt;
Also:&lt;br /&gt;
 http://crl.sca1b.amazontrust.com/sca1b.crl&lt;br /&gt;
 http://ocsp.sca1b.amazontrust.com&lt;br /&gt;
 http://crt.sca1b.amazontrust.com/sca1b.crt &lt;br /&gt;
&lt;br /&gt;
That&#039;s pretty much it. We couldn&#039;t find any unwanted connections.&lt;br /&gt;
&lt;br /&gt;
The app also checks for updates for the used devices, this is also indicated in the app when it happens, so this is very transparent. It is indicated in the app when an update is happening or when the app is checking for new updates as can be seen in the screenshot below. If a device happens to be unavailable, e.g. because it is currently disconnected/turned off, then the app does not report back the current version but instead says the device is unreachable (&#039;Nicht erreichbar&#039;)&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-tradfri-update.png|360px]]&lt;br /&gt;
&lt;br /&gt;
=== Turning devices on/off ===&lt;br /&gt;
When devices are turned on or off, the individual packet sequences are made up of packets that are the same in size but with some devices there are more packets sent when turning on than off. Let me illustrate this by comparing the on/off sequences of the light bulb (pretty much the same for on/off, although of course different packet content):&lt;br /&gt;
&lt;br /&gt;
Light Bulb ON&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-gluehbirne_ein.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Light Bulb OFF&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-gluehbirne_aus.png|700px]]&lt;br /&gt;
&lt;br /&gt;
As opposed to the smart plug where the on sequence is longer than the off sequence:&lt;br /&gt;
&lt;br /&gt;
Smart Plug ON&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-strom ein.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Smart Plug OFF&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Ikea-strom aus.png|700px]]&lt;br /&gt;
&lt;br /&gt;
(these were done using arpspoof on 192.168.0.106, 192.168.0.101 is the Internet Gateway, 192.168.0.104 is the TRADFRI Gateway, commands were sent via 192.168.0.103 - so keep in mind that you see duplicates of each packet in the Wireshark caps because they include the sniff and forward to the actual target device)&lt;br /&gt;
&lt;br /&gt;
== Interrupt Communication ==&lt;br /&gt;
This experiment will show if it is possible to interrupt or sniff the communication between the IKEA and the IKEA gateway. This is not possible with only a packet sniffer like Wireshark, because the communication is encrypted with DTLS. Two attacks were performed, a mitm proxy attack and a replay attack. For the mitm attack the mitm proxy from the c’t Raspion was used and for the replay attack a scapy script.  The network structure is as follows:&lt;br /&gt;
&lt;br /&gt;
IP overview:&lt;br /&gt;
&lt;br /&gt;
[[File:mitm_findings.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== Structure ===&lt;br /&gt;
[[File:mitm-top.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Android can be operated as a virtual machine, or you can also use a smart phone that has the IKEA Smarthome app installed. If it is operated as a virtual machine, make sure that bridge mode is used, since the VM will then have its own IP. This has the advantage that you only have to analyze the traffic generated by Android and not that of the host system.&lt;br /&gt;
&lt;br /&gt;
In order to be able to use the mitm, certificates must be added to the key store on the android os. This can be done by opening the website mitm.it in the browser of android. If you are in the right network, you will see the following window.&lt;br /&gt;
&lt;br /&gt;
[[File:mitmproxy-cert.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Here you choose the right operating system and download the certificates.&lt;br /&gt;
&lt;br /&gt;
The official documentation can be found here[https://docs.mitmproxy.org/stable/concepts-certificates/#quick-setup].&lt;br /&gt;
&lt;br /&gt;
=== MitM Proxy ===&lt;br /&gt;
When you start the app in Wireshark you can see that the handshake for the DTLS connection is being carried out.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-dtls.png]]&lt;br /&gt;
&lt;br /&gt;
You can also observe that there are several connections to different servers outside the network.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-tls.png]]&lt;br /&gt;
&lt;br /&gt;
The following messages can be decrypted.&lt;br /&gt;
&lt;br /&gt;
[[File:mitm-sniff.png]]&lt;br /&gt;
&lt;br /&gt;
Both include a JSON-file.&lt;br /&gt;
&lt;br /&gt;
[[File:Json-file-mitm.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* In the debug log, you can observe that there are additional TLS connections, but the mitm proxy couldn’t decrypt these.&lt;br /&gt;
&lt;br /&gt;
[[File:Debug-log-mitm.jpg]]&lt;br /&gt;
&lt;br /&gt;
The DTLS connection between the app and the gateway, however, does not appear in the mitm log.&lt;br /&gt;
&lt;br /&gt;
=== Replay-Attack ===&lt;br /&gt;
In order to be able to carry out a replay attack, the data traffic between the device on which the IKEA app is running and the IKEA gateway must be recorded. Then the SRC and DST in IP and MAC have to be adjusted accordingly. In this particular example, a sequence number is available in the DTLS protocol. This must also be adjusted so that it is preliminary. Since the payload is also included in the UDP checksum, it must be recalculated too. This attack was performed on the TKEA Gateway, where a socket was connected to. In the socket was light plugged in to see what&#039;s happening&lt;br /&gt;
&lt;br /&gt;
[[File:replay-attack.png]]&lt;br /&gt;
&lt;br /&gt;
As you can see, the attack is unsuccessful because no response is sent from the gateway, which is likely to drop the packets.&lt;br /&gt;
&lt;br /&gt;
This may be because DTLS also uses MAC (message authentication code). The sequence number is used to calculate the MAC value. Unfortunately, this value cannot be recalculated without knowing the encryption.&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=4142</id>
		<title>Install c&#039;t&#039;-Raspion on Raspberry PI</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=4142"/>
		<updated>2020-06-06T13:26:06Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
* Raspberry PI with Raspbian OS&lt;br /&gt;
* Internet connection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
=== Step 1: System Update ===&lt;br /&gt;
&lt;br /&gt;
In the command line interface enter:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Download ===&lt;br /&gt;
Download the latest version of Raspion:&lt;br /&gt;
&lt;br /&gt;
 wget ct.de/s/x5Pm -O raspion.zip &lt;br /&gt;
&lt;br /&gt;
=== Step 3: Installation ===&lt;br /&gt;
Unzip:&lt;br /&gt;
 unzip raspion.zip&lt;br /&gt;
&lt;br /&gt;
Install:&lt;br /&gt;
 cd raspion&lt;br /&gt;
 ./install.sh or bash install.sh&lt;br /&gt;
&lt;br /&gt;
[[File:Install_Raspion.png]]&lt;br /&gt;
&lt;br /&gt;
At the end of the installation there is the wifi name and password of the c&#039;t-Raspion.&lt;br /&gt;
&lt;br /&gt;
=== Launch c&#039;t-Raspion web interface ===&lt;br /&gt;
Atfer connecting to the wifi of the c&#039;t&#039;-Raspion go to http://&amp;lt;ip-address of your Raspberry-PI&amp;gt;:81&lt;br /&gt;
&lt;br /&gt;
[[File:Raspion_webinterface.png]]&lt;br /&gt;
&lt;br /&gt;
== Services of the c&#039;t-Raspion ==&lt;br /&gt;
&lt;br /&gt;
=== Pi-hole ===&lt;br /&gt;
Pi-hole shows DNS-Requests. They can also be blocked.&lt;br /&gt;
&lt;br /&gt;
=== ntopng ===&lt;br /&gt;
They include the&lt;br /&gt;
involved communication partners, the network protocol and information on duration and volume. ntopng does not show the contents of the packages. But it analyses the flows and provides information about which application is communicating, such as Skype, BitTorrent etc., and provides statistics.&lt;br /&gt;
&lt;br /&gt;
=== Wireshark ===&lt;br /&gt;
Wireshark offers a deeper analysis of the network traffic as ntopng.  The program allows recording and analyzing network traffic down to the last bit and can be operated via browser as a special feature of c&#039;t-Raspion. The recorded network traffic will be saved in pcap-files.&lt;br /&gt;
 &lt;br /&gt;
=== mitmproxy ===&lt;br /&gt;
The mitm-Proxy can loop into the communication between the local and remote devices by the c&#039;t-Raspion redirecting all access from the internal network on TCP ports 80 and 443 to the mitm-Proxy. It takes the redirected accesses to port&lt;br /&gt;
8080 towards. The redirection is handled by firewall rules, which  can be activated and deactivated as required by clicking in the c&#039;t-Raspion web interface.&lt;br /&gt;
&lt;br /&gt;
== Ikea Tradfri Setup Sniff ==&lt;br /&gt;
For testing purposes an iphone was cleaned as far as possible. All uninstalable services were erased and synchronization plans were deactivated.&lt;br /&gt;
However iphones are not that good for this kind of tests because after all cleaning there were still some connections to apple servers.&lt;br /&gt;
&lt;br /&gt;
To use pihole for capturing the dns queries of the Tradfri Gateway itself you may use an USB networkadapter or an external router as wifi bride. Otherwise you cannot use the Tradfri Gateway due to the lack of connection possibilities. As an workaround outside the Raspion software package classic arpspoofing was used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Preliminary overview IP addressess:&lt;br /&gt;
&lt;br /&gt;
[[File:ip-config.png|900px]]&lt;br /&gt;
&lt;br /&gt;
Immediately after power on the app is sending dns requests to get ip addresses for fw.ota.homesmart.ikea.net. In the dns answer the ip&#039;s to d262cmbxmzphsu.cloudfront.net were included which is an address belonging to amazons aws.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap1.png|700px]]&lt;br /&gt;
[[File:wireshark-cap2.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Also an http get request can be found:&lt;br /&gt;
[[File:wireshark-cap-http.png|600px]]&lt;br /&gt;
&lt;br /&gt;
The data from fw.ota.homesmart.ikea.net/feed/version_info.json are not that spectacular. As the name implies it only consists of version information.&lt;br /&gt;
&lt;br /&gt;
As soon as the Ikea Smart Home App starts the setup it tries to find a Tradfri Gateway with mDNS queries.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-mDNS.png|550px]]&lt;br /&gt;
&lt;br /&gt;
The mDNS queries are not forwarded through our pihole setup so this technique finding the Tradfri Gateway fails. The app itself provides another way to find the Tradfri Gateway by entering the ip address directly. After submitting the input the app finds the gateway and asks you to scan the QR code on the bottom side of the divce or to enter the security code which can be found near the QR code.&lt;br /&gt;
&lt;br /&gt;
The QR code contains the security code which is used as the pre shared key of the DTLS connection. As soon as the app gets the security code the app and the gateway are initiating the DTLS connection. All applicationdata is send over this encrypted connection.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls.png|550px]]&lt;br /&gt;
&lt;br /&gt;
Same implies to connections of additional smart home devices: All data is sent over the encrypted connection.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls-snap.png|550px]]&lt;br /&gt;
&lt;br /&gt;
As far as the initial setup goes there are only a few connections to the internet. This connections are all from app to some aws cloud addresses. It seems this is relating to the setup of a new device:&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-aws.png|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Data Transmission when using TRADFRI ==&lt;br /&gt;
&lt;br /&gt;
The IKEA TRADFRI Gateway was connected via LAN cable while the mobile phone running the IKEA app was connected wirelessly to the same network.&lt;br /&gt;
Overview of IP addresses used:&lt;br /&gt;
&lt;br /&gt;
[[File:ip_overview_muzik.png|550px]]&lt;br /&gt;
&lt;br /&gt;
Wireshark was used to record the traffic (using arpspoof because the IKEA TRADFRI Gateway requires a LAN connection so it is not possible to just monitor the Raspion WiFi) which was then filtered.&lt;br /&gt;
&lt;br /&gt;
It turns out that TRADFRI is rather well-behaved when it comes to sending data.&lt;br /&gt;
&lt;br /&gt;
For the most part it uses encrypted (DTLS) communication internally between the Gateway and the mobile phone. To initially find the Gateway after opening the mobile app, an MDNS request is sent out via multicast (224.x.x.x).&lt;br /&gt;
&lt;br /&gt;
However, 2 external connections or destinations could also be found:&lt;br /&gt;
&lt;br /&gt;
* IP address 13.227.156.82 / privacypolicy.config.homesmart.ikea.net (as the url indicates, this has the current policy one has to agree to before using the app)&lt;br /&gt;
* IP address 13.227.156.50 / supportdetails.config.homesmart.ikea.net (this is where the secure certificates are located, apparently).&lt;br /&gt;
&lt;br /&gt;
=== Wireshark caps ===&lt;br /&gt;
privacypolicy.config.homesmart.ikea.net Client Hello:&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-privacy policy-clientHello.png|700px]]&lt;br /&gt;
&lt;br /&gt;
supportdetails.config.homesmart.ikea.net ServerHello:&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-supportdetails-serverHello.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== Certificate Information ===&lt;br /&gt;
The Server Hello contains the information regarding the .cer and .crl:&lt;br /&gt;
 http://ocsp.rootca1.amazontrust.com&lt;br /&gt;
 http://crt.rootca1.amazontrust.com/rootca1.cer&lt;br /&gt;
 http://crl.rootca1.amazontrust.com/rootca1.crl&lt;br /&gt;
Starfield Technologies, Inc.; Starfield Services Root Certificate Authority&lt;br /&gt;
&lt;br /&gt;
Also:&lt;br /&gt;
 http://crl.sca1b.amazontrust.com/sca1b.crl&lt;br /&gt;
 http://ocsp.sca1b.amazontrust.com&lt;br /&gt;
 http://crt.sca1b.amazontrust.com/sca1b.crt &lt;br /&gt;
&lt;br /&gt;
That&#039;s pretty much it. We couldn&#039;t find any unwanted connections.&lt;br /&gt;
&lt;br /&gt;
The app also checks for updates for the used devices, this is also indicated in the app when it happens, so this is very transparent. It is indicated in the app when an update is happening or when the app is checking for new updates as can be seen in the screenshot below. If a device happens to be unavailable, e.g. because it is currently disconnected/turned off, then the app does not report back the current version but instead says the device is unreachable (&#039;Nicht erreichbar&#039;)&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-tradfri-update.png|360px]]&lt;br /&gt;
&lt;br /&gt;
== Interrupt Communication ==&lt;br /&gt;
This experiment will show if it is possible to interrupt or sniff the communication between the IKEA and the IKEA gateway. This is not possible with only a packet sniffer like Wireshark, because the communication is encrypt with DTLS. Two attacks where performed, a mitm proxy attack and a replay attack. For the mitm attack the mitm proxy from the c’t Raspion was used and for the replay attack a scapy script.  The network structure is as follows:&lt;br /&gt;
&lt;br /&gt;
IP overview:&lt;br /&gt;
&lt;br /&gt;
[[File:mitm_findings.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== Structure ===&lt;br /&gt;
[[File:mitm-top.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Android can be operated as a virtual machine, or you can also use a smart phone that has the IKEA Smarthome app installed. If it is operated as a virtual machine, make sure that bridge mode is used, since the VM will then have its own IP. This has the advantage that you only have to analyze the traffic generated by Android and not that of the host system.&lt;br /&gt;
&lt;br /&gt;
In order to be able to use the mitm, certificates must be added to the key store on the android os. This can be done by opening the website mitm.it in the browser of android. If you are in the right network, you will see the following window.&lt;br /&gt;
&lt;br /&gt;
[[File:mitmproxy-cert.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Here you choose the right operating system and download the certificates.&lt;br /&gt;
&lt;br /&gt;
The official documentation can be found here[https://docs.mitmproxy.org/stable/concepts-certificates/#quick-setup].&lt;br /&gt;
&lt;br /&gt;
=== MitM Proxy ===&lt;br /&gt;
When you start the app in Wireshark you can see that the handshake for the DTLS connection is being carried out.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-dtls.png]]&lt;br /&gt;
&lt;br /&gt;
You can also observe that there are several connections to different servers outside the network.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-tls.png]]&lt;br /&gt;
&lt;br /&gt;
The following messages can be decrypted.&lt;br /&gt;
&lt;br /&gt;
[[File:mitm-sniff.png]]&lt;br /&gt;
&lt;br /&gt;
Both include a JSON-file.&lt;br /&gt;
&lt;br /&gt;
[[File:Json-file-mitm.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* In the debug log, you can observer that there are additional TLS connections, but the mitm proxy couldn’t decrypt these.&lt;br /&gt;
&lt;br /&gt;
[[File:Debug-log-mitm.jpg]]&lt;br /&gt;
&lt;br /&gt;
The DTLS connection between the app and the gateway, however, does not appear in the mitm log. &lt;br /&gt;
&lt;br /&gt;
=== Replay-Attack ===&lt;br /&gt;
In order to be able to carry out a replay attack, the data traffic between the device on which the IKEA app is running and the IKEA gateway must be recorded. Then the SRC and DST in IP and MAC have to be adjusted accordingly. In this particular example, a sequence number is available in the DTLS protocol. This must also be adjusted so that it is preliminary. Since the payload is also included in the UDP checksum, it must be recalculated too.&lt;br /&gt;
&lt;br /&gt;
[[File:replay-attack.png]]&lt;br /&gt;
&lt;br /&gt;
As you can see, the attack is unsuccessful because no response is sent from the gateway, which is likely to drop the packets.&lt;br /&gt;
&lt;br /&gt;
This may be because DTLS also uses MAC (message authentication code). The sequence number is used to calculate the MAC value. Unfortunately, this value cannot be recalculated without knowing the encryption.&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Json-file-mitm.jpg&amp;diff=4141</id>
		<title>File:Json-file-mitm.jpg</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Json-file-mitm.jpg&amp;diff=4141"/>
		<updated>2020-06-06T13:24:56Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Debug-log-mitm.jpg&amp;diff=4140</id>
		<title>File:Debug-log-mitm.jpg</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Debug-log-mitm.jpg&amp;diff=4140"/>
		<updated>2020-06-06T13:23:55Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=4139</id>
		<title>Install c&#039;t&#039;-Raspion on Raspberry PI</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=4139"/>
		<updated>2020-06-06T12:47:55Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
* Raspberry PI with Raspbian OS&lt;br /&gt;
* Internet connection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
=== Step 1: System Update ===&lt;br /&gt;
&lt;br /&gt;
In the command line interface enter:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Download ===&lt;br /&gt;
Download the latest version of Raspion:&lt;br /&gt;
&lt;br /&gt;
 wget ct.de/s/x5Pm -O raspion.zip &lt;br /&gt;
&lt;br /&gt;
=== Step 3: Installation ===&lt;br /&gt;
Unzip:&lt;br /&gt;
 unzip raspion.zip&lt;br /&gt;
&lt;br /&gt;
Install:&lt;br /&gt;
 cd raspion&lt;br /&gt;
 ./install.sh or bash install.sh&lt;br /&gt;
&lt;br /&gt;
[[File:Install_Raspion.png]]&lt;br /&gt;
&lt;br /&gt;
At the end of the installation there is the wifi name and password of the c&#039;t-Raspion.&lt;br /&gt;
&lt;br /&gt;
=== Launch c&#039;t-Raspion web interface ===&lt;br /&gt;
Atfer connecting to the wifi of the c&#039;t&#039;-Raspion go to http://&amp;lt;ip-address of your Raspberry-PI&amp;gt;:81&lt;br /&gt;
&lt;br /&gt;
[[File:Raspion_webinterface.png]]&lt;br /&gt;
&lt;br /&gt;
== Services of the c&#039;t-Raspion ==&lt;br /&gt;
&lt;br /&gt;
=== Pi-hole ===&lt;br /&gt;
Pi-hole shows DNS-Requests. They can also be blocked.&lt;br /&gt;
&lt;br /&gt;
=== ntopng ===&lt;br /&gt;
They include the&lt;br /&gt;
involved communication partners, the network protocol and information on duration and volume. ntopng does not show the contents of the packages. But it analyses the flows and provides information about which application is communicating, such as Skype, BitTorrent etc., and provides statistics.&lt;br /&gt;
&lt;br /&gt;
=== Wireshark ===&lt;br /&gt;
Wireshark offers a deeper analysis of the network traffic as ntopng.  The program allows recording and analyzing network traffic down to the last bit and can be operated via browser as a special feature of c&#039;t-Raspion. The recorded network traffic will be saved in pcap-files.&lt;br /&gt;
 &lt;br /&gt;
=== mitmproxy ===&lt;br /&gt;
The mitm-Proxy can loop into the communication between the local and remote devices by the c&#039;t-Raspion redirecting all access from the internal network on TCP ports 80 and 443 to the mitm-Proxy. It takes the redirected accesses to port&lt;br /&gt;
8080 towards. The redirection is handled by firewall rules, which  can be activated and deactivated as required by clicking in the c&#039;t-Raspion web interface.&lt;br /&gt;
&lt;br /&gt;
== Ikea Tradfri Setup Sniff ==&lt;br /&gt;
For testing purposes an iphone was cleaned as far as possible. All uninstalable services were erased and synchronization plans were deactivated.&lt;br /&gt;
However iphones are not that good for this kind of tests because after all cleaning there were still some connections to apple servers.&lt;br /&gt;
&lt;br /&gt;
To use pihole for capturing the dns queries of the Tradfri Gateway itself you may use an USB networkadapter or an external router as wifi bride. Otherwise you cannot use the Tradfri Gateway due to the lack of connection possibilities. As an workaround outside the Raspion software package classic arpspoofing was used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Preliminary overview IP addressess:&lt;br /&gt;
&lt;br /&gt;
[[File:ip-config.png|900px]]&lt;br /&gt;
&lt;br /&gt;
Immediately after power on the app is sending dns requests to get ip addresses for fw.ota.homesmart.ikea.net. In the dns answer the ip&#039;s to d262cmbxmzphsu.cloudfront.net were included which is an address belonging to amazons aws.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap1.png|700px]]&lt;br /&gt;
[[File:wireshark-cap2.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Also an http get request can be found:&lt;br /&gt;
[[File:wireshark-cap-http.png|600px]]&lt;br /&gt;
&lt;br /&gt;
The data from fw.ota.homesmart.ikea.net/feed/version_info.json are not that spectacular. As the name implies it only consists of version information.&lt;br /&gt;
&lt;br /&gt;
As soon as the Ikea Smart Home App starts the setup it tries to find a Tradfri Gateway with mDNS queries.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-mDNS.png|550px]]&lt;br /&gt;
&lt;br /&gt;
The mDNS queries are not forwarded through our pihole setup so this technique finding the Tradfri Gateway fails. The app itself provides another way to find the Tradfri Gateway by entering the ip address directly. After submitting the input the app finds the gateway and asks you to scan the QR code on the bottom side of the divce or to enter the security code which can be found near the QR code.&lt;br /&gt;
&lt;br /&gt;
The QR code contains the security code which is used as the pre shared key of the DTLS connection. As soon as the app gets the security code the app and the gateway are initiating the DTLS connection. All applicationdata is send over this encrypted connection.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls.png|550px]]&lt;br /&gt;
&lt;br /&gt;
Same implies to connections of additional smart home devices: All data is sent over the encrypted connection.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls-snap.png|550px]]&lt;br /&gt;
&lt;br /&gt;
As far as the initial setup goes there are only a few connections to the internet. This connections are all from app to some aws cloud addresses. It seems this is relating to the setup of a new device:&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-aws.png|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Data Transmission when using TRADFRI ==&lt;br /&gt;
&lt;br /&gt;
The IKEA TRADFRI Gateway was connected via LAN cable while the mobile phone running the IKEA app was connected wirelessly to the same network.&lt;br /&gt;
Overview of IP addresses used:&lt;br /&gt;
&lt;br /&gt;
[[File:ip_overview_muzik.png|550px]]&lt;br /&gt;
&lt;br /&gt;
Wireshark was used to record the traffic (using arpspoof because the IKEA TRADFRI Gateway requires a LAN connection so it is not possible to just monitor the Raspion WiFi) which was then filtered.&lt;br /&gt;
&lt;br /&gt;
It turns out that TRADFRI is rather well-behaved when it comes to sending data.&lt;br /&gt;
&lt;br /&gt;
For the most part it uses encrypted (DTLS) communication internally between the Gateway and the mobile phone. To initially find the Gateway after opening the mobile app, an MDNS request is sent out via multicast (224.x.x.x).&lt;br /&gt;
&lt;br /&gt;
However, 2 external connections or destinations could also be found:&lt;br /&gt;
&lt;br /&gt;
* IP address 13.227.156.82 / privacypolicy.config.homesmart.ikea.net (as the url indicates, this has the current policy one has to agree to before using the app)&lt;br /&gt;
* IP address 13.227.156.50 / supportdetails.config.homesmart.ikea.net (this is where the secure certificates are located, apparently).&lt;br /&gt;
&lt;br /&gt;
=== Wireshark caps ===&lt;br /&gt;
privacypolicy.config.homesmart.ikea.net Client Hello:&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-privacy policy-clientHello.png|700px]]&lt;br /&gt;
&lt;br /&gt;
supportdetails.config.homesmart.ikea.net ServerHello:&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-supportdetails-serverHello.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== Certificate Information ===&lt;br /&gt;
The Server Hello contains the information regarding the .cer and .crl:&lt;br /&gt;
 http://ocsp.rootca1.amazontrust.com&lt;br /&gt;
 http://crt.rootca1.amazontrust.com/rootca1.cer&lt;br /&gt;
 http://crl.rootca1.amazontrust.com/rootca1.crl&lt;br /&gt;
Starfield Technologies, Inc.; Starfield Services Root Certificate Authority&lt;br /&gt;
&lt;br /&gt;
Also:&lt;br /&gt;
 http://crl.sca1b.amazontrust.com/sca1b.crl&lt;br /&gt;
 http://ocsp.sca1b.amazontrust.com&lt;br /&gt;
 http://crt.sca1b.amazontrust.com/sca1b.crt &lt;br /&gt;
&lt;br /&gt;
That&#039;s pretty much it. We couldn&#039;t find any unwanted connections.&lt;br /&gt;
&lt;br /&gt;
The app also checks for updates for the used devices, this is also indicated in the app when it happens, so this is very transparent. It is indicated in the app when an update is happening or when the app is checking for new updates as can be seen in the screenshot below. If a device happens to be unavailable, e.g. because it is currently disconnected/turned off, then the app does not report back the current version but instead says the device is unreachable (&#039;Nicht erreichbar&#039;)&lt;br /&gt;
&lt;br /&gt;
[[File:Ikea-tradfri-update.png|360px]]&lt;br /&gt;
&lt;br /&gt;
== Kommunikation entschlüsseln ==&lt;br /&gt;
Bei diesem Versuch wird geschaut ob es möglich ist die Kommunikation, zwischen der IKEA App und dem IKEA Gateway mitzuhören. Nur mit einem Packet Sniffer ist dies nicht möglich, da die Kommunikation per DTLS verschlüsselt wird. Es kam zum Einsatz der MITM Proxy, welcher bei dem c’t-Raspion dabei ist.&lt;br /&gt;
&lt;br /&gt;
IP overview:&lt;br /&gt;
&lt;br /&gt;
[[File:mitm_findings.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== Aufbau ===&lt;br /&gt;
[[File:mitm-top.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Android kann als eine Virtuelle Maschine betrieben werden, oder es kann auch ein Smart Phone benutzt werden welches die IKEA Smarthome App installiert hat. Wenn es als Virtuelle Maschine betrieben wird, ist drauf zu achten, dass der Bridge Mode benutzt wird, da dann die VM eine eigene IP erhält. Dies hat den Vorteil, dass man nur den Traffic analysieren muss, welcher von Android erzeugt wird und nicht dem des Host Systems.&lt;br /&gt;
Um den MITM benutzten zu können, müssen die Zertifikaten zu dem Key-Store hinzugefügt werden. Dies kann getan werden in dem man die Website mitm.it ansurft. Ist man in dem richtigen Netzwerk sieht man folgendes Fenster.&lt;br /&gt;
&lt;br /&gt;
[[File:mitmproxy-cert.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Hier wählt man das richtige Betriebssystem und lädt die Zertifikate herunter.&lt;br /&gt;
&lt;br /&gt;
Die offizielle Dokumentation findet man hier[https://docs.mitmproxy.org/stable/concepts-certificates/#quick-setup].&lt;br /&gt;
&lt;br /&gt;
=== MitM Proxy ===&lt;br /&gt;
Beim Starten der App kann man in Wireshark stehen, dass der Handshake für die DTLS Verbindung durchgeführt wird. &lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-dtls.png]]&lt;br /&gt;
&lt;br /&gt;
Ebenso kann man beobachten, dass mehrere Verbindungen mit verschiedenen Servern nach draußen aufgebaut werden.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-tls.png]]&lt;br /&gt;
&lt;br /&gt;
Die Nachrichten zu diesen Servern können durch den MITM entschlüsselt werden.&lt;br /&gt;
&lt;br /&gt;
[[File:mitm-sniff.png]]&lt;br /&gt;
&lt;br /&gt;
Beide Nachrichten beinhalten eine JSON-Datei. &lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;descriptionText&amp;quot;: &amp;quot;That’s why we have updated the terms and conditions. Please agree below in order to continue. You can find the updated legal information in Settings or you can read more below.&amp;quot;,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampCookie&amp;quot;: 1568799375000,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampPP&amp;quot;: 1568798738000,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampTnC&amp;quot;: 1568798786000,&lt;br /&gt;
    &amp;quot;titleText&amp;quot;: &amp;quot;We’ve changed the name of our app! &amp;quot;&lt;br /&gt;
}&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;versionCode&amp;quot;: &amp;quot;44&amp;quot;,&lt;br /&gt;
    &amp;quot;versionName&amp;quot;: &amp;quot;1.11.3&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Im debug log kann beobachtet werden, dass weitere TLS Verbindung aufgebaut werden jedoch nicht entschlüsselt werden können.&lt;br /&gt;
&lt;br /&gt;
	192.168.24.241:59332: Client Handshake failed. The client may not trust the proxy&#039;s certificate for data.logentries.com.&lt;br /&gt;
	192.168.24.241:59332: ClientHandshakeException(&#039;Cannot establish TLS with client (sni: data.logentries.com): TlsException(&amp;quot;(-1, \&#039;Unexpected EOF\&#039;)&amp;quot;)&#039;)&lt;br /&gt;
	::ffff:192.168.24.241:58971: serverdisconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
	192.168.24.241:59332: clientdisconnect&lt;br /&gt;
	::ffff:192.168.24.241:40204: serverdisconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.50&#039;, 443)&lt;br /&gt;
	192.168.24.241:58971: clientdisconnect&lt;br /&gt;
	192.168.24.241:40204: clientdisconnect&lt;br /&gt;
	192.168.24.241:41657: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:41657: Establish TLS with client&lt;br /&gt;
	192.168.24.241:50453: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:50453: serverconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.36&#039;, 443)&lt;br /&gt;
	192.168.24.241:42222: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:42222: serverconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
	::ffff:192.168.24.241:42222: Establish TLS with server&lt;br /&gt;
	::ffff:192.168.24.241:50453: Establish TLS with server&lt;br /&gt;
	::ffff:192.168.24.241:42222: ALPN selected by server: -&lt;br /&gt;
	::ffff:192.168.24.241:42222: Establish TLS with client&lt;br /&gt;
	::ffff:192.168.24.241:50453: ALPN selected by server: -&lt;br /&gt;
	::ffff:192.168.24.241:50453: Establish TLS with client&lt;br /&gt;
	::ffff:192.168.24.241:42222: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
	::ffff:192.168.24.241:50453: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
	::ffff:192.168.24.241:50453: request&lt;br /&gt;
	  -&amp;gt; Request(GET /US/en/getPolicyUpdate/?deviceType=android)&lt;br /&gt;
	::ffff:192.168.24.241:42222: request&lt;br /&gt;
	  -&amp;gt; Request(GET /AppDetails)&lt;br /&gt;
	::ffff:192.168.24.241:42222: response&lt;br /&gt;
	  -&amp;gt; Response(200 OK, application/json, 44b)&lt;br /&gt;
	::ffff:192.168.24.241:50453: response&lt;br /&gt;
	  -&amp;gt; Response(200 OK, application/json, 374b)&lt;br /&gt;
&lt;br /&gt;
Die DTLS Verbindung zwischen der App und dem Gateway, erscheint jedoch nicht in dem Log des MITM.&lt;br /&gt;
&lt;br /&gt;
=== Replay-Attacke ===&lt;br /&gt;
Um eine Replay-Attacke durchführen zu können, muss der Datenverkehr zwischen dem Gerät, auf dem die IKEA App läuft und dem IKEA Gateway aufgezeichnet werden. Danach muss die SRC und DST in IP und MAC entsprechend angepasst werden. In diesem speziellen Beispiel ist im DTLS Protokoll eine Sequenznummer vorhanden. Diese muss ebenfalls angepasst werden, damit diese vorlaufend ist. Da in der UDP Checksumme auch der Payload miteinbezogen wird, muss diese neu berechnet werden.&lt;br /&gt;
&lt;br /&gt;
[[File:replay-attack.png]]&lt;br /&gt;
&lt;br /&gt;
Wie man sehen kann ist die Attacke nicht erfolgreich, da keine Antwort von dem Gateway gesendet wird und der die Pakete wahrscheinlich droppt.&lt;br /&gt;
&lt;br /&gt;
Dass kann aus dem Grund sein, da bei DTLS auch MAC (message authentication code) benutzt wird. Um den MAC Wert zu berechnen wird die Sequenznummer benutzt. Dieser Wert kann leider nicht neu berechnet werden, ohne die Verschlüsselung zu kennen.&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Replay-attack.png&amp;diff=4138</id>
		<title>File:Replay-attack.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Replay-attack.png&amp;diff=4138"/>
		<updated>2020-06-06T12:30:14Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3635</id>
		<title>Install c&#039;t&#039;-Raspion on Raspberry PI</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3635"/>
		<updated>2020-05-11T15:17:51Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
* Raspberry PI with Raspbian OS&lt;br /&gt;
* Internet connection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
=== Step 1: System Update ===&lt;br /&gt;
&lt;br /&gt;
In the command line interface enter:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Download ===&lt;br /&gt;
Download the latest version of Raspion:&lt;br /&gt;
&lt;br /&gt;
 wget ct.de/s/x5Pm -O raspion.zip &lt;br /&gt;
&lt;br /&gt;
=== Step 3: Installation ===&lt;br /&gt;
Unzip:&lt;br /&gt;
 unzip raspion.zip&lt;br /&gt;
&lt;br /&gt;
Install:&lt;br /&gt;
 cd raspion&lt;br /&gt;
 ./install.sh or bash install.sh&lt;br /&gt;
&lt;br /&gt;
[[File:Install_Raspion.png]]&lt;br /&gt;
&lt;br /&gt;
At the end of the installation there is the wifi name and password of the c&#039;t-Raspion.&lt;br /&gt;
&lt;br /&gt;
=== Launch c&#039;t-Raspion web interface ===&lt;br /&gt;
Atfer connecting to the wifi of the c&#039;t&#039;-Raspion go to http://&amp;lt;ip-address of your Raspberry-PI&amp;gt;:81&lt;br /&gt;
&lt;br /&gt;
[[File:Raspion_webinterface.png]]&lt;br /&gt;
&lt;br /&gt;
== Services of the c&#039;t-Raspion ==&lt;br /&gt;
&lt;br /&gt;
=== Pi-hole ===&lt;br /&gt;
Pi-hole shows DNS-Requests. They can also be blocked.&lt;br /&gt;
&lt;br /&gt;
[[File:pi-hole.png]]&lt;br /&gt;
&lt;br /&gt;
=== ntopng ===&lt;br /&gt;
They include the&lt;br /&gt;
involved communication partners, the network protocol and information on duration and volume. ntopng does not show the contents of the packages. But it analyses the flows and provides information about which application is communicating, such as Skype, BitTorrent etc., and provides statistics.&lt;br /&gt;
&lt;br /&gt;
=== Wireshark ===&lt;br /&gt;
Wireshark offers a deeper analysis of the network traffic as ntopng.  The program allows recording and analyzing network traffic down to the last bit and can be operated via browser as a special feature of c&#039;t-Raspion. The recorded network traffic will be saved in pcap-files.&lt;br /&gt;
 &lt;br /&gt;
=== mitmproxy ===&lt;br /&gt;
The mitm-Proxy can loop into the communication between the local and remote devices by the c&#039;t-Raspion redirecting all access from the internal network on TCP ports 80 and 443 to the mitm-Proxy. It takes the redirected accesses to port&lt;br /&gt;
8080 towards. The redirection is handled by firewall rules, which  can be activated and deactivated as required by clicking in the c&#039;t-Raspion web interface.&lt;br /&gt;
&lt;br /&gt;
== Ikea Tradfri Setup Sniff ==&lt;br /&gt;
Als Testgerät wurde ein möglich leergeräumtes iPhone verwendet. Alle deinstallierbaren Services wurden entfernt, wo möglich Synchronisierung deaktiviert.&lt;br /&gt;
 Jedoch sind Apple geräte mäßig geeignet, es werden zu viele Verbindungen vom Betriebssystem hergestellt (auch von deaktivierten iOs Services). &lt;br /&gt;
&lt;br /&gt;
Um Pihole auch zur Aufzeichnung von DNS queries vom Tradfri Gateway zu nutzen muss eine USB Netzwerkadapter verwendet werden oder ein externer Router als WiFi Bridge konfiguriert werden. Ohne diese Hardwareänderungen lässt sich ein Tradfri Gateway nicht in das Raspion Netzwerk integrieren. Um dennoch Pakete mitschneiden zu können wurde arpspoofing verwendet.&lt;br /&gt;
&lt;br /&gt;
Vorab Übersicht IP config&lt;br /&gt;
&lt;br /&gt;
[[File:ip-config.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Direkt beim Einschalten (cap power_on_gateway) werden von der App einige DNS anfragen gestellt um IPs von fw.ota.homesmart.ikea.net zu erhalten. In den DNS Antworten sind ebenfalls IPs zu d262cmbxmzphsu.cloudfront.net enthalten. Ikea nutzt dabei AWS.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap1.png|700px]]&lt;br /&gt;
[[File:wireshark-cap2.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Weiters findet man eine http Verbindung:&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-http.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Die unter fw.ota.homesmart.ikea.net/feed/version_info.json vorhandenen Daten sind nicht allzu spektakulär: Es sind lediglich Versionsinfos.&lt;br /&gt;
&lt;br /&gt;
Sobald über die Ikea Smart Home App das Setup gestarted wird versucht die App mit mDNS queries den Tradfri Gateway zu finden.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-mDNS.png|550px]]&lt;br /&gt;
&lt;br /&gt;
Bei dem verwendeten Setup schlägt dies natürlich fehl, jedoch bietet die App direkt die option eine IP manuell einzugeben. Nach Eingabe der IP muss entweder der QR Code auf der Rückseite des Gerätes gescannt werden oder der Sicherheitscode eingegeben werden der sich ebenfalls auf der Rückseite des Geräts befindet.&lt;br /&gt;
&lt;br /&gt;
Der Sicherheitscode ist dabei der PSK der DTLS Verbindung. Sobald der App der QR Code bzw der Sicherheitscode bekannt sind bauen App und Gateway eine DTLS Verbindung auf. Über diese Verbindung werden alle Applikationsdaten gesendet.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls.png|550px]]&lt;br /&gt;
&lt;br /&gt;
Auch beim Verbinden von weiteren SH Geräten baut die App keine gesonderten Verbindung auf sondern kommuniziert ausschließlich über DTLS.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls-snap.png|550px]]&lt;br /&gt;
&lt;br /&gt;
Einige Verbindungen zur AWS Cloud baut die App dennoch auf. Dies steht anscheinend im Zusammenhang mit dem Verbinden von Geräten da immer direkt nach dem Verbinden eines Gerätes diese Seiten abgefragt werden:&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-aws.png|550px]]&lt;br /&gt;
&lt;br /&gt;
== Data Transmission when using TRADFRI ==&lt;br /&gt;
&lt;br /&gt;
The IKEA TRADFRI Gateway was connected via LAN cable while the mobile phone running the IKEA app was connected wirelessly to the same network.&lt;br /&gt;
&lt;br /&gt;
Wireshark was used to record the traffic which was then filtered.&lt;br /&gt;
&lt;br /&gt;
It turns out that TRADFRI is rather well-behaved when it comes to sending data.&lt;br /&gt;
&lt;br /&gt;
For the most part it uses encrypted (DTLS) communication internally between the Gateway and the mobile phone. To find the Gateway an MDNS request is sent out via multicast (224.x.x.x).&lt;br /&gt;
&lt;br /&gt;
However, 2 external connections or destinations could also be found:&lt;br /&gt;
&lt;br /&gt;
* IP address 13.227.156.82 / privacypolicy.config.homesmart.ikea.net (as the url indicates, this has the current policy one has to agree to before using the app)&lt;br /&gt;
* IP address 13.227.156.50 / supportdetails.config.homesmart.ikea.net (this is where the secure certificates are located, apparently).&lt;br /&gt;
&lt;br /&gt;
That&#039;s pretty much it. We couldn&#039;t find any unwanted connections. The app also checks for updates for the used devices, this is also indicated in the app when it happens, so this is very transparent.&lt;br /&gt;
&lt;br /&gt;
TODO: Screenshots to follow shortly&lt;br /&gt;
&lt;br /&gt;
== Kommunikation entschlüsseln ==&lt;br /&gt;
Bei diesem Versuch wird geschaut ob es möglich ist die Kommunikation, zwischen der IKEA App und dem IKEA Gateway mitzuhören. Nur mit einem Packet Sniffer ist dies nicht möglich, da die Kommunikation per DTLS verschlüsselt wird. Es kam zum Einsatz der MITM Proxy, welcher bei dem c’t-Raspion dabei ist.&lt;br /&gt;
&lt;br /&gt;
=== Aufbau ===&lt;br /&gt;
[[File:mitm-top.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Android kann als eine Virtuelle Maschine betrieben werden, oder es kann auch ein Smart Phone benutzt werden welches die IKEA Smarthome App installiert hat. Wenn es als Virtuelle Maschine betrieben wird, ist drauf zu achten, dass der Bridge Mode benutzt wird, da dann die VM eine eigene IP erhält. Dies hat den Vorteil, dass man nur den Traffic analysieren muss, welcher von Android erzeugt wird und nicht dem des Host Systems.&lt;br /&gt;
Um den MITM benutzten zu können, müssen die Zertifikaten zu dem Key-Store hinzugefügt werden. Dies kann getan werden in dem man die Website mitm.it ansurft. Ist man in dem richtigen Netzwerk sieht man folgendes Fenster.&lt;br /&gt;
&lt;br /&gt;
[[File:mitmproxy-cert.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Hier wählt man das richtige Betriebssystem und lädt die Zertifikate herunter.&lt;br /&gt;
&lt;br /&gt;
Die offizielle Dokumentation findet man hier[https://docs.mitmproxy.org/stable/concepts-certificates/#quick-setup].&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
Beim Starten der App kann man in Wireshark stehen, dass der Handshake für die DTLS Verbindung durchgeführt wird. &lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-dtls.png]]&lt;br /&gt;
&lt;br /&gt;
Ebenso kann man beobachten, dass mehrere Verbindungen mit verschiedenen Servern nach draußen aufgebaut werden.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-tls.png]]&lt;br /&gt;
&lt;br /&gt;
Die Nachrichten zu diesen Servern können durch den MITM entschlüsselt werden.&lt;br /&gt;
&lt;br /&gt;
[[File:mitm-sniff.png]]&lt;br /&gt;
&lt;br /&gt;
Beide Nachrichten beinhalten eine JSON-Datei. &lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;descriptionText&amp;quot;: &amp;quot;That’s why we have updated the terms and conditions. Please agree below in order to continue. You can find the updated legal information in Settings or you can read more below.&amp;quot;,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampCookie&amp;quot;: 1568799375000,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampPP&amp;quot;: 1568798738000,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampTnC&amp;quot;: 1568798786000,&lt;br /&gt;
    &amp;quot;titleText&amp;quot;: &amp;quot;We’ve changed the name of our app! &amp;quot;&lt;br /&gt;
}&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;versionCode&amp;quot;: &amp;quot;44&amp;quot;,&lt;br /&gt;
    &amp;quot;versionName&amp;quot;: &amp;quot;1.11.3&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Im debug log kann beobachtet werden, dass weitere TLS Verbindung aufgebaut werden jedoch nicht entschlüsselt werden können.&lt;br /&gt;
&lt;br /&gt;
	192.168.24.241:59332: Client Handshake failed. The client may not trust the proxy&#039;s certificate for data.logentries.com.&lt;br /&gt;
	192.168.24.241:59332: ClientHandshakeException(&#039;Cannot establish TLS with client (sni: data.logentries.com): TlsException(&amp;quot;(-1, \&#039;Unexpected EOF\&#039;)&amp;quot;)&#039;)&lt;br /&gt;
	::ffff:192.168.24.241:58971: serverdisconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
	192.168.24.241:59332: clientdisconnect&lt;br /&gt;
	::ffff:192.168.24.241:40204: serverdisconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.50&#039;, 443)&lt;br /&gt;
	192.168.24.241:58971: clientdisconnect&lt;br /&gt;
	192.168.24.241:40204: clientdisconnect&lt;br /&gt;
	192.168.24.241:41657: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:41657: Establish TLS with client&lt;br /&gt;
	192.168.24.241:50453: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:50453: serverconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.36&#039;, 443)&lt;br /&gt;
	192.168.24.241:42222: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:42222: serverconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
	::ffff:192.168.24.241:42222: Establish TLS with server&lt;br /&gt;
	::ffff:192.168.24.241:50453: Establish TLS with server&lt;br /&gt;
	::ffff:192.168.24.241:42222: ALPN selected by server: -&lt;br /&gt;
	::ffff:192.168.24.241:42222: Establish TLS with client&lt;br /&gt;
	::ffff:192.168.24.241:50453: ALPN selected by server: -&lt;br /&gt;
	::ffff:192.168.24.241:50453: Establish TLS with client&lt;br /&gt;
	::ffff:192.168.24.241:42222: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
	::ffff:192.168.24.241:50453: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
	::ffff:192.168.24.241:50453: request&lt;br /&gt;
	  -&amp;gt; Request(GET /US/en/getPolicyUpdate/?deviceType=android)&lt;br /&gt;
	::ffff:192.168.24.241:42222: request&lt;br /&gt;
	  -&amp;gt; Request(GET /AppDetails)&lt;br /&gt;
	::ffff:192.168.24.241:42222: response&lt;br /&gt;
	  -&amp;gt; Response(200 OK, application/json, 44b)&lt;br /&gt;
	::ffff:192.168.24.241:50453: response&lt;br /&gt;
	  -&amp;gt; Response(200 OK, application/json, 374b)&lt;br /&gt;
&lt;br /&gt;
Die DTLS Verbindung zwischen der App und dem Gateway, erscheint jedoch nicht in dem Log des MITM.&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-cap-mDNS.png&amp;diff=3634</id>
		<title>File:Wireshark-cap-mDNS.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-cap-mDNS.png&amp;diff=3634"/>
		<updated>2020-05-11T15:14:21Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-cap-http.png&amp;diff=3633</id>
		<title>File:Wireshark-cap-http.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-cap-http.png&amp;diff=3633"/>
		<updated>2020-05-11T15:14:14Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-cap-dtls-snap.png&amp;diff=3632</id>
		<title>File:Wireshark-cap-dtls-snap.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-cap-dtls-snap.png&amp;diff=3632"/>
		<updated>2020-05-11T15:14:06Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-cap-dtls.png&amp;diff=3631</id>
		<title>File:Wireshark-cap-dtls.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-cap-dtls.png&amp;diff=3631"/>
		<updated>2020-05-11T15:13:58Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-cap-aws.png&amp;diff=3630</id>
		<title>File:Wireshark-cap-aws.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-cap-aws.png&amp;diff=3630"/>
		<updated>2020-05-11T15:13:48Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-cap2.png&amp;diff=3629</id>
		<title>File:Wireshark-cap2.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-cap2.png&amp;diff=3629"/>
		<updated>2020-05-11T15:13:39Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-cap1.png&amp;diff=3628</id>
		<title>File:Wireshark-cap1.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-cap1.png&amp;diff=3628"/>
		<updated>2020-05-11T15:13:31Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Ip-config.png&amp;diff=3627</id>
		<title>File:Ip-config.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Ip-config.png&amp;diff=3627"/>
		<updated>2020-05-11T15:13:02Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3626</id>
		<title>Install c&#039;t&#039;-Raspion on Raspberry PI</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3626"/>
		<updated>2020-05-11T15:03:03Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
* Raspberry PI with Raspbian OS&lt;br /&gt;
* Internet connection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
=== Step 1: System Update ===&lt;br /&gt;
&lt;br /&gt;
In the command line interface enter:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Download ===&lt;br /&gt;
Download the latest version of Raspion:&lt;br /&gt;
&lt;br /&gt;
 wget ct.de/s/x5Pm -O raspion.zip &lt;br /&gt;
&lt;br /&gt;
=== Step 3: Installation ===&lt;br /&gt;
Unzip:&lt;br /&gt;
 unzip raspion.zip&lt;br /&gt;
&lt;br /&gt;
Install:&lt;br /&gt;
 cd raspion&lt;br /&gt;
 ./install.sh or bash install.sh&lt;br /&gt;
&lt;br /&gt;
[[File:Install_Raspion.png]]&lt;br /&gt;
&lt;br /&gt;
At the end of the installation there is the wifi name and password of the c&#039;t-Raspion.&lt;br /&gt;
&lt;br /&gt;
=== Launch c&#039;t-Raspion web interface ===&lt;br /&gt;
Atfer connecting to the wifi of the c&#039;t&#039;-Raspion go to http://&amp;lt;ip-address of your Raspberry-PI&amp;gt;:81&lt;br /&gt;
&lt;br /&gt;
[[File:Raspion_webinterface.png]]&lt;br /&gt;
&lt;br /&gt;
== Services of the c&#039;t-Raspion ==&lt;br /&gt;
&lt;br /&gt;
=== Pi-hole ===&lt;br /&gt;
Pi-hole shows DNS-Requests. They can also be blocked.&lt;br /&gt;
&lt;br /&gt;
[[File:pi-hole.png]]&lt;br /&gt;
&lt;br /&gt;
=== ntopng ===&lt;br /&gt;
They include the&lt;br /&gt;
involved communication partners, the network protocol and information on duration and volume. ntopng does not show the contents of the packages. But it analyses the flows and provides information about which application is communicating, such as Skype, BitTorrent etc., and provides statistics.&lt;br /&gt;
&lt;br /&gt;
=== Wireshark ===&lt;br /&gt;
Wireshark offers a deeper analysis of the network traffic as ntopng.  The program allows recording and analyzing network traffic down to the last bit and can be operated via browser as a special feature of c&#039;t-Raspion. The recorded network traffic will be saved in pcap-files.&lt;br /&gt;
 &lt;br /&gt;
=== mitmproxy ===&lt;br /&gt;
The mitm-Proxy can loop into the communication between the local and remote devices by the c&#039;t-Raspion redirecting all access from the internal network on TCP ports 80 and 443 to the mitm-Proxy. It takes the redirected accesses to port&lt;br /&gt;
8080 towards. The redirection is handled by firewall rules, which  can be activated and deactivated as required by clicking in the c&#039;t-Raspion web interface.&lt;br /&gt;
&lt;br /&gt;
== Ikea Tradfri Setup Sniff ==&lt;br /&gt;
Als Testgerät wurde ein möglich leergeräumtes iPhone verwendet. Alle deinstallierbaren Services wurden entfernt, wo möglich Synchronisierung deaktiviert.&lt;br /&gt;
 Jedoch sind Apple geräte mäßig geeignet, es werden zu viele Verbindungen vom Betriebssystem hergestellt (auch von deaktivierten iOs Services). &lt;br /&gt;
&lt;br /&gt;
Um Pihole auch zur Aufzeichnung von DNS queries vom Tradfri Gateway zu nutzen muss eine USB Netzwerkadapter verwendet werden oder ein externer Router als WiFi Bridge konfiguriert werden. Ohne diese Hardwareänderungen lässt sich ein Tradfri Gateway nicht in das Raspion Netzwerk integrieren. Um dennoch Pakete mitschneiden zu können wurde arpspoofing verwendet.&lt;br /&gt;
&lt;br /&gt;
Vorab Übersicht IP config&lt;br /&gt;
&lt;br /&gt;
[[File:ip-config.png]]&lt;br /&gt;
&lt;br /&gt;
Direkt beim Einschalten (cap power_on_gateway) werden von der App einige DNS anfragen gestellt um IPs von fw.ota.homesmart.ikea.net zu erhalten. In den DNS Antworten sind ebenfalls IPs zu d262cmbxmzphsu.cloudfront.net enthalten. Ikea nutzt dabei AWS.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap1.png]]&lt;br /&gt;
[[File:wireshark-cap2.png]]&lt;br /&gt;
&lt;br /&gt;
Weiters findet man eine http Verbindung:&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-http.png]]&lt;br /&gt;
&lt;br /&gt;
Die unter fw.ota.homesmart.ikea.net/feed/version_info.json vorhandenen Daten sind nicht allzu spektakulär: Es sind lediglich Versionsinfos.&lt;br /&gt;
&lt;br /&gt;
Sobald über die Ikea Smart Home App das Setup gestarted wird versucht die App mit mDNS queries den Tradfri Gateway zu finden.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-mDNS.png]]&lt;br /&gt;
&lt;br /&gt;
Bei dem verwendeten Setup schlägt dies natürlich fehl, jedoch bietet die App direkt die option eine IP manuell einzugeben. Nach Eingabe der IP muss entweder der QR Code auf der Rückseite des Gerätes gescannt werden oder der Sicherheitscode eingegeben werden der sich ebenfalls auf der Rückseite des Geräts befindet.&lt;br /&gt;
&lt;br /&gt;
Der Sicherheitscode ist dabei der PSK der DTLS Verbindung. Sobald der App der QR Code bzw der Sicherheitscode bekannt sind bauen App und Gateway eine DTLS Verbindung auf. Über diese Verbindung werden alle Applikationsdaten gesendet.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls.png]]&lt;br /&gt;
&lt;br /&gt;
Auch beim Verbinden von weiteren SH Geräten baut die App keine gesonderten Verbindung auf sondern kommuniziert ausschließlich über DTLS.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-dtls-snap.png]]&lt;br /&gt;
&lt;br /&gt;
Einige Verbindungen zur AWS Cloud baut die App dennoch auf. Dies steht anscheinend im Zusammenhang mit dem Verbinden von Geräten da immer direkt nach dem Verbinden eines Gerätes diese Seiten abgefragt werden:&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-cap-aws.png]]&lt;br /&gt;
&lt;br /&gt;
== Data Transmission when using TRADFRI ==&lt;br /&gt;
&lt;br /&gt;
The IKEA TRADFRI Gateway was connected via LAN cable while the mobile phone running the IKEA app was connected wirelessly to the same network.&lt;br /&gt;
&lt;br /&gt;
Wireshark was used to record the traffic which was then filtered.&lt;br /&gt;
&lt;br /&gt;
It turns out that TRADFRI is rather well-behaved when it comes to sending data.&lt;br /&gt;
&lt;br /&gt;
For the most part it uses encrypted (DTLS) communication internally between the Gateway and the mobile phone. To find the Gateway an MDNS request is sent out via multicast (224.x.x.x).&lt;br /&gt;
&lt;br /&gt;
However, 2 external connections or destinations could also be found:&lt;br /&gt;
&lt;br /&gt;
* IP address 13.227.156.82 / privacypolicy.config.homesmart.ikea.net (as the url indicates, this has the current policy one has to agree to before using the app)&lt;br /&gt;
* IP address 13.227.156.50 / supportdetails.config.homesmart.ikea.net (this is where the secure certificates are located, apparently).&lt;br /&gt;
&lt;br /&gt;
That&#039;s pretty much it. We couldn&#039;t find any unwanted connections. The app also checks for updates for the used devices, this is also indicated in the app when it happens, so this is very transparent.&lt;br /&gt;
&lt;br /&gt;
TODO: Screenshots to follow shortly&lt;br /&gt;
&lt;br /&gt;
== Kommunikation entschlüsseln ==&lt;br /&gt;
Bei diesem Versuch wird geschaut ob es möglich ist die Kommunikation, zwischen der IKEA App und dem IKEA Gateway mitzuhören. Nur mit einem Packet Sniffer ist dies nicht möglich, da die Kommunikation per DTLS verschlüsselt wird. Es kam zum Einsatz der MITM Proxy, welcher bei dem c’t-Raspion dabei ist.&lt;br /&gt;
&lt;br /&gt;
=== Aufbau ===&lt;br /&gt;
[[File:mitm-top.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Android kann als eine Virtuelle Maschine betrieben werden, oder es kann auch ein Smart Phone benutzt werden welches die IKEA Smarthome App installiert hat. Wenn es als Virtuelle Maschine betrieben wird, ist drauf zu achten, dass der Bridge Mode benutzt wird, da dann die VM eine eigene IP erhält. Dies hat den Vorteil, dass man nur den Traffic analysieren muss, welcher von Android erzeugt wird und nicht dem des Host Systems.&lt;br /&gt;
Um den MITM benutzten zu können, müssen die Zertifikaten zu dem Key-Store hinzugefügt werden. Dies kann getan werden in dem man die Website mitm.it ansurft. Ist man in dem richtigen Netzwerk sieht man folgendes Fenster.&lt;br /&gt;
&lt;br /&gt;
[[File:mitmproxy-cert.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Hier wählt man das richtige Betriebssystem und lädt die Zertifikate herunter.&lt;br /&gt;
&lt;br /&gt;
Die offizielle Dokumentation findet man hier[https://docs.mitmproxy.org/stable/concepts-certificates/#quick-setup].&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
Beim Starten der App kann man in Wireshark stehen, dass der Handshake für die DTLS Verbindung durchgeführt wird. &lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-dtls.png]]&lt;br /&gt;
&lt;br /&gt;
Ebenso kann man beobachten, dass mehrere Verbindungen mit verschiedenen Servern nach draußen aufgebaut werden.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-tls.png]]&lt;br /&gt;
&lt;br /&gt;
Die Nachrichten zu diesen Servern können durch den MITM entschlüsselt werden.&lt;br /&gt;
&lt;br /&gt;
[[File:mitm-sniff.png]]&lt;br /&gt;
&lt;br /&gt;
Beide Nachrichten beinhalten eine JSON-Datei. &lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;descriptionText&amp;quot;: &amp;quot;That’s why we have updated the terms and conditions. Please agree below in order to continue. You can find the updated legal information in Settings or you can read more below.&amp;quot;,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampCookie&amp;quot;: 1568799375000,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampPP&amp;quot;: 1568798738000,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampTnC&amp;quot;: 1568798786000,&lt;br /&gt;
    &amp;quot;titleText&amp;quot;: &amp;quot;We’ve changed the name of our app! &amp;quot;&lt;br /&gt;
}&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;versionCode&amp;quot;: &amp;quot;44&amp;quot;,&lt;br /&gt;
    &amp;quot;versionName&amp;quot;: &amp;quot;1.11.3&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Im debug log kann beobachtet werden, dass weitere TLS Verbindung aufgebaut werden jedoch nicht entschlüsselt werden können.&lt;br /&gt;
&lt;br /&gt;
	192.168.24.241:59332: Client Handshake failed. The client may not trust the proxy&#039;s certificate for data.logentries.com.&lt;br /&gt;
	192.168.24.241:59332: ClientHandshakeException(&#039;Cannot establish TLS with client (sni: data.logentries.com): TlsException(&amp;quot;(-1, \&#039;Unexpected EOF\&#039;)&amp;quot;)&#039;)&lt;br /&gt;
	::ffff:192.168.24.241:58971: serverdisconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
	192.168.24.241:59332: clientdisconnect&lt;br /&gt;
	::ffff:192.168.24.241:40204: serverdisconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.50&#039;, 443)&lt;br /&gt;
	192.168.24.241:58971: clientdisconnect&lt;br /&gt;
	192.168.24.241:40204: clientdisconnect&lt;br /&gt;
	192.168.24.241:41657: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:41657: Establish TLS with client&lt;br /&gt;
	192.168.24.241:50453: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:50453: serverconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.36&#039;, 443)&lt;br /&gt;
	192.168.24.241:42222: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:42222: serverconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
	::ffff:192.168.24.241:42222: Establish TLS with server&lt;br /&gt;
	::ffff:192.168.24.241:50453: Establish TLS with server&lt;br /&gt;
	::ffff:192.168.24.241:42222: ALPN selected by server: -&lt;br /&gt;
	::ffff:192.168.24.241:42222: Establish TLS with client&lt;br /&gt;
	::ffff:192.168.24.241:50453: ALPN selected by server: -&lt;br /&gt;
	::ffff:192.168.24.241:50453: Establish TLS with client&lt;br /&gt;
	::ffff:192.168.24.241:42222: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
	::ffff:192.168.24.241:50453: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
	::ffff:192.168.24.241:50453: request&lt;br /&gt;
	  -&amp;gt; Request(GET /US/en/getPolicyUpdate/?deviceType=android)&lt;br /&gt;
	::ffff:192.168.24.241:42222: request&lt;br /&gt;
	  -&amp;gt; Request(GET /AppDetails)&lt;br /&gt;
	::ffff:192.168.24.241:42222: response&lt;br /&gt;
	  -&amp;gt; Response(200 OK, application/json, 44b)&lt;br /&gt;
	::ffff:192.168.24.241:50453: response&lt;br /&gt;
	  -&amp;gt; Response(200 OK, application/json, 374b)&lt;br /&gt;
&lt;br /&gt;
Die DTLS Verbindung zwischen der App und dem Gateway, erscheint jedoch nicht in dem Log des MITM.&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3622</id>
		<title>Install c&#039;t&#039;-Raspion on Raspberry PI</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3622"/>
		<updated>2020-05-11T14:42:55Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
* Raspberry PI with Raspbian OS&lt;br /&gt;
* Internet connection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
=== Step 1: System Update ===&lt;br /&gt;
&lt;br /&gt;
In the command line interface enter:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Download ===&lt;br /&gt;
Download the latest version of Raspion:&lt;br /&gt;
&lt;br /&gt;
 wget ct.de/s/x5Pm -O raspion.zip &lt;br /&gt;
&lt;br /&gt;
=== Step 3: Installation ===&lt;br /&gt;
Unzip:&lt;br /&gt;
 unzip raspion.zip&lt;br /&gt;
&lt;br /&gt;
Install:&lt;br /&gt;
 cd raspion&lt;br /&gt;
 ./install.sh or bash install.sh&lt;br /&gt;
&lt;br /&gt;
[[File:Install_Raspion.png]]&lt;br /&gt;
&lt;br /&gt;
At the end of the installation there is the wifi name and password of the c&#039;t-Raspion.&lt;br /&gt;
&lt;br /&gt;
=== Launch c&#039;t-Raspion web interface ===&lt;br /&gt;
Atfer connecting to the wifi of the c&#039;t&#039;-Raspion go to http://&amp;lt;ip-address of your Raspberry-PI&amp;gt;:81&lt;br /&gt;
&lt;br /&gt;
[[File:Raspion_webinterface.png]]&lt;br /&gt;
&lt;br /&gt;
== Services of the c&#039;t-Raspion ==&lt;br /&gt;
&lt;br /&gt;
=== Pi-hole ===&lt;br /&gt;
Pi-hole shows DNS-Requests. They can also be blocked.&lt;br /&gt;
&lt;br /&gt;
[[File:pi-hole.png]]&lt;br /&gt;
&lt;br /&gt;
=== ntopng ===&lt;br /&gt;
They include the&lt;br /&gt;
involved communication partners, the network protocol and information on duration and volume. ntopng does not show the contents of the packages. But it analyses the flows and provides information about which application is communicating, such as Skype, BitTorrent etc., and provides statistics.&lt;br /&gt;
&lt;br /&gt;
=== Wireshark ===&lt;br /&gt;
Wireshark offers a deeper analysis of the network traffic as ntopng.  The program allows recording and analyzing network traffic down to the last bit and can be operated via browser as a special feature of c&#039;t-Raspion. The recorded network traffic will be saved in pcap-files.&lt;br /&gt;
 &lt;br /&gt;
=== mitmproxy ===&lt;br /&gt;
The mitm-Proxy can loop into the communication between the local and remote devices by the c&#039;t-Raspion redirecting all access from the internal network on TCP ports 80 and 443 to the mitm-Proxy. It takes the redirected accesses to port&lt;br /&gt;
8080 towards. The redirection is handled by firewall rules, which  can be activated and deactivated as required by clicking in the c&#039;t-Raspion web interface.&lt;br /&gt;
&lt;br /&gt;
== Kommunikation entschlüsseln ==&lt;br /&gt;
Bei diesem Versuch wird geschaut ob es möglich ist die Kommunikation, zwischen der IKEA App und dem IKEA Gateway mitzuhören. Nur mit einem Packet Sniffer ist dies nicht möglich, da die Kommunikation per DTLS verschlüsselt wird. Es kam zum Einsatz der MITM Proxy, welcher bei dem c’t-Raspion dabei ist.&lt;br /&gt;
&lt;br /&gt;
=== Aufbau ===&lt;br /&gt;
[[File:mitm-top.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Android kann als eine Virtuelle Maschine betrieben werden, oder es kann auch ein Smart Phone benutzt werden welches die IKEA Smarthome App installiert hat. Wenn es als Virtuelle Maschine betrieben wird, ist drauf zu achten, dass der Bridge Mode benutzt wird, da dann die VM eine eigene IP erhält. Dies hat den Vorteil, dass man nur den Traffic analysieren muss, welcher von Android erzeugt wird und nicht dem des Host Systems.&lt;br /&gt;
Um den MITM benutzten zu können, müssen die Zertifikaten zu dem Key-Store hinzugefügt werden. Dies kann getan werden in dem man die Website mitm.it ansurft. Ist man in dem richtigen Netzwerk sieht man folgendes Fenster.&lt;br /&gt;
&lt;br /&gt;
[[File:mitmproxy-cert.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Hier wählt man das richtige Betriebssystem und lädt die Zertifikate herunter.&lt;br /&gt;
&lt;br /&gt;
Die offizielle Dokumentation findet man hier[https://docs.mitmproxy.org/stable/concepts-certificates/#quick-setup].&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
Beim Starten der App kann man in Wireshark stehen, dass der Handshake für die DTLS Verbindung durchgeführt wird. &lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-dtls.png]]&lt;br /&gt;
&lt;br /&gt;
Ebenso kann man beobachten, dass mehrere Verbindungen mit verschiedenen Servern nach draußen aufgebaut werden.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-tls.png]]&lt;br /&gt;
&lt;br /&gt;
Die Nachrichten zu diesen Servern können durch den MITM entschlüsselt werden.&lt;br /&gt;
&lt;br /&gt;
[[File:mitm-sniff.png]]&lt;br /&gt;
&lt;br /&gt;
Beide Nachrichten beinhalten eine JSON-Datei. &lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;descriptionText&amp;quot;: &amp;quot;That’s why we have updated the terms and conditions. Please agree below in order to continue. You can find the updated legal information in Settings or you can read more below.&amp;quot;,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampCookie&amp;quot;: 1568799375000,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampPP&amp;quot;: 1568798738000,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampTnC&amp;quot;: 1568798786000,&lt;br /&gt;
    &amp;quot;titleText&amp;quot;: &amp;quot;We’ve changed the name of our app! &amp;quot;&lt;br /&gt;
}&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;versionCode&amp;quot;: &amp;quot;44&amp;quot;,&lt;br /&gt;
    &amp;quot;versionName&amp;quot;: &amp;quot;1.11.3&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Im debug log kann beobachtet werden, dass weitere TLS Verbindung aufgebaut werden jedoch nicht entschlüsselt werden können.&lt;br /&gt;
&lt;br /&gt;
	192.168.24.241:59332: Client Handshake failed. The client may not trust the proxy&#039;s certificate for data.logentries.com.&lt;br /&gt;
	192.168.24.241:59332: ClientHandshakeException(&#039;Cannot establish TLS with client (sni: data.logentries.com): TlsException(&amp;quot;(-1, \&#039;Unexpected EOF\&#039;)&amp;quot;)&#039;)&lt;br /&gt;
	::ffff:192.168.24.241:58971: serverdisconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
	192.168.24.241:59332: clientdisconnect&lt;br /&gt;
	::ffff:192.168.24.241:40204: serverdisconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.50&#039;, 443)&lt;br /&gt;
	192.168.24.241:58971: clientdisconnect&lt;br /&gt;
	192.168.24.241:40204: clientdisconnect&lt;br /&gt;
	192.168.24.241:41657: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:41657: Establish TLS with client&lt;br /&gt;
	192.168.24.241:50453: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:50453: serverconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.36&#039;, 443)&lt;br /&gt;
	192.168.24.241:42222: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:42222: serverconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
	::ffff:192.168.24.241:42222: Establish TLS with server&lt;br /&gt;
	::ffff:192.168.24.241:50453: Establish TLS with server&lt;br /&gt;
	::ffff:192.168.24.241:42222: ALPN selected by server: -&lt;br /&gt;
	::ffff:192.168.24.241:42222: Establish TLS with client&lt;br /&gt;
	::ffff:192.168.24.241:50453: ALPN selected by server: -&lt;br /&gt;
	::ffff:192.168.24.241:50453: Establish TLS with client&lt;br /&gt;
	::ffff:192.168.24.241:42222: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
	::ffff:192.168.24.241:50453: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
	::ffff:192.168.24.241:50453: request&lt;br /&gt;
	  -&amp;gt; Request(GET /US/en/getPolicyUpdate/?deviceType=android)&lt;br /&gt;
	::ffff:192.168.24.241:42222: request&lt;br /&gt;
	  -&amp;gt; Request(GET /AppDetails)&lt;br /&gt;
	::ffff:192.168.24.241:42222: response&lt;br /&gt;
	  -&amp;gt; Response(200 OK, application/json, 44b)&lt;br /&gt;
	::ffff:192.168.24.241:50453: response&lt;br /&gt;
	  -&amp;gt; Response(200 OK, application/json, 374b)&lt;br /&gt;
&lt;br /&gt;
Die DTLS Verbindung zwischen der App und dem Gateway, erscheint jedoch nicht in dem Log des MITM.&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3621</id>
		<title>Install c&#039;t&#039;-Raspion on Raspberry PI</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3621"/>
		<updated>2020-05-11T14:40:44Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
* Raspberry PI with Raspbian OS&lt;br /&gt;
* Internet connection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
=== Step 1: System Update ===&lt;br /&gt;
&lt;br /&gt;
In the command line interface enter:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Download ===&lt;br /&gt;
Download the latest version of Raspion:&lt;br /&gt;
&lt;br /&gt;
 wget ct.de/s/x5Pm -O raspion.zip &lt;br /&gt;
&lt;br /&gt;
=== Step 3: Installation ===&lt;br /&gt;
Unzip:&lt;br /&gt;
 unzip raspion.zip&lt;br /&gt;
&lt;br /&gt;
Install:&lt;br /&gt;
 cd raspion&lt;br /&gt;
 ./install.sh or bash install.sh&lt;br /&gt;
&lt;br /&gt;
[[File:Install_Raspion.png]]&lt;br /&gt;
&lt;br /&gt;
At the end of the installation there is the wifi name and password of the c&#039;t-Raspion.&lt;br /&gt;
&lt;br /&gt;
=== Launch c&#039;t-Raspion web interface ===&lt;br /&gt;
Atfer connecting to the wifi of the c&#039;t&#039;-Raspion go to http://&amp;lt;ip-address of your Raspberry-PI&amp;gt;:81&lt;br /&gt;
&lt;br /&gt;
[[File:Raspion_webinterface.png]]&lt;br /&gt;
&lt;br /&gt;
== Services of the c&#039;t-Raspion ==&lt;br /&gt;
&lt;br /&gt;
=== Pi-hole ===&lt;br /&gt;
Pi-hole shows DNS-Requests. They can also be blocked.&lt;br /&gt;
&lt;br /&gt;
[[File:pi-hole.png]]&lt;br /&gt;
&lt;br /&gt;
=== ntopng ===&lt;br /&gt;
They include the&lt;br /&gt;
involved communication partners, the network protocol and information on duration and volume. ntopng does not show the contents of the packages. But it analyses the flows and provides information about which application is communicating, such as Skype, BitTorrent etc., and provides statistics.&lt;br /&gt;
&lt;br /&gt;
=== Wireshark ===&lt;br /&gt;
Wireshark offers a deeper analysis of the network traffic as ntopng.  The program allows recording and analyzing network traffic down to the last bit and can be operated via browser as a special feature of c&#039;t-Raspion. The recorded network traffic will be saved in pcap-files.&lt;br /&gt;
 &lt;br /&gt;
=== mitmproxy ===&lt;br /&gt;
The mitm-Proxy can loop into the communication between the local and remote devices by the c&#039;t-Raspion redirecting all access from the internal network on TCP ports 80 and 443 to the mitm-Proxy. It takes the redirected accesses to port&lt;br /&gt;
8080 towards. The redirection is handled by firewall rules, which  can be activated and deactivated as required by clicking in the c&#039;t-Raspion web interface.&lt;br /&gt;
&lt;br /&gt;
== Kommunikation entschlüsseln ==&lt;br /&gt;
Bei diesem Versuch wird geschaut ob es möglich ist die Kommunikation, zwischen der IKEA App und dem IKEA Gateway mitzuhören. Nur mit einem Packet Sniffer ist dies nicht möglich, da die Kommunikation per DTLS verschlüsselt wird. Es kam zum Einsatz der MITM Proxy, welcher bei dem c’t-Raspion dabei ist.&lt;br /&gt;
&lt;br /&gt;
=== Aufbau ===&lt;br /&gt;
[[File:mitm-top.png]]&lt;br /&gt;
&lt;br /&gt;
Android kann als eine Virtuelle Maschine betrieben werden, oder es kann auch ein Smart Phone benutzt werden welches die IKEA Smarthome App installiert hat. Wenn es als Virtuelle Maschine betrieben wird, ist drauf zu achten, dass der Bridge Mode benutzt wird, da dann die VM eine eigene IP erhält. Dies hat den Vorteil, dass man nur den Traffic analysieren muss, welcher von Android erzeugt wird und nicht dem des Host Systems.&lt;br /&gt;
Um den MITM benutzten zu können, müssen die Zertifikaten zu dem Key-Store hinzugefügt werden. Dies kann getan werden in dem man die Website mitm.it ansurft. Ist man in dem richtigen Netzwerk sieht man folgendes Fenster.&lt;br /&gt;
&lt;br /&gt;
[[File:mitmproxy-cert.png]]&lt;br /&gt;
Hier wählt man das richtige Betriebssystem und lädt die Zertifikate herunter.&lt;br /&gt;
&lt;br /&gt;
Die offizielle Dokumentation findet man hier[https://docs.mitmproxy.org/stable/concepts-certificates/#quick-setup].&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
Beim Starten der App kann man in Wireshark stehen, dass der Handshake für die DTLS Verbindung durchgeführt wird. &lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-dtls.png]]&lt;br /&gt;
&lt;br /&gt;
Ebenso kann man beobachten, dass mehrere Verbindungen mit verschiedenen Servern nach draußen aufgebaut werden.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-tls.png]]&lt;br /&gt;
&lt;br /&gt;
Die Nachrichten zu diesen Servern können durch den MITM entschlüsselt werden.&lt;br /&gt;
&lt;br /&gt;
[[File:mitm-sniff.png]]&lt;br /&gt;
&lt;br /&gt;
Beide Nachrichten beinhalten eine JSON-Datei. &lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;descriptionText&amp;quot;: &amp;quot;That’s why we have updated the terms and conditions. Please agree below in order to continue. You can find the updated legal information in Settings or you can read more below.&amp;quot;,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampCookie&amp;quot;: 1568799375000,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampPP&amp;quot;: 1568798738000,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampTnC&amp;quot;: 1568798786000,&lt;br /&gt;
    &amp;quot;titleText&amp;quot;: &amp;quot;We’ve changed the name of our app! &amp;quot;&lt;br /&gt;
}&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;versionCode&amp;quot;: &amp;quot;44&amp;quot;,&lt;br /&gt;
    &amp;quot;versionName&amp;quot;: &amp;quot;1.11.3&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Im debug log kann beobachtet werden, dass weitere TLS Verbindung aufgebaut werden jedoch nicht entschlüsselt werden können.&lt;br /&gt;
&lt;br /&gt;
	192.168.24.241:59332: Client Handshake failed. The client may not trust the proxy&#039;s certificate for data.logentries.com.&lt;br /&gt;
	192.168.24.241:59332: ClientHandshakeException(&#039;Cannot establish TLS with client (sni: data.logentries.com): TlsException(&amp;quot;(-1, \&#039;Unexpected EOF\&#039;)&amp;quot;)&#039;)&lt;br /&gt;
	::ffff:192.168.24.241:58971: serverdisconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
	192.168.24.241:59332: clientdisconnect&lt;br /&gt;
	::ffff:192.168.24.241:40204: serverdisconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.50&#039;, 443)&lt;br /&gt;
	192.168.24.241:58971: clientdisconnect&lt;br /&gt;
	192.168.24.241:40204: clientdisconnect&lt;br /&gt;
	192.168.24.241:41657: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:41657: Establish TLS with client&lt;br /&gt;
	192.168.24.241:50453: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:50453: serverconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.36&#039;, 443)&lt;br /&gt;
	192.168.24.241:42222: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:42222: serverconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
	::ffff:192.168.24.241:42222: Establish TLS with server&lt;br /&gt;
	::ffff:192.168.24.241:50453: Establish TLS with server&lt;br /&gt;
	::ffff:192.168.24.241:42222: ALPN selected by server: -&lt;br /&gt;
	::ffff:192.168.24.241:42222: Establish TLS with client&lt;br /&gt;
	::ffff:192.168.24.241:50453: ALPN selected by server: -&lt;br /&gt;
	::ffff:192.168.24.241:50453: Establish TLS with client&lt;br /&gt;
	::ffff:192.168.24.241:42222: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
	::ffff:192.168.24.241:50453: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
	::ffff:192.168.24.241:50453: request&lt;br /&gt;
	  -&amp;gt; Request(GET /US/en/getPolicyUpdate/?deviceType=android)&lt;br /&gt;
	::ffff:192.168.24.241:42222: request&lt;br /&gt;
	  -&amp;gt; Request(GET /AppDetails)&lt;br /&gt;
	::ffff:192.168.24.241:42222: response&lt;br /&gt;
	  -&amp;gt; Response(200 OK, application/json, 44b)&lt;br /&gt;
	::ffff:192.168.24.241:50453: response&lt;br /&gt;
	  -&amp;gt; Response(200 OK, application/json, 374b)&lt;br /&gt;
&lt;br /&gt;
Die DTLS Verbindung zwischen der App und dem Gateway, erscheint jedoch nicht in dem Log des MITM.&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-tls.png&amp;diff=3620</id>
		<title>File:Wireshark-tls.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-tls.png&amp;diff=3620"/>
		<updated>2020-05-11T14:40:01Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-dtls.png&amp;diff=3619</id>
		<title>File:Wireshark-dtls.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Wireshark-dtls.png&amp;diff=3619"/>
		<updated>2020-05-11T14:39:43Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Mitmproxy-cert.png&amp;diff=3618</id>
		<title>File:Mitmproxy-cert.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Mitmproxy-cert.png&amp;diff=3618"/>
		<updated>2020-05-11T14:39:20Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Mitm-top.png&amp;diff=3617</id>
		<title>File:Mitm-top.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Mitm-top.png&amp;diff=3617"/>
		<updated>2020-05-11T14:39:00Z</updated>

		<summary type="html">&lt;p&gt;DAmon: DAmon uploaded a new version of File:Mitm-top.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Mitm-top.png&amp;diff=3616</id>
		<title>File:Mitm-top.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Mitm-top.png&amp;diff=3616"/>
		<updated>2020-05-11T14:38:09Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:Mitm-sniff.png&amp;diff=3615</id>
		<title>File:Mitm-sniff.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:Mitm-sniff.png&amp;diff=3615"/>
		<updated>2020-05-11T14:37:49Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3614</id>
		<title>Install c&#039;t&#039;-Raspion on Raspberry PI</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3614"/>
		<updated>2020-05-11T14:33:49Z</updated>

		<summary type="html">&lt;p&gt;DAmon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
* Raspberry PI with Raspbian OS&lt;br /&gt;
* Internet connection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
=== Step 1: System Update ===&lt;br /&gt;
&lt;br /&gt;
In the command line interface enter:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Download ===&lt;br /&gt;
Download the latest version of Raspion:&lt;br /&gt;
&lt;br /&gt;
 wget ct.de/s/x5Pm -O raspion.zip &lt;br /&gt;
&lt;br /&gt;
=== Step 3: Installation ===&lt;br /&gt;
Unzip:&lt;br /&gt;
 unzip raspion.zip&lt;br /&gt;
&lt;br /&gt;
Install:&lt;br /&gt;
 cd raspion&lt;br /&gt;
 ./install.sh or bash install.sh&lt;br /&gt;
&lt;br /&gt;
[[File:Install_Raspion.png]]&lt;br /&gt;
&lt;br /&gt;
At the end of the installation there is the wifi name and password of the c&#039;t-Raspion.&lt;br /&gt;
&lt;br /&gt;
=== Launch c&#039;t-Raspion web interface ===&lt;br /&gt;
Atfer connecting to the wifi of the c&#039;t&#039;-Raspion go to http://&amp;lt;ip-address of your Raspberry-PI&amp;gt;:81&lt;br /&gt;
&lt;br /&gt;
[[File:Raspion_webinterface.png]]&lt;br /&gt;
&lt;br /&gt;
== Services of the c&#039;t-Raspion ==&lt;br /&gt;
&lt;br /&gt;
=== Pi-hole ===&lt;br /&gt;
Pi-hole shows DNS-Requests. They can also be blocked.&lt;br /&gt;
&lt;br /&gt;
[[File:pi-hole.png]]&lt;br /&gt;
&lt;br /&gt;
=== ntopng ===&lt;br /&gt;
They include the&lt;br /&gt;
involved communication partners, the network protocol and information on duration and volume. ntopng does not show the contents of the packages. But it analyses the flows and provides information about which application is communicating, such as Skype, BitTorrent etc., and provides statistics.&lt;br /&gt;
&lt;br /&gt;
=== Wireshark ===&lt;br /&gt;
Wireshark offers a deeper analysis of the network traffic as ntopng.  The program allows recording and analyzing network traffic down to the last bit and can be operated via browser as a special feature of c&#039;t-Raspion. The recorded network traffic will be saved in pcap-files.&lt;br /&gt;
 &lt;br /&gt;
=== mitmproxy ===&lt;br /&gt;
The mitm-Proxy can loop into the communication between the local and remote devices by the c&#039;t-Raspion redirecting all access from the internal network on TCP ports 80 and 443 to the mitm-Proxy. It takes the redirected accesses to port&lt;br /&gt;
8080 towards. The redirection is handled by firewall rules, which  can be activated and deactivated as required by clicking in the c&#039;t-Raspion web interface.&lt;br /&gt;
&lt;br /&gt;
== Kommunikation entschlüsseln ==&lt;br /&gt;
Bei diesem Versuch wird geschaut ob es möglich ist die Kommunikation, zwischen der IKEA App und dem IKEA Gateway mitzuhören. Nur mit einem Packet Sniffer ist dies nicht möglich, da die Kommunikation per DTLS verschlüsselt wird. Es kam zum Einsatz der MITM Proxy, welcher bei dem c’t-Raspion dabei ist.&lt;br /&gt;
&lt;br /&gt;
=== Aufbau ===&lt;br /&gt;
[[File:mitm-top]]&lt;br /&gt;
&lt;br /&gt;
Android kann als eine Virtuelle Maschine betrieben werden, oder es kann auch ein Smart Phone benutzt werden welches die IKEA Smarthome App installiert hat. Wenn es als Virtuelle Maschine betrieben wird, ist drauf zu achten, dass der Bridge Mode benutzt wird, da dann die VM eine eigene IP erhält. Dies hat den Vorteil, dass man nur den Traffic analysieren muss, welcher von Android erzeugt wird und nicht dem des Host Systems.&lt;br /&gt;
Um den MITM benutzten zu können, müssen die Zertifikaten zu dem Key-Store hinzugefügt werden. Dies kann getan werden in dem man die Website mitm.it ansurft. Ist man in dem richtigen Netzwerk sieht man folgendes Fenster.&lt;br /&gt;
&lt;br /&gt;
[[File:mitmproxy-cert]]&lt;br /&gt;
Hier wählt man das richtige Betriebssystem und lädt die Zertifikate herunter.&lt;br /&gt;
&lt;br /&gt;
Die offizielle Dokumentation findet man hier[https://docs.mitmproxy.org/stable/concepts-certificates/#quick-setup].&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
Beim Starten der App kann man in Wireshark stehen, dass der Handshake für die DTLS Verbindung durchgeführt wird. &lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-dtls]]&lt;br /&gt;
&lt;br /&gt;
Ebenso kann man beobachten, dass mehrere Verbindungen mit verschiedenen Servern nach draußen aufgebaut werden.&lt;br /&gt;
&lt;br /&gt;
[[File:wireshark-tls]]&lt;br /&gt;
&lt;br /&gt;
Die Nachrichten zu diesen Servern können durch den MITM entschlüsselt werden.&lt;br /&gt;
&lt;br /&gt;
[[File:mitm-sniff]]&lt;br /&gt;
&lt;br /&gt;
Beide Nachrichten beinhalten eine JSON-Datei. &lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;descriptionText&amp;quot;: &amp;quot;That’s why we have updated the terms and conditions. Please agree below in order to continue. You can find the updated legal information in Settings or you can read more below.&amp;quot;,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampCookie&amp;quot;: 1568799375000,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampPP&amp;quot;: 1568798738000,&lt;br /&gt;
    &amp;quot;lastUpdatedTimestampTnC&amp;quot;: 1568798786000,&lt;br /&gt;
    &amp;quot;titleText&amp;quot;: &amp;quot;We’ve changed the name of our app! &amp;quot;&lt;br /&gt;
}&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;versionCode&amp;quot;: &amp;quot;44&amp;quot;,&lt;br /&gt;
    &amp;quot;versionName&amp;quot;: &amp;quot;1.11.3&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Im debug log kann beobachtet werden, dass weitere TLS Verbindung aufgebaut werden jedoch nicht entschlüsselt werden können.&lt;br /&gt;
&lt;br /&gt;
	192.168.24.241:59332: Client Handshake failed. The client may not trust the proxy&#039;s certificate for data.logentries.com.&lt;br /&gt;
	192.168.24.241:59332: ClientHandshakeException(&#039;Cannot establish TLS with client (sni: data.logentries.com): TlsException(&amp;quot;(-1, \&#039;Unexpected EOF\&#039;)&amp;quot;)&#039;)&lt;br /&gt;
	::ffff:192.168.24.241:58971: serverdisconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
	192.168.24.241:59332: clientdisconnect&lt;br /&gt;
	::ffff:192.168.24.241:40204: serverdisconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.50&#039;, 443)&lt;br /&gt;
	192.168.24.241:58971: clientdisconnect&lt;br /&gt;
	192.168.24.241:40204: clientdisconnect&lt;br /&gt;
	192.168.24.241:41657: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:41657: Establish TLS with client&lt;br /&gt;
	192.168.24.241:50453: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:50453: serverconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.36&#039;, 443)&lt;br /&gt;
	192.168.24.241:42222: clientconnect&lt;br /&gt;
	::ffff:192.168.24.241:42222: serverconnect&lt;br /&gt;
	  -&amp;gt; (&#039;99.86.243.4&#039;, 443)&lt;br /&gt;
	::ffff:192.168.24.241:42222: Establish TLS with server&lt;br /&gt;
	::ffff:192.168.24.241:50453: Establish TLS with server&lt;br /&gt;
	::ffff:192.168.24.241:42222: ALPN selected by server: -&lt;br /&gt;
	::ffff:192.168.24.241:42222: Establish TLS with client&lt;br /&gt;
	::ffff:192.168.24.241:50453: ALPN selected by server: -&lt;br /&gt;
	::ffff:192.168.24.241:50453: Establish TLS with client&lt;br /&gt;
	::ffff:192.168.24.241:42222: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
	::ffff:192.168.24.241:50453: ALPN for client: b&#039;http/1.1&#039;&lt;br /&gt;
	::ffff:192.168.24.241:50453: request&lt;br /&gt;
	  -&amp;gt; Request(GET /US/en/getPolicyUpdate/?deviceType=android)&lt;br /&gt;
	::ffff:192.168.24.241:42222: request&lt;br /&gt;
	  -&amp;gt; Request(GET /AppDetails)&lt;br /&gt;
	::ffff:192.168.24.241:42222: response&lt;br /&gt;
	  -&amp;gt; Response(200 OK, application/json, 44b)&lt;br /&gt;
	::ffff:192.168.24.241:50453: response&lt;br /&gt;
	  -&amp;gt; Response(200 OK, application/json, 374b)&lt;br /&gt;
&lt;br /&gt;
Die DTLS Verbindung zwischen der App und dem Gateway, erscheint jedoch nicht in dem Log des MITM.&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3613</id>
		<title>Install c&#039;t&#039;-Raspion on Raspberry PI</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3613"/>
		<updated>2020-05-11T14:05:14Z</updated>

		<summary type="html">&lt;p&gt;DAmon: /* Step 3: Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
* Raspberry PI with Raspbian OS&lt;br /&gt;
* Internet connection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
=== Step 1: System Update ===&lt;br /&gt;
&lt;br /&gt;
In the command line interface enter:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Download ===&lt;br /&gt;
Download the latest version of Raspion:&lt;br /&gt;
&lt;br /&gt;
 wget ct.de/s/x5Pm -O raspion.zip &lt;br /&gt;
&lt;br /&gt;
=== Step 3: Installation ===&lt;br /&gt;
Unzip:&lt;br /&gt;
 unzip raspion.zip&lt;br /&gt;
&lt;br /&gt;
Install:&lt;br /&gt;
 cd raspion&lt;br /&gt;
 ./install.sh or bash install.sh&lt;br /&gt;
&lt;br /&gt;
[[File:Install_Raspion.png]]&lt;br /&gt;
&lt;br /&gt;
At the end of the installation there is the wifi name and password of the c&#039;t-Raspion.&lt;br /&gt;
&lt;br /&gt;
=== Launch c&#039;t-Raspion web interface ===&lt;br /&gt;
Atfer connecting to the wifi of the c&#039;t&#039;-Raspion go to http://&amp;lt;ip-address of your Raspberry-PI&amp;gt;:81&lt;br /&gt;
&lt;br /&gt;
[[File:Raspion_webinterface.png]]&lt;br /&gt;
&lt;br /&gt;
== Services of the c&#039;t-Raspion ==&lt;br /&gt;
&lt;br /&gt;
=== Pi-hole ===&lt;br /&gt;
Pi-hole shows DNS-Requests. They can also be blocked.&lt;br /&gt;
&lt;br /&gt;
[[File:pi-hole.png]]&lt;br /&gt;
&lt;br /&gt;
=== ntopng ===&lt;br /&gt;
They include the&lt;br /&gt;
involved communication partners, the network protocol and information on duration and volume. ntopng does not show the contents of the packages. But it analyses the flows and provides information about which application is communicating, such as Skype, BitTorrent etc., and provides statistics.&lt;br /&gt;
&lt;br /&gt;
=== Wireshark ===&lt;br /&gt;
Wireshark offers a deeper analysis of the network traffic as ntopng.  The program allows recording and analyzing network traffic down to the last bit and can be operated via browser as a special feature of c&#039;t-Raspion. The recorded network traffic will be saved in pcap-files.&lt;br /&gt;
 &lt;br /&gt;
=== mitmproxy ===&lt;br /&gt;
The mitm-Proxy can loop into the communication between the local and remote devices by the c&#039;t-Raspion redirecting all access from the internal network on TCP ports 80 and 443 to the mitm-Proxy. It takes the redirected accesses to port&lt;br /&gt;
8080 towards. The redirection is handled by firewall rules, which  can be activated and deactivated as required by clicking in the c&#039;t-Raspion web interface.&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3612</id>
		<title>Install c&#039;t&#039;-Raspion on Raspberry PI</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3612"/>
		<updated>2020-05-11T14:04:57Z</updated>

		<summary type="html">&lt;p&gt;DAmon: /* Launch c&amp;#039;t-Raspion web interface */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
* Raspberry PI with Raspbian OS&lt;br /&gt;
* Internet connection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
=== Step 1: System Update ===&lt;br /&gt;
&lt;br /&gt;
In the command line interface enter:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Download ===&lt;br /&gt;
Download the latest version of Raspion:&lt;br /&gt;
&lt;br /&gt;
 wget ct.de/s/x5Pm -O raspion.zip &lt;br /&gt;
&lt;br /&gt;
=== Step 3: Installation ===&lt;br /&gt;
Unzip:&lt;br /&gt;
 unzip raspion.zip&lt;br /&gt;
&lt;br /&gt;
Install:&lt;br /&gt;
 cd raspion&lt;br /&gt;
 ./install.sh or bash install.sh&lt;br /&gt;
&lt;br /&gt;
[[File:Install_Raspion.png]]&lt;br /&gt;
&lt;br /&gt;
At the end of the installation there is the wifi name and password of the c&#039;t&#039;-Raspion.&lt;br /&gt;
&lt;br /&gt;
=== Launch c&#039;t-Raspion web interface ===&lt;br /&gt;
Atfer connecting to the wifi of the c&#039;t&#039;-Raspion go to http://&amp;lt;ip-address of your Raspberry-PI&amp;gt;:81&lt;br /&gt;
&lt;br /&gt;
[[File:Raspion_webinterface.png]]&lt;br /&gt;
&lt;br /&gt;
== Services of the c&#039;t-Raspion ==&lt;br /&gt;
&lt;br /&gt;
=== Pi-hole ===&lt;br /&gt;
Pi-hole shows DNS-Requests. They can also be blocked.&lt;br /&gt;
&lt;br /&gt;
[[File:pi-hole.png]]&lt;br /&gt;
&lt;br /&gt;
=== ntopng ===&lt;br /&gt;
They include the&lt;br /&gt;
involved communication partners, the network protocol and information on duration and volume. ntopng does not show the contents of the packages. But it analyses the flows and provides information about which application is communicating, such as Skype, BitTorrent etc., and provides statistics.&lt;br /&gt;
&lt;br /&gt;
=== Wireshark ===&lt;br /&gt;
Wireshark offers a deeper analysis of the network traffic as ntopng.  The program allows recording and analyzing network traffic down to the last bit and can be operated via browser as a special feature of c&#039;t-Raspion. The recorded network traffic will be saved in pcap-files.&lt;br /&gt;
 &lt;br /&gt;
=== mitmproxy ===&lt;br /&gt;
The mitm-Proxy can loop into the communication between the local and remote devices by the c&#039;t-Raspion redirecting all access from the internal network on TCP ports 80 and 443 to the mitm-Proxy. It takes the redirected accesses to port&lt;br /&gt;
8080 towards. The redirection is handled by firewall rules, which  can be activated and deactivated as required by clicking in the c&#039;t-Raspion web interface.&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3611</id>
		<title>Install c&#039;t&#039;-Raspion on Raspberry PI</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Install_c%27t%27-Raspion_on_Raspberry_PI&amp;diff=3611"/>
		<updated>2020-05-11T14:04:04Z</updated>

		<summary type="html">&lt;p&gt;DAmon: /* Services of the c&amp;#039;t-Raspion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
* Raspberry PI with Raspbian OS&lt;br /&gt;
* Internet connection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
=== Step 1: System Update ===&lt;br /&gt;
&lt;br /&gt;
In the command line interface enter:&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Download ===&lt;br /&gt;
Download the latest version of Raspion:&lt;br /&gt;
&lt;br /&gt;
 wget ct.de/s/x5Pm -O raspion.zip &lt;br /&gt;
&lt;br /&gt;
=== Step 3: Installation ===&lt;br /&gt;
Unzip:&lt;br /&gt;
 unzip raspion.zip&lt;br /&gt;
&lt;br /&gt;
Install:&lt;br /&gt;
 cd raspion&lt;br /&gt;
 ./install.sh or bash install.sh&lt;br /&gt;
&lt;br /&gt;
[[File:Install_Raspion.png]]&lt;br /&gt;
&lt;br /&gt;
At the end of the installation there is the wifi name and password of the c&#039;t&#039;-Raspion.&lt;br /&gt;
&lt;br /&gt;
=== Launch c&#039;t&#039;-Raspion web interface ===&lt;br /&gt;
Atfer connecting to the wifi of the c&#039;t&#039;-Raspion go to http://&amp;lt;ip-address of your Raspberry-PI&amp;gt;:81&lt;br /&gt;
&lt;br /&gt;
[[File:Raspion_webinterface.png]]&lt;br /&gt;
&lt;br /&gt;
== Services of the c&#039;t-Raspion ==&lt;br /&gt;
&lt;br /&gt;
=== Pi-hole ===&lt;br /&gt;
Pi-hole shows DNS-Requests. They can also be blocked.&lt;br /&gt;
&lt;br /&gt;
[[File:pi-hole.png]]&lt;br /&gt;
&lt;br /&gt;
=== ntopng ===&lt;br /&gt;
They include the&lt;br /&gt;
involved communication partners, the network protocol and information on duration and volume. ntopng does not show the contents of the packages. But it analyses the flows and provides information about which application is communicating, such as Skype, BitTorrent etc., and provides statistics.&lt;br /&gt;
&lt;br /&gt;
=== Wireshark ===&lt;br /&gt;
Wireshark offers a deeper analysis of the network traffic as ntopng.  The program allows recording and analyzing network traffic down to the last bit and can be operated via browser as a special feature of c&#039;t-Raspion. The recorded network traffic will be saved in pcap-files.&lt;br /&gt;
 &lt;br /&gt;
=== mitmproxy ===&lt;br /&gt;
The mitm-Proxy can loop into the communication between the local and remote devices by the c&#039;t-Raspion redirecting all access from the internal network on TCP ports 80 and 443 to the mitm-Proxy. It takes the redirected accesses to port&lt;br /&gt;
8080 towards. The redirection is handled by firewall rules, which  can be activated and deactivated as required by clicking in the c&#039;t-Raspion web interface.&lt;/div&gt;</summary>
		<author><name>DAmon</name></author>
	</entry>
</feed>