Skip to content

Commit

Permalink
Introduce to Costura.Fody to embed dlls inside exe on release.
Browse files Browse the repository at this point in the history
+ Improve parts of the GUI and tabs order.
+ Add also ConfigureAwait package for async await. Might be used later.
+ Update README.
  • Loading branch information
giladreich committed Jun 16, 2018
1 parent 6c70f12 commit 0f023fc
Show file tree
Hide file tree
Showing 46 changed files with 287 additions and 67 deletions.
58 changes: 16 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# IHK Results Notifier

Simple tool to notify the user whenever the results of the IHK exams has been update on official website.
A simple tool to notify you whenever the results on the official website of the IHK exams has been updated.
When the new results are available, the tool will make a sound and will bring it on top of all windows so you'll notice the new results.


### Login Interface
Expand All @@ -10,27 +11,26 @@ Simple tool to notify the user whenever the results of the IHK exams has been up

### Main Window Interface

![Main Window Interface](/pictures/main_window.png)
![Main Window Interface1](/pictures/main_window1.png)
![Main Window Interface2](/pictures/main_window2.png)
![Main Window Interface3](/pictures/main_window3.png)





# The Cookies Trick For Authenticating A User




# The Cookies Trick For Authenticating User

## Steps to reproduce
## Steps To Reproduce

#### Description:

Before posting the login form, we need 2 cookies that the login pages automatically creates us.
If the credentials we send as post request to the server are correct, the server will respond with a new session key
that will replace the session key we got from the BB_auszubildende.jsp.
The server will identify that we are logged in with new session key that we got as response from the login and from the favicon.ico.
The following steps shows how it works:
Before posting the login form, we need 2 cookies that the login pages automatically creates for us.
If the credentials we send to the server as a POST request are correct or accepted by the server, the server will identify us and respond with a new session key
that will replace the session key that we got from the `BB_auszubildende.jsp` page.
With the new cookie/session-key + the session-key from the `favicon.ico`, we can access user-specific/private pages.

The following steps will show how it works using curl:


// We send the first request to get the first cookie:
Expand All @@ -53,38 +53,12 @@ curl -v -X POST "https://apps.ihk-berlin.de/tibrosBB/azubiHome.jsp" -H "Cookie:
curl "https://apps.ihk-berlin.de/tibrosBB/azubiPruef.jsp" -H "Cookie: TSESSIONID=replacemeSession3; TSESSIONID=replacemeSession2"
```

// IMPORTANT NOTE: Jumping directly to this link won't work, you must first visit the link before with the same session keys.

// Get the last link with the exam results:
// NOTE: Jumping directly to this link won't work, you must first visit the link before with the same session keys.
```sh
curl "https://apps.ihk-berlin.de/tibrosBB/azubiErgebnisse.jsp?id=1" -H "Cookie: TSESSIONID=replacemeSession3; TSESSIONID=replacemeSession2"
```

#### Full requests detailed

// Gets the first cookie
```sh
curl -I "https://apps.ihk-berlin.de/tibrosBB/BB_auszubildende.jsp" -H "Connection: keep-alive" -H "Upgrade-Insecure-Requests: 1" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" -H "Accept-Encoding: gzip, deflate, br" -H "Accept-Language: en,en-US;q=0.9,de-DE;q=0.8,de;q=0.7,he;q=0.6"
```

// Gets the second cookie
```sh
curl -I "https://apps.ihk-berlin.de/favicon.ico" -H "Accept: image/webp,image/apng,image/*,*/*;q=0.8" -H "Connection: keep-alive" -H "Accept-Encoding: gzip, deflate, br" -H "Referer: https://apps.ihk-berlin.de/tibrosBB/BB_auszubildende.jsp" -H "Accept-Language: en,en-US;q=0.9,de-DE;q=0.8,de;q=0.7,he;q=0.6" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36"
```

// Posts the login data with the 2 cookies created from before:
```sh
curl -v -X POST "https://apps.ihk-berlin.de/tibrosBB/azubiHome.jsp" -H "Connection: keep-alive" -H "Cache-Control: max-age=0" -H "Origin: https://apps.ihk-berlin.de" -H "Upgrade-Insecure-Requests: 1" -H "Content-Type: application/x-www-form-urlencoded" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" -H "Referer: https://apps.ihk-berlin.de/tibrosBB/BB_auszubildende.jsp" -H "Accept-Encoding: gzip, deflate, br" -H "Accept-Language: en,en-US;q=0.9,de-DE;q=0.8,de;q=0.7,he;q=0.6" -H "Cookie: TSESSIONID=replacemeSession1; TSESSIONID=replacemeSession2" --data "login=replacemeUser&pass=replacemePass&anmelden="
```

// Using the login authentication:
```sh
curl -v "https://apps.ihk-berlin.de/tibrosBB/azubiPruef.jsp" -H "Connection: keep-alive" -H "Upgrade-Insecure-Requests: 1" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" -H "Referer: https://apps.ihk-berlin.de/tibrosBB/azubiHome.jsp" -H "Accept-Encoding: gzip, deflate, br" -H "Accept-Language: en,en-US;q=0.9,de-DE;q=0.8,de;q=0.7,he;q=0.6" -H "Cookie: TSESSIONID=replacemeSession3; TSESSIONID=replacemeSession2"
```

// Results website
```sh
curl -v "https://apps.ihk-berlin.de/tibrosBB/azubiErgebnisse.jsp?id=1" -H "Connection: keep-alive" -H "Upgrade-Insecure-Requests: 1" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" -H "Referer: https://apps.ihk-berlin.de/tibrosBB/azubiPruef.jsp" -H "Accept-Encoding: gzip, deflate, br" -H "Accept-Language: en,en-US;q=0.9,de-DE;q=0.8,de;q=0.7,he;q=0.6" -H "Cookie: TSESSIONID=replacemeSession3; TSESSIONID=replacemeSession2"
```


Note that this can be easily done by creating a cookie jar: `curl --cookie-jar` or `curl -c`, but to have a better understanding I show the requests commands the manual way.

Binary file removed pictures/main_window.png
Binary file not shown.
Binary file added pictures/main_window1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pictures/main_window2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pictures/main_window3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
5 changes: 5 additions & 0 deletions src/IHK.ResultsNotifier/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers>
<Costura />
<ConfigureAwait />
</Weavers>
23 changes: 20 additions & 3 deletions src/IHK.ResultsNotifier/IHK.ResultsNotifier.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -32,10 +34,15 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>
</ApplicationIcon>
<ApplicationIcon>AppIcon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="ConfigureAwait, Version=2.1.0.0, Culture=neutral, PublicKeyToken=233850a516558a98, processorArchitecture=MSIL">
<HintPath>..\packages\ConfigureAwait.Fody.2.1.0\lib\net452\ConfigureAwait.dll</HintPath>
</Reference>
<Reference Include="Costura, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.2.0.0\lib\net452\Costura.dll</HintPath>
</Reference>
<Reference Include="CustomUI">
<HintPath>..\packages\CustomUI-1.0.5\CustomUI.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -123,8 +130,18 @@
<None Include="Resources\LogoIHK.png" />
</ItemGroup>
<ItemGroup>
<Content Include="Resources\AppIcon.ico" />
<Content Include="AppIcon.ico" />
<Content Include="FodyWeavers.xml" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Costura.Fody.2.0.0\build\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.2.0.0\build\Costura.Fody.targets'))" />
<Error Condition="!Exists('..\packages\Fody.3.0.3\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.3.0.3\build\Fody.targets'))" />
</Target>
<Import Project="..\packages\Costura.Fody.2.0.0\build\Costura.Fody.targets" Condition="'$(Configuration)' == 'Release' and Exists('..\packages\Costura.Fody.2.0.0\build\Costura.Fody.targets')" />
<Import Project="..\packages\Fody.3.0.3\build\Fody.targets" Condition="Exists('..\packages\Fody.3.0.3\build\Fody.targets')" />
</Project>
2 changes: 1 addition & 1 deletion src/IHK.ResultsNotifier/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("IHK ResultsNotifier")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyCopyright("Reich Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
2 changes: 1 addition & 1 deletion src/IHK.ResultsNotifier/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="AppIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\appicon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<value>..\appicon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="LogoIHK" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\LogoIHK.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
Expand Down
43 changes: 23 additions & 20 deletions src/IHK.ResultsNotifier/Windows/MainWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/IHK.ResultsNotifier/Windows/MainWindow.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Media;
using System.Windows.Forms;
Expand Down Expand Up @@ -75,12 +76,14 @@ private void btnStartStop_Click(object sender, EventArgs e)
{
if (btnStartStop.IsActivated)
{
tbxMinutes.Enabled = false;
Log("Starting listening for new results...");
Log($"Request to update results will be sent to the server every {tbxMinutes.Text} minutes.");
worker = new Worker(StartListening).Start();
}
else
{
tbxMinutes.Enabled = true;
Log("Stopping listening for results...");
worker.Stop();
}
Expand Down
3 changes: 3 additions & 0 deletions src/IHK.ResultsNotifier/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ConfigureAwait.Fody" version="2.1.0" targetFramework="net461" />
<package id="Costura.Fody" version="2.0.0" targetFramework="net461" />
<package id="Fody" version="3.0.3" targetFramework="net461" developmentDependency="true" />
<package id="HtmlAgilityPack" version="1.8.4" targetFramework="net461" />
</packages>
Binary file not shown.
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 0f023fc

Please sign in to comment.