Compare commits

..

No commits in common. 'main' and 'devel_freefall' have entirely different histories.

  1. 10
      ASYD_Cryptograhpy/ASYD_Cryptograhpy.sln
  2. 0
      ASYD_Cryptograhpy/SW04-DSA/assignment/ass03_ArnoldJonas_EstermannBasil_FreiSimon.zip
  3. 0
      ASYD_Cryptograhpy/SW04-DSA/assignment/ass03_ArnoldJonas_EstermannBasil_FreiSimon/C/DSA.c
  4. 0
      ASYD_Cryptograhpy/SW04-DSA/assignment/ass03_ArnoldJonas_EstermannBasil_FreiSimon/C/DSA.h
  5. 0
      ASYD_Cryptograhpy/SW04-DSA/assignment/ass03_ArnoldJonas_EstermannBasil_FreiSimon/C/encryptionArithmetic.c
  6. 0
      ASYD_Cryptograhpy/SW04-DSA/assignment/ass03_ArnoldJonas_EstermannBasil_FreiSimon/C/encryptionArithmetic.h
  7. 0
      ASYD_Cryptograhpy/SW04-DSA/assignment/ass03_ArnoldJonas_EstermannBasil_FreiSimon/C/main.c
  8. 0
      ASYD_Cryptograhpy/SW04-DSA/assignment/ass03_ArnoldJonas_EstermannBasil_FreiSimon/Python/DSA.py
  9. 135
      ASYD_Cryptograhpy/SW05-SHA1/SW05-SHA1.vcxproj
  10. 22
      ASYD_Cryptograhpy/SW05-SHA1/SW05-SHA1.vcxproj.filters
  11. 216
      ASYD_Cryptograhpy/SW05-SHA1/assignment/ass05_ArnoldJonas_EstermannBasil_FreiSimon.c
  12. 11
      ASYD_Cryptograhpy/SW05-SHA1/assignment/ass05_ArnoldJonas_EstermannBasil_FreiSimon.txt
  13. 4
      ASYD_Cryptograhpy/SW05-SHA1/assignment/ass05_ArnoldJonas_EstermannBasil_FreiSimon_SHA1.cip
  14. 216
      ASYD_Cryptograhpy/SW05-SHA1/main.c
  15. 3
      ASYD_Docker/README.md
  16. 37
      ASYD_Docker/docker-01/01-demo/Dockerfile
  17. 5
      ASYD_Docker/docker-01/01-demo/build.sh
  18. 8
      ASYD_Docker/docker-01/01-demo/src/ASYD_Demo.csproj
  19. 39
      ASYD_Docker/docker-01/01-demo/src/Program.cs
  20. 13
      ASYD_Docker/docker-02/123deb/solution.md
  21. 34
      ASYD_Docker/docker-02/vol_host/solution.md
  22. 23
      ASYD_Docker/docker-02/vol_named/solution.md
  23. 19
      ASYD_Docker/docker-02/webcp/build.sh
  24. 8
      ASYD_Docker/docker-02/webcp/index.html
  25. 11
      ASYD_Docker/docker-02/webimg/README.txt
  26. 40
      ASYD_Docker/docker-02/webimg/build.sh
  27. 6
      ASYD_Docker/docker-02/webimg/index.html
  28. 6
      ASYD_Docker/docker-03/chello-world/Dockerfile
  29. 23
      ASYD_Docker/docker-03/chello-world/build.sh
  30. BIN
      ASYD_Docker/docker-03/chello-world/hello-world
  31. 6
      ASYD_Docker/docker-03/chello-world/hello-world.c
  32. 4
      ASYD_Docker/docker-03/debcp_v1/Dockerfile
  33. 17
      ASYD_Docker/docker-03/debcp_v1/build.sh
  34. 1
      ASYD_Docker/docker-03/debcp_v1/greetings.txt
  35. 3
      ASYD_Docker/docker-03/debcp_v2/Dockerfile
  36. 17
      ASYD_Docker/docker-03/debcp_v2/build.sh
  37. 3
      ASYD_Docker/docker-03/debcp_v3/Dockerfile
  38. 17
      ASYD_Docker/docker-03/debcp_v3/build.sh
  39. 3
      ASYD_Docker/docker-03/debcp_v3/debcp_v2/Dockerfile
  40. 17
      ASYD_Docker/docker-03/debcp_v3/debcp_v2/build.sh
  41. 8
      ASYD_Docker/docker-03/debcp_v4/Dockerfile
  42. 7
      ASYD_Docker/docker-03/debcp_v4/build.sh
  43. 1
      ASYD_Docker/docker-03/debcp_v4/greetings.txt
  44. 6
      ASYD_Docker/docker-03/debcp_v5/Dockerfile
  45. 20
      ASYD_Docker/docker-03/debcp_v5/build.sh
  46. 17
      ASYD_Docker/docker-03/debcptmp/build.sh
  47. 4
      ASYD_Docker/docker-03/debcptmp/context/Dockerfile
  48. 1
      ASYD_Docker/docker-03/debcptmp/context/greetings.txt
  49. 6
      ASYD_Docker/docker-03/myhelloworld/Dockerfile
  50. BIN
      ASYD_Docker/docker-03/myhelloworld/hello-world
  51. 11
      ASYD_Docker/docker-03/myweb_v1/README.txt
  52. 34
      ASYD_Docker/docker-03/myweb_v1/build.sh
  53. 6
      ASYD_Docker/docker-03/myweb_v1/index.html
  54. 5
      ASYD_Docker/docker-03/myweb_v2/Dockerfile
  55. 3
      ASYD_Docker/docker-03/myweb_v2/build.sh
  56. 6
      ASYD_Docker/docker-03/myweb_v2/index.html
  57. 5
      ASYD_Docker/docker-03/nanodeb_v1/Dockerfile
  58. 3
      ASYD_Docker/docker-03/nanodeb_v1/build.sh
  59. 7
      ASYD_Docker/docker-03/nanodeb_v2/Dockerfile
  60. 3
      ASYD_Docker/docker-03/nanodeb_v2/build.sh
  61. 8
      ASYD_Docker/docker-03/nanodeb_v3/Dockerfile
  62. 3
      ASYD_Docker/docker-03/nanodeb_v3/build.sh
  63. 9
      ASYD_Docker/docker-03/nanodeb_v4/Dockerfile
  64. 3
      ASYD_Docker/docker-03/nanodeb_v4/build.sh
  65. 10
      ASYD_Docker/docker-03/nanodeb_v5/Dockerfile
  66. 3
      ASYD_Docker/docker-03/nanodeb_v5/build.sh
  67. 4
      ASYD_Docker/docker-03/scratch/Dockerfile
  68. 5
      ASYD_Docker/docker-03/scratch/build.sh
  69. BIN
      ASYD_Docker/docker-03/scratch/hello-world1
  70. BIN
      ASYD_Docker/docker-03/scratch/hello-world2
  71. 15
      ASYD_Docker/docker-03/web/build.sh
  72. 6
      ASYD_Docker/docker-03/web/index.html
  73. 10
      ASYD_Docker/docker-04/compose/netcat_server/Dockerfile
  74. 6
      ASYD_Docker/docker-04/compose/netcat_server/build.sh
  75. 10
      ASYD_Docker/docker-04/compose/netcat_server/docker-compose.yml
  76. 3
      ASYD_Docker/docker-04/compose/netcat_server/start_cmd.sh
  77. 79
      ASYD_Docker/docker-04/compose/nginx-golang/README.md
  78. 11
      ASYD_Docker/docker-04/compose/nginx-golang/backend/Dockerfile
  79. 30
      ASYD_Docker/docker-04/compose/nginx-golang/backend/main.go
  80. 9
      ASYD_Docker/docker-04/compose/nginx-golang/docker-compose.yml
  81. 4
      ASYD_Docker/docker-04/compose/nginx-golang/frontend/Dockerfile
  82. 6
      ASYD_Docker/docker-04/compose/nginx-golang/frontend/nginx.conf
  83. 32
      ASYD_Docker/docker-04/compose/wordpress-beispiel/docker-compose.yml
  84. 3
      ASYD_Docker/docker-04/dangling/Dockerfile
  85. 4
      ASYD_Docker/docker-04/dangling/Dockerfile.v1
  86. 4
      ASYD_Docker/docker-04/dangling/Dockerfile.v2
  87. 24
      ASYD_Docker/docker-04/dangling/build.sh
  88. 15
      ASYD_Docker/docker-04/ex_00_multistage_alpine_musl/Dockerfile
  89. 11
      ASYD_Docker/docker-04/ex_00_multistage_alpine_musl/build.sh
  90. BIN
      ASYD_Docker/docker-04/ex_00_multistage_alpine_musl/hello-world
  91. 6
      ASYD_Docker/docker-04/ex_00_multistage_alpine_musl/hello-world.c
  92. 13
      ASYD_Docker/docker-04/ex_01_csharp_interactive/solution.txt
  93. 8
      ASYD_Docker/docker-04/ex_01_csharp_interactive/src/ConsoleApp1.csproj
  94. 12
      ASYD_Docker/docker-04/ex_01_csharp_interactive/src/Program.cs
  95. 11
      ASYD_Docker/docker-04/ex_02_csharp_singlestage/Dockerfile
  96. 10
      ASYD_Docker/docker-04/ex_02_csharp_singlestage/build.sh
  97. 8
      ASYD_Docker/docker-04/ex_02_csharp_singlestage/src/ConsoleApp1.csproj
  98. 12
      ASYD_Docker/docker-04/ex_02_csharp_singlestage/src/Program.cs
  99. 23
      ASYD_Docker/docker-04/ex_03_csharp_multistage/Dockerfile
  100. 11
      ASYD_Docker/docker-04/ex_03_csharp_multistage/build.sh
  101. Some files were not shown because too many files have changed in this diff Show More

@ -11,8 +11,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SW03-DHKE", "SW03-DHKE\SW03
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SW04-DSA", "SW04-DSA\SW04-DSA.vcxproj", "{737511B3-89A4-41CD-A680-EE8CC74C60FA}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SW04-DSA", "SW04-DSA\SW04-DSA.vcxproj", "{737511B3-89A4-41CD-A680-EE8CC74C60FA}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SW05-SHA1", "SW05-SHA1\SW05-SHA1.vcxproj", "{4F23BA48-5E70-4FBB-A131-26176C695776}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
@ -53,14 +51,6 @@ Global
{737511B3-89A4-41CD-A680-EE8CC74C60FA}.Release|x64.Build.0 = Release|x64 {737511B3-89A4-41CD-A680-EE8CC74C60FA}.Release|x64.Build.0 = Release|x64
{737511B3-89A4-41CD-A680-EE8CC74C60FA}.Release|x86.ActiveCfg = Release|Win32 {737511B3-89A4-41CD-A680-EE8CC74C60FA}.Release|x86.ActiveCfg = Release|Win32
{737511B3-89A4-41CD-A680-EE8CC74C60FA}.Release|x86.Build.0 = Release|Win32 {737511B3-89A4-41CD-A680-EE8CC74C60FA}.Release|x86.Build.0 = Release|Win32
{4F23BA48-5E70-4FBB-A131-26176C695776}.Debug|x64.ActiveCfg = Debug|x64
{4F23BA48-5E70-4FBB-A131-26176C695776}.Debug|x64.Build.0 = Debug|x64
{4F23BA48-5E70-4FBB-A131-26176C695776}.Debug|x86.ActiveCfg = Debug|Win32
{4F23BA48-5E70-4FBB-A131-26176C695776}.Debug|x86.Build.0 = Debug|Win32
{4F23BA48-5E70-4FBB-A131-26176C695776}.Release|x64.ActiveCfg = Release|x64
{4F23BA48-5E70-4FBB-A131-26176C695776}.Release|x64.Build.0 = Release|x64
{4F23BA48-5E70-4FBB-A131-26176C695776}.Release|x86.ActiveCfg = Release|Win32
{4F23BA48-5E70-4FBB-A131-26176C695776}.Release|x86.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -1,135 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.c" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{4f23ba48-5e70-4fbb-a131-26176c695776}</ProjectGuid>
<RootNamespace>SW05SHA1</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

@ -1,216 +0,0 @@
/**
*--------------------------------------------------------------------\n
* HSLU T&A Hochschule Luzern Technik+Architektur \n
*--------------------------------------------------------------------\n
*
* \brief ASYD assignment crypto 05
* \file
* \author Basil Estermann, basil.estermann@stud.hslu.ch
* Simon Frei, simon.frei@stud.hslu.ch
* Jonas Arnold, jonas.arnold@stud.hslu.ch
* \date 23.03.2023
*
*--------------------------------------------------------------------
*/
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#define VALUE_LENGTH 32
#define MESSAGE_DIGEST_LENGTH 160
#define BLOCK_LENGTH (512/8)
#define INPUT_MESSAGE ("Lorem ipsum dolor sit amet, consetetur sadipscing.")
#pragma region Macros
#define INT_64_LOW_BYTE(input) (input & 0xff)
#define INT_64_HIGH_BYTE(input) ((input>>8) & 0xff)
#pragma endregion
#pragma region SHA1-Constants
// initial hash values
#define H0 0x67452301
#define H1 0xEFCDAB89
#define H2 0x98BADCFE
#define H3 0x10325476
#define H4 0xC3D2E1F0
// constants Kt
#define K1 0x5A827999
#define K2 0x6ED9EBA1
#define K3 0x8F1BBCDC
#define K4 0xCA62C1D6
#pragma endregion
void printBits(size_t const size, void const* const ptr);
uint32_t leftRotate(uint32_t n, uint32_t d);
uint32_t SHA1_f1(uint32_t b, uint32_t c, uint32_t d);
uint32_t SHA1_f2(uint32_t b, uint32_t c, uint32_t d);
uint32_t SHA1_f3(uint32_t b, uint32_t c, uint32_t d);
uint32_t SHA1_f4(uint32_t b, uint32_t c, uint32_t d);
void main(void) {
int result = 0;
printf("****** SHA1 preprocessing ******\n\n");
#pragma region Preprocessing
printf("------ Set initial hash value ------\n\n");
#pragma region Initial Hash values
uint32_t a, b, c, d, e;
uint32_t h[5] = { H0, H1, H2, H3, H4 };
uint32_t k[5] = { 0, K1, K2, K3, K4 }; // 5 so the array can be accessed by 1, 2, 3, 4
a = h[0];
b = h[1];
c = h[2];
d = h[3];
e = h[4];
#pragma endregion
if (sizeof(INPUT_MESSAGE) * 8 > 447) {
printf("Message too long!");
return 1000002;
}
printf("------ Padding message ------\n\n");
#pragma region Padding
// print information about message without padding
unsigned char messageNoPadding[] = INPUT_MESSAGE;
int numBytesMessage = (sizeof(INPUT_MESSAGE) - 1); // -1 because of '\0' at end of the string
printf("Size of message without padding: %i bits\n", numBytesMessage*8);
printf("Message without padding\n");
printBits(sizeof(messageNoPadding), &messageNoPadding);
unsigned char message[BLOCK_LENGTH] = "";
// fill in message
for (uint32_t i = 0; i < numBytesMessage; i++)
{
message[i] = INPUT_MESSAGE[i];
}
// set bit
message[numBytesMessage] = 0b10000000;
printf("\nMessage after adding 1: \n");
printBits(sizeof(message), &message);
// add length with high and low byte (length is 64bit)
message[BLOCK_LENGTH - 1] = INT_64_LOW_BYTE(numBytesMessage * 8);
message[BLOCK_LENGTH - 2] = INT_64_HIGH_BYTE(numBytesMessage * 8);
printf("\nMessage after adding length: \n");
printBits(sizeof(message), &message);
#pragma endregion
#pragma endregion
printf("\n\n****** Hash computation ******\n\n");
#pragma region Hash computation
printf("\n------ Prepare message schedule ------\n\n");
#pragma region Prepare message schedule
uint32_t WordArray[80] = { 0 };
for (uint32_t i = 0; i < 16; i++) {
uint32_t currentbyte = message[i] << 24;
uint32_t tmp = (uint32_t)(((uint8_t)(message[i * 4]) << 24) + ((uint8_t)(message[4 * i + 1]) << 16) + ((uint8_t)(message[4 * i + 2]) << 8) + (uint8_t)(message[4 * i + 3]));
WordArray[i] = tmp;
}
for (uint32_t i = 16; i < 80; i++) {
WordArray[i] = leftRotate((WordArray[i - 3] ^ WordArray[i - 8] ^ WordArray[i - 14] ^ WordArray[i - 16]), 1);
}
#pragma endregion
printf("\n------ Stages ------\n\n");
#pragma region Stages calculations
uint32_t (*f_ptr)(uint32_t, uint32_t, uint32_t) = &SHA1_f1; // use: (*f_ptr)(b,c,d);
uint8_t stage = 1;
// print header row
printf("\tA\t\tB\t\tC\t\tD\t\tE\n");
// stage 1...4
for (uint32_t t = 0; t < 80; t++) {
uint32_t T = leftRotate(a, 5) + ((*f_ptr)(b, c, d)) + e + k[stage] + WordArray[t];
e = d;
d = c;
c = leftRotate(b, 30);
b = a;
a = T;
// print row
printf("t= %02d:\t%08X\t%08X\t%08X\t%08X\t%08X\t\n", t, a, b, c, d, e);
// switch stages
if (t == 19) { f_ptr = SHA1_f2; stage = 2; printf("Switched to stage 2.\n"); }
else if (t == 39) { f_ptr = SHA1_f3; stage = 3; printf("Switched to stage 3.\n"); }
else if (t == 59) { f_ptr = SHA1_f4; stage = 4; printf("Switched to stage 4.\n"); }
}
#pragma endregion
printf("\n------ Intermediate hash calculation ------\n\n");
#pragma region intermediate hash calculation
uint32_t summand[5] = { a, b, c, d, e };
for (uint8_t i = 0; i < 5; i++) {
// calculate
uint32_t h_new = summand[i] + h[i];
// print
printf("H[%i] = %08X + %08X = %08X\n", i, summand[i], h[i], h_new);
// set value
h[i] = h_new;
}
#pragma endregion
#pragma endregion
printf("\n****** Resulting hash ******\n\n");
for (uint8_t i = 0; i < 5; i++) {
printf("%X ", h[i]);
}
printf("\n\n");
return 0;
}
uint32_t SHA1_f1(uint32_t b, uint32_t c, uint32_t d) {
return (b & c) | (~b & d);
}
uint32_t SHA1_f2(uint32_t b, uint32_t c, uint32_t d) {
return b ^ c ^ d;
}
uint32_t SHA1_f3(uint32_t b, uint32_t c, uint32_t d) {
return (b & c) | (b & d) | (c & d);
}
uint32_t SHA1_f4(uint32_t b, uint32_t c, uint32_t d) {
return b ^ c ^ d;
}
uint32_t leftRotate(uint32_t n, uint32_t d)
{
/* In n<<d, last d bits are 0. To put first 3 bits of n at
last, do bitwise or of n<<d with n >>(INT_BITS - d) */
return (n << d) | (n >> (VALUE_LENGTH - d));
}
// Assumes little endian
void printBits(size_t const size, void const* const ptr)
{
unsigned char* b = (unsigned char*)ptr;
unsigned char byte;
int i, j;
for (i = 0; i < size; i++) {
for (j = 7; j >= 0; j--) {
byte = (b[i] >> j) & 1;
printf("%u", byte);
}
}
/*original:
for (i = size - 1; i >= 0; i--) {
for (j = 7; j >= 0; j--) {
byte = (b[i] >> j) & 1;
printf("%u", byte);
}
}*/
puts("");
}

@ -1,11 +0,0 @@
Assignment crypto 05
Gruppenmitglieder: Basil Estermann, Jonas Arnold, Simon Frei
Wir konnten erfolgreich einen SHA-1 Hash Generator implementieren. Wie vorgesehen lässt sich der SHA-1 mit den verhältnismässig kleinen Zahlen (32bit) gut implementieren, auch beispielsweise auf Embedded Systemen mit der Programmiersprache C.
Bei der Implementierung haben wir uns hauptsächlich auf das Dokument der NIST gestützt. Das Preprocessing bzw. Padding der Nachricht haben wir gemäss Abschnitt 5.1.1. implementiert. Aktuell kann unser Programm nur den Hash von eine Nachricht (1 Block a 512bit, mit Padding also maxima 447bit für Nachricht bzw. 55 ASCII Zeichen) berechnen. Dies wäre einfach erweiterbar gemäss Abschnitt 5.2.1. Die Hash Berechnung, welche wir anhand Abschnitt 6.1.2 implementiert haben, müsste ebenfalls um eine for-schleife von "i=1 bis N" erweitert werden.
Verifiziert haben wir unseren Generator einerseits mit den hilfreichen SHA1_DebugHelp.pdf von ILIAS. Damit war einfach nachvollziehbar wo unser Programm falsch rechnet. Ausserdem haben wir einen online SHA-1 Generator (http://www.sha1-online.com/) verwendet, um weitere Nachrichten zu testen.
Mithilfe dieser Verifikation war es möglich den Algorithmus zum Laufen zu bringen. Ein Prolglem bei der Implementierung war, dass wir erst den String-Ende Indikator ('\0') auch in den Hash integriert hatten, was dann zu anderen Hashes geführt hat als z.B. dem online SHA-1 Generator. Dieses Problem konnte jedoch rasch behoben werden, indem das '\0' einfach nicht miteinbezogen wird.
Beim Testen vom Hash einer Gruppen auf Ilias mussten wir jedoch feststellen, dass unser SHA-1 Generator nur bis zu einer Nachrichtengrösse von 32 Zeichen funktioniert. Der Grund dafür war, dass wir lediglich das Low-Byte der Länge der Nachricht in das Padding der Nachricht integriert hatten. Nachdem wir auch das High-Byte integrierten (nun also volle 64bit für die Länge der Nachricht am Ende des Message Blocks) konnten wir den SHA-1 Hash der anderen Gruppe OdermattStefan/PfrennigerDavid auch erfolgreich generieren.
Leider war zum Zeitpunkt dieses Berichts auch nur ein einziges Testfile einer anderen Gruppe im Austausch-Ordner.

@ -1,4 +0,0 @@
Message:
Lorem ipsum dolor sit amet, consetetur sadipscing.
Hash:
95A2B0D2 1278E3CB EF1D6F24 59366764 D0648AA7

@ -1,216 +0,0 @@
/**
*--------------------------------------------------------------------\n
* HSLU T&A Hochschule Luzern Technik+Architektur \n
*--------------------------------------------------------------------\n
*
* \brief ASYD assignment crypto 05
* \file
* \author Basil Estermann, basil.estermann@stud.hslu.ch
* Simon Frei, simon.frei@stud.hslu.ch
* Jonas Arnold, jonas.arnold@stud.hslu.ch
* \date 23.03.2023
*
*--------------------------------------------------------------------
*/
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#define VALUE_LENGTH 32
#define MESSAGE_DIGEST_LENGTH 160
#define BLOCK_LENGTH (512/8)
#define INPUT_MESSAGE ("Lorem ipsum dolor sit amet, consetetur sadipscing.")
#pragma region Macros
#define INT_64_LOW_BYTE(input) (input & 0xff)
#define INT_64_HIGH_BYTE(input) ((input>>8) & 0xff)
#pragma endregion
#pragma region SHA1-Constants
// initial hash values
#define H0 0x67452301
#define H1 0xEFCDAB89
#define H2 0x98BADCFE
#define H3 0x10325476
#define H4 0xC3D2E1F0
// constants Kt
#define K1 0x5A827999
#define K2 0x6ED9EBA1
#define K3 0x8F1BBCDC
#define K4 0xCA62C1D6
#pragma endregion
void printBits(size_t const size, void const* const ptr);
uint32_t leftRotate(uint32_t n, uint32_t d);
uint32_t SHA1_f1(uint32_t b, uint32_t c, uint32_t d);
uint32_t SHA1_f2(uint32_t b, uint32_t c, uint32_t d);
uint32_t SHA1_f3(uint32_t b, uint32_t c, uint32_t d);
uint32_t SHA1_f4(uint32_t b, uint32_t c, uint32_t d);
void main(void) {
int result = 0;
printf("****** SHA1 preprocessing ******\n\n");
#pragma region Preprocessing
printf("------ Set initial hash value ------\n\n");
#pragma region Initial Hash values
uint32_t a, b, c, d, e;
uint32_t h[5] = { H0, H1, H2, H3, H4 };
uint32_t k[5] = { 0, K1, K2, K3, K4 }; // 5 so the array can be accessed by 1, 2, 3, 4
a = h[0];
b = h[1];
c = h[2];
d = h[3];
e = h[4];
#pragma endregion
if (sizeof(INPUT_MESSAGE) * 8 > 447) {
printf("Message too long!");
return 1000002;
}
printf("------ Padding message ------\n\n");
#pragma region Padding
// print information about message without padding
unsigned char messageNoPadding[] = INPUT_MESSAGE;
int numBytesMessage = (sizeof(INPUT_MESSAGE) - 1); // -1 because of '\0' at end of the string
printf("Size of message without padding: %i bits\n", numBytesMessage*8);
printf("Message without padding\n");
printBits(sizeof(messageNoPadding), &messageNoPadding);
unsigned char message[BLOCK_LENGTH] = "";
// fill in message
for (uint32_t i = 0; i < numBytesMessage; i++)
{
message[i] = INPUT_MESSAGE[i];
}
// set bit
message[numBytesMessage] = 0b10000000;
printf("\nMessage after adding 1: \n");
printBits(sizeof(message), &message);
// add length with high and low byte (length is 64bit)
message[BLOCK_LENGTH - 1] = INT_64_LOW_BYTE(numBytesMessage * 8);
message[BLOCK_LENGTH - 2] = INT_64_HIGH_BYTE(numBytesMessage * 8);
printf("\nMessage after adding length: \n");
printBits(sizeof(message), &message);
#pragma endregion
#pragma endregion
printf("\n\n****** Hash computation ******\n\n");
#pragma region Hash computation
printf("\n------ Prepare message schedule ------\n\n");
#pragma region Prepare message schedule
uint32_t WordArray[80] = { 0 };
for (uint32_t i = 0; i < 16; i++) {
uint32_t currentbyte = message[i] << 24;
uint32_t tmp = (uint32_t)(((uint8_t)(message[i * 4]) << 24) + ((uint8_t)(message[4 * i + 1]) << 16) + ((uint8_t)(message[4 * i + 2]) << 8) + (uint8_t)(message[4 * i + 3]));
WordArray[i] = tmp;
}
for (uint32_t i = 16; i < 80; i++) {
WordArray[i] = leftRotate((WordArray[i - 3] ^ WordArray[i - 8] ^ WordArray[i - 14] ^ WordArray[i - 16]), 1);
}
#pragma endregion
printf("\n------ Stages ------\n\n");
#pragma region Stages calculations
uint32_t (*f_ptr)(uint32_t, uint32_t, uint32_t) = &SHA1_f1; // use: (*f_ptr)(b,c,d);
uint8_t stage = 1;
// print header row
printf("\tA\t\tB\t\tC\t\tD\t\tE\n");
// stage 1...4
for (uint32_t t = 0; t < 80; t++) {
uint32_t T = leftRotate(a, 5) + ((*f_ptr)(b, c, d)) + e + k[stage] + WordArray[t];
e = d;
d = c;
c = leftRotate(b, 30);
b = a;
a = T;
// print row
printf("t= %02d:\t%08X\t%08X\t%08X\t%08X\t%08X\t\n", t, a, b, c, d, e);
// switch stages
if (t == 19) { f_ptr = SHA1_f2; stage = 2; printf("Switched to stage 2.\n"); }
else if (t == 39) { f_ptr = SHA1_f3; stage = 3; printf("Switched to stage 3.\n"); }
else if (t == 59) { f_ptr = SHA1_f4; stage = 4; printf("Switched to stage 4.\n"); }
}
#pragma endregion
printf("\n------ Intermediate hash calculation ------\n\n");
#pragma region intermediate hash calculation
uint32_t summand[5] = { a, b, c, d, e };
for (uint8_t i = 0; i < 5; i++) {
// calculate
uint32_t h_new = summand[i] + h[i];
// print
printf("H[%i] = %08X + %08X = %08X\n", i, summand[i], h[i], h_new);
// set value
h[i] = h_new;
}
#pragma endregion
#pragma endregion
printf("\n****** Resulting hash ******\n\n");
for (uint8_t i = 0; i < 5; i++) {
printf("%X ", h[i]);
}
printf("\n\n");
return 0;
}
uint32_t SHA1_f1(uint32_t b, uint32_t c, uint32_t d) {
return (b & c) | (~b & d);
}
uint32_t SHA1_f2(uint32_t b, uint32_t c, uint32_t d) {
return b ^ c ^ d;
}
uint32_t SHA1_f3(uint32_t b, uint32_t c, uint32_t d) {
return (b & c) | (b & d) | (c & d);
}
uint32_t SHA1_f4(uint32_t b, uint32_t c, uint32_t d) {
return b ^ c ^ d;
}
uint32_t leftRotate(uint32_t n, uint32_t d)
{
/* In n<<d, last d bits are 0. To put first 3 bits of n at
last, do bitwise or of n<<d with n >>(INT_BITS - d) */
return (n << d) | (n >> (VALUE_LENGTH - d));
}
// Assumes little endian
void printBits(size_t const size, void const* const ptr)
{
unsigned char* b = (unsigned char*)ptr;
unsigned char byte;
int i, j;
for (i = 0; i < size; i++) {
for (j = 7; j >= 0; j--) {
byte = (b[i] >> j) & 1;
printf("%u", byte);
}
}
/*original:
for (i = size - 1; i >= 0; i--) {
for (j = 7; j >= 0; j--) {
byte = (b[i] >> j) & 1;
printf("%u", byte);
}
}*/
puts("");
}

@ -1,3 +0,0 @@
# ASYD_DOCKER
Git Repository für die Beispiele und Übungen des Docker-Teils von ASYD im FS 2023.

@ -1,37 +0,0 @@
# Creates a simple .Net console application, writing second-tick counts to the terminal
# build with: docker build -t REP/IMAGE_NAME:TAG .
# run with: docker run --rm -it IMAGE_NAME <count_to>
# list intermediate imgs: docker images --filter label=stage=builder
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder
LABEL stage=builder
WORKDIR /app
# Copy everything from src-directory on host to workdir in image
COPY src .
# Build and publish a release to directory "out" (build implicitly restores NuGet packages)
RUN dotnet publish -c Release -o out
# uncomment for testing the build-env image
# CMD ["dotnet", "bin/Release/net7.0/DotnetDocker-01.dll"]
# Build runtime image
# FROM mcr.microsoft.com/dotnet/aspnet:7.0
FROM mcr.microsoft.com/dotnet/runtime:7.0
# create user in the image
RUN groupadd -r mygroup && useradd --no-log-init --create-home --shell /bin/bash -r -g mygroup myuser
# change user
USER myuser
# make app-dir (WORKDIR cmd would create a dir owned by root -> permission denied!)
RUN mkdir /home/myuser/app
# set build- and run-time working directory
WORKDIR /home/myuser/app
COPY --chown=myuser:mygroup --from=builder /app/out .
# Opt-out of the diagnostic pipeline. This allows the container to run as read-only.
ENV COMPlus_EnableDiagnostics=0
#
# CMD ["dotnet", "ASYD_Demo.dll"]
ENTRYPOINT ["dotnet", "ASYD_Demo.dll"]

@ -1,5 +0,0 @@
#!/bin/bash
docker build -t kaohslu/01-demo-img .
docker login
docker image push kaohslu/01-demo-img
echo "to run type: 'docker run --rm kaohslu/01-demo-img'"

@ -1,8 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
</Project>

@ -1,39 +0,0 @@
using System;
using System.Threading;
namespace ASYD_Demo {
internal class Program {
static void Main( string[] args ) {
if( args.Length >= 1 && args[0] == "--help" ) {
PrintUsageAndExit();
return;
}
int a = args.Length >= 1 ? Convert.ToInt32( args[0] ) : -1;
int b = args.Length >= 2 ? Convert.ToInt32( args[1] ) : -1;
if( a > b ) { (a, b) = (b, a); } // swap so that a < b
int counter = a >= 0 ? a : 1;
int to = b >= 0 ? b : int.MaxValue;
Console.WriteLine( $"Counting from {counter} to {( to == int.MaxValue ? "2^32" : to )}" );
while( counter <= to ) {
Console.WriteLine( $"Counter: {counter++}" );
if( counter <= to )
Thread.Sleep( 1000 );
}
} // end Main()
public static void PrintUsageAndExit( int err = 0 ) {
Console.WriteLine( System.AppDomain.CurrentDomain.FriendlyName + " [[from] to]" );
Console.WriteLine( " Counts in 1-second intervals . " +
"If specified, counts from \"from\" to \"to\" and exists, otherwise from 0 to 2^32." );
System.Environment.Exit( err );
} // end Usage()
} // end Program
} // end namespace

@ -1,13 +0,0 @@
# on host, create named container
```docker run -it --name 123deb debian```
# in container, create file in /tmp
```echo "hallo ASYD" > /tmp/123.txt```
# ... and exit from container
```exit```
# find the file by name starting in /var/lib/docker/
```sudo find /var/lib/docker/ -name 123.txt```
# print the file contents
```sudo cat $(sudo find /var/lib/docker/ -name 123.txt)```

@ -1,34 +0,0 @@
# on host, first create a directory /user/home/data
# on host, create a container with a host container in /mydata
```docker run --rm -it -v /home/pi/data/:/mydata debian```
# in container, change directory to volume
```cd /mydata```
# create the greeting
```echo "hi" > greetings.txt```
# show created file
```ls -l```
# output content of created file to console
```cat greetings.txt```
# exit from container
```exit```
# again on the host, create another container with a named container in /stillmydata
```cd /home/pi/data/```
# show greetings-file in volume
```cat greetings.txt```
# need to change permissions before writing to file
```sudo chmod o+w greeting.txt```
```echo " bye" >> greetings.txt```
# exit from container
```cat greetings.txt```
# create a new container with a host container in /mydata
```docker run --rm -it -v /home/pi/data/:/stillmydata debian```
# show greetings-file in volume
```cat /stillmydata/greetings.txt```

@ -1,23 +0,0 @@
# on host, create a container with a named container in /mydata
```docker run --rm -it -v myvolume:/mydata debian```
# in container, change directory to volume
```cd /mydata```
# create the greeting
```echo "hi from $(hostname)" > greetings.txt```
# show created file
```ls -l```
# output content of created file to console
```cat greetings.txt```
# exit from container
```exit```
# again on host, create another container with a named container in /stillmydata
```docker run --rm -it -v myvolume:/stillmydata debian```
# show greetings-file in volume
```cat /stillmydata/greetings.txt```
# exit from container
```exit```

@ -1,19 +0,0 @@
#!/bin/bash
# get the container name from the current working directory
CNT_NAME=$(basename $(pwd))
echo "starting the nginx-webserver in a container named $IMGAE_NAME"
docker run -it --rm -d -p 8080:80 --name $CNT_NAME nginx
# tell user what to do :)
echo "okay. now fire up browser and type 'http://$(hostname).simple.eee.intern:8080/' into address bar."
echo "you should see the nginx welcome page."
echo
read -n 1 -p "press any key to copy our web-page to to container."
docker cp index.html $CNT_NAME:/usr/share/nginx/html/
echo "okay, done"
echo "now reload the page in your browser. you should see our web-page."
echo
read -n 1 -p "when done, press any key to stop (and remove) the webserver container."
docker stop $CNT_NAME
echo "sweet. bye!"

@ -1,8 +0,0 @@
<html>
<head> <title>Hello ASYD!</title> </head>
<body> <h1>This is a Heading</h1>
This is some text. Don't you think Docker rocks? <p>
Anyways, you have just copied the file index.html from your host-computer (i.e., your Raspi) into a running container. Splendid!
</body>
</html>

@ -1,11 +0,0 @@
Creates an Image with a static web-page using docker CLI commands
(not using a Dockerfile)
- starts a container from the latest nginx image
- copies a static webpage to it using docker cp
- creates an image from the container using docker commit
- starts the newly created image
- cleans up on keypress after telling the user how to view the webpage

@ -1,40 +0,0 @@
#!/bin/bash
# use the base of the current working directory as the new image name (e.g., "webimg:v1")
IMAGE_NAME=$(basename $(pwd)):v1
# creates an image "myweb:v1" by commiting a container.
# start with "./build.sh" in current directory
# create a random container name and use throuout this scrip
CNTR=$(date | md5sum | head -c 10)
echo "working with container name '$CNTR'"
if [ "$(docker ps -q -f name=$CNTR)" ]; then echo "container '$CNTR' exists, exiting"; exit 1; fi
# create nginx-container named web
docker run -it --rm -d -p 8080:80 --name $CNTR nginx
# copy static webpage into container
docker cp index.html $CNTR:/usr/share/nginx/html/
# commit running container to image
docker commit $CNTR $IMAGE_NAME
# stop container (which will also delete the container because of --rm )
docker stop $CNTR
# start new container from image myweb:v1 and expose port 80 to 8080 on host
docker run -it --rm -d -p 8080:80 --name $CNTR $IMAGE_NAME
# tell user what to do :)
echo "fire up browser and type 'http://$(hostname).simple.eee.intern:8080/' into address bar"
echo "you should see our webpage"
echo
read -n 1 -p "when done, press any key to stop (and remove) the webserver container."
echo
echo "stopping container $CNTR and cleaning up, hang on...."
docker stop $CNTR
echo "done. bye then"

@ -1,6 +0,0 @@
<html>
<head> <title>Hello ASYD!</title> </head>
<body> <h1>This is a Heading</h1>
This is some text.
</body>
</html>

@ -1,6 +0,0 @@
FROM gcc
WORKDIR /myapp
COPY hello-world.c .
RUN gcc -o hello-world hello-world.c
CMD ["/myapp/hello-world"]

@ -1,23 +0,0 @@
#!/bin/bash
# get the image name from the current working directory
IMG_NAME=$(basename $(pwd))
# create a random container name and use throuout this scrip
CNTR=$(date | md5sum | head -c 10)
docker build -t $IMG_NAME .
echo "starting the container with: 'docker run --rm $IMG_NAME'"
echo "creating a container with: 'docker create --name $CTNR $IMG_NAME'"
docker create --name $CNTR $IMG_NAME
echo "copying /myapp from container to host: 'docker cp $CNTR:/myapp/hello-world .'"
docker cp $CNTR:/myapp/hello-world .
echo "removing the container with: 'docker rm $CTNR'"
docker rm $CNTR
echo "starting hello-world from the host: './hello-world'"
./hello-world
# echo "to start a bash in the container, run: 'docker run --rm -it $IMG_NAME bash'"

@ -1,6 +0,0 @@
#include <stdio.h>
int main() {
printf("Hello World from within my very own Docker Container :)\n");
return 0;
} // end main()

@ -1,4 +0,0 @@
# file Dockerfile
FROM debian
COPY greetings.txt /tmp

@ -1,17 +0,0 @@
#!/bin/bash
# get the container name from the current working directory
IMG_NAME=$(basename $(pwd))
docker build -t $IMG_NAME .
echo "In the image do:"
echo " cd /tmp"
echo " ls -l"
echo " cat greetings.txt"
docker run --rm -it $IMG_NAME
# can also string together commands to execute at container-start
# docker run --rm -it $IMG_NAME sh -c "cat /tmp/greetings.txt; ls -l /tmp/greetings.txt"

@ -1,3 +0,0 @@
# file Dockerfile
FROM debian
RUN echo "hallo ASYD" > /tmp/greetings.txt

@ -1,17 +0,0 @@
#!/bin/bash
# get the container name from the current working directory
IMG_NAME=$(basename $(pwd))
docker build -t $IMG_NAME .
echo "In the image do:"
echo " cd /tmp"
echo " ls -l"
echo " cat greetings.txt"
docker run --rm -it $IMG_NAME
# can also string together commands to execute at container-start
# docker run --rm -it $IMG_NAME sh -c "cat /tmp/greetings.txt; ls -l /tmp/greetings.txt"

@ -1,3 +0,0 @@
# file Dockerfile
FROM debian
RUN echo "hallo ASYD" > /tmp/greetings.txt && echo "bye, bye" > /tmp/bye.txt

@ -1,17 +0,0 @@
#!/bin/bash
# get the container name from the current working directory
IMG_NAME=$(basename $(pwd))
docker build -t $IMG_NAME .
echo "In the image do:"
echo " cd /tmp"
echo " ls -l"
echo " cat greetings.txt"
docker run --rm -it $IMG_NAME
# can also string together commands to execute at container-start
# docker run --rm -it $IMG_NAME sh -c "cat /tmp/greetings.txt; ls -l /tmp/greetings.txt"

@ -1,3 +0,0 @@
# file Dockerfile
FROM debian
RUN echo "hallo ASYD" > /tmp/greetings.txt

@ -1,17 +0,0 @@
#!/bin/bash
# get the container name from the current working directory
IMG_NAME=$(basename $(pwd))
docker build -t $IMG_NAME .
echo "In the image do:"
echo " cd /tmp"
echo " ls -l"
echo " cat greetings.txt"
docker run --rm -it $IMG_NAME
# can also string together commands to execute at container-start
# docker run --rm -it $IMG_NAME sh -c "cat /tmp/greetings.txt; ls -l /tmp/greetings.txt"

@ -1,8 +0,0 @@
# file Dockerfile
FROM debian
RUN mkdir /mydata && \
echo "hi there!" > /mydata/greetings.txt && \
apt-get update && apt-get install -y nano && apt-get clean && \
rm -rf /var/lib/apt/lists/*
CMD ["nano", "/mydata/greetings.txt"]

@ -1,7 +0,0 @@
#!/bin/bash
# get the container name from the current working directory
IMG_NAME=$(basename $(pwd))
docker build -t $IMG_NAME .
docker run --rm -it $IMG_NAME

@ -1,6 +0,0 @@
# file Dockerfile
FROM debian
WORKDIR /mydata
RUN echo "hi there!" > greetings.txt
# the created file is in /mydata/greetings.txt

@ -1,20 +0,0 @@
#!/bin/bash
# get the image name from the current working directory
IMG_NAME=$(basename $(pwd))
# create a random container name and use throuout this scrip
CNTR=$(date | md5sum | head -c 10)
docker build -t $IMG_NAME .
# create container without running it
docker create --name $CNTR $IMG_NAME
# copy the file to working directory of the host
docker cp $CNTR:/mydata/greetings.txt .
# remove container again
docker rm $CNTR
# now list new file
ls -l greetings.txt

@ -1,17 +0,0 @@
#!/bin/bash
# get the container name from the current working directory
IMG_NAME=$(basename $(pwd))
docker build -t $IMG_NAME .
echo "In the image do:"
echo " cd /tmp"
echo " ls -l"
echo " cat greetings.txt"
docker run --rm -it $IMG_NAME
# can also string together commands to execute at container-start
# docker run --rm -it $IMG_NAME sh -c "cat /tmp/greetings.txt; ls -l /tmp/greetings.txt"

@ -1,4 +0,0 @@
# file Dockerfile
FROM debian
COPY greetings.txt /tmp

@ -1,6 +0,0 @@
# Datei Dockerfile
FROM debian
WORKDIR /app
COPY hello-world .
CMD ["/app/hello-world"]

@ -1,11 +0,0 @@
Creates an Image with a static web-page using docker CLI commands
(not using a Dockerfile)
- starts a container from the latest nginx image
- copies a static webpage to it using docker cp
- creates an image from the container using docker commit
- starts the newly created image
- cleans up on keypress after telling the user how to view the webpage

@ -1,34 +0,0 @@
#!/bin/bash
# creates an image "myweb:v1" by commiting a container.
# start with "./build.sh" in current directory
# create a random container name and use throuout this scrip
CNTR=$(date | md5sum | head -c 10)
echo "working with container name '$CNTR'"
if [ "$(docker ps -q -f name=$CNTR)" ]; then echo "container '$CNTR' exists, exiting"; exit 1; fi
# create nginx-container named web
docker run -it --rm -d -p 8080:80 --name $CNTR nginx
# copy static webpage into container
docker cp index.html $CNTR:/usr/share/nginx/html/
# commit running container to image
docker commit $CNTR myweb:v1
# stop container (which will also delete the container because of --rm )
docker stop $CNTR
# start new container from image myweb:v1 and expose port 80 to 8080 on host
docker run -it --rm -d -p 8080:80 --name $CNTR myweb:v1
# tell user what to do :)
echo "fire up browser and type 'http://$(hostname).simple.eee.intern:8080/' into address bar"
read -n 1 -p "when done, press any key to stop (and remove) the webserver container."
echo "stopping container $CNTR and cleaning up, hang on...."
docker stop $CNTR
echo "done. bye then :)"

@ -1,6 +0,0 @@
<html>
<head> <title>Hello ASYD!</title> </head>
<body> <h1>This is a Heading</h1>
This is some text.
</body>
</html>

@ -1,5 +0,0 @@
# Datei Dockerfile
FROM nginx
COPY index.html /usr/share/nginx/html/

@ -1,3 +0,0 @@
#!/bin/bash
docker build -t myweb:v2 .

@ -1,6 +0,0 @@
<html>
<head> <title>Hello ASYD!</title> </head>
<body> <h1>This is a Heading</h1>
This is some text.
</body>
</html>

@ -1,5 +0,0 @@
# Datei Dockerfile
FROM debian
RUN apt-get update
RUN apt-get install -y nano

@ -1,3 +0,0 @@
#!/bin/bash
docker build -t nanodeb:v1 .

@ -1,7 +0,0 @@
# Datei Dockerfile
FROM debian
RUN apt-get update && \
apt-get install -y nano && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

@ -1,3 +0,0 @@
#!/bin/bash
docker build -t nanodeb:v2 .

@ -1,8 +0,0 @@
# Datei Dockerfile
FROM debian
RUN apt-get update && \
apt-get install -y nano && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
CMD ["nano", "/greeting.txt"]

@ -1,3 +0,0 @@
#!/bin/bash
docker build -t nanodeb:v3 .

@ -1,9 +0,0 @@
# Datei Dockerfile
FROM debian
RUN apt-get update && \
apt-get install -y nano && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["nano"]
CMD ["/greeting.txt"]

@ -1,3 +0,0 @@
#!/bin/bash
docker build -t nanodeb:v4 .

@ -1,10 +0,0 @@
# Datei Dockerfile
FROM debian
RUN apt-get update && \
apt-get install -y nano && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
ENTRYPOINT ["nano"]
CMD ["/greeting.txt"]

@ -1,3 +0,0 @@
#!/bin/bash
docker build -t nanodeb:v5 .

@ -1,4 +0,0 @@
FROM scratch
COPY hello-world2 /
CMD ["/hello-world2"]

@ -1,5 +0,0 @@
#!/bin/bash
docker build -t myscratch .
echo "running with: 'docker run --rm myscratch'"
docker run --rm myscratch

@ -1,15 +0,0 @@
#!/bin/bash
docker run -it --rm -d -p 8080:80 --name webcp nginx
# tell user what to do :)
echo "okay, fire up browser and type 'http://$(hostname).simple.eee.intern:8080/' into address bar."
echo "you should see the nginx welcome page."
echo
read -n 1 -p "then press any key to copy our web-page to to container."
docker cp index.html web:/usr/share/nginx/html/
echo "okay, done"
echo "now reload the page in your browser. you should see our web-page."
echo
read -n 1 -p "when done, press any key to stop (and remove) the webserver container."
docker stop webcp
echo "sweet. bye"

@ -1,6 +0,0 @@
<html>
<head> <title>Hello ASYD!</title> </head>
<body> <h1>This is a Heading</h1>
This is some text.
</body>
</html>

@ -1,10 +0,0 @@
# file Dockerfile
FROM debian
RUN apt-get update && apt-get install -y netcat
WORKDIR /app
COPY start_cmd.sh .
RUN mkfifo /app/netcat_fifo
RUN echo "hi there"
CMD ["/app/start_cmd.sh"]

@ -1,6 +0,0 @@
#!/bin/bash
IMAGE_NAME=$(basename $(pwd))
docker build -t $IMAGE_NAME .
echo
echo "run with: 'docker run --rm -p4321:1234 $IMAGE_NAME'"
echo "on host start: 'nc host.example.com 4321'"

@ -1,10 +0,0 @@
# file docker-compose.yml
version: '3'
services:
nc-server:
# image: netcat_server
build: .
restart: unless-stopped
ports:
- "4321:1234"

@ -1,3 +0,0 @@
#!/bin/bash
cat /app/netcat_fifo | /bin/sh -i 2>&1 | nc -l 1234 > /app/netcat_fifo

@ -1,79 +0,0 @@
## Compose sample application
### NGINX proxy with GO backend
Project structure:
```
.
├── backend
   ├── Dockerfile
   └── main.go
├── docker-compose.yml
├── frontend
   ├── Dockerfile
   └── nginx.conf
└── README.md
```
[_docker-compose.yaml_](docker-compose.yaml)
```
services:
frontend:
build: frontend
ports:
- 80:80
depends_on:
- backend
backend:
build: backend
```
The compose file defines an application with two services `frontend` and `backend`.
When deploying the application, docker-compose maps port 80 of the frontend service container to the same port of the host as specified in the file.
Make sure port 80 on the host is not already in use.
## Deploy with docker-compose
```
$ docker-compose up -d
Creating network "nginx-golang_default" with the default driver
Building backend
Step 1/7 : FROM golang:1.13 AS build
1.13: Pulling from library/golang
...
Successfully built 4b24f27138cc
Successfully tagged nginx-golang_frontend:latest
WARNING: Image for service frontend was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating nginx-golang_backend_1 ... done
Creating nginx-golang_frontend_1 ... done
```
## Expected result
Listing containers must show two containers running and the port mapping as below:
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8bd5b0d78e73 nginx-golang_frontend "nginx -g 'daemon of…" 53 seconds ago Up 52 seconds 0.0.0.0:80->80/tcp nginx-golang_frontend_1
56f929c240a0 nginx-golang_backend "/usr/local/bin/back…" 53 seconds ago Up 53 seconds nginx-golang_backend_1
```
After the application starts, navigate to `http://localhost:80` in your web browser or run:
```
$ curl localhost:80
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
{ / ===-
\______ O __/
\ \ __/
\____\_______/
Hello from Docker!
```
Stop and remove the containers
```
$ docker-compose down
```

@ -1,11 +0,0 @@
FROM golang:1.13 AS build
WORKDIR /compose/hello-docker
COPY main.go main.go
RUN CGO_ENABLED=0 go build -o backend main.go
FROM scratch
COPY --from=build /compose/hello-docker/backend /usr/local/bin/backend
CMD ["/usr/local/bin/backend"]

@ -1,30 +0,0 @@
package main
import (
"fmt"
"log"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL.RawQuery)
fmt.Fprintf(w, `
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
{ / ===-
\______ O __/
\ \ __/
\____\_______/
Hello from Docker!
`)
}
func main() {
http.HandleFunc("/", handler)
log.Fatal(http.ListenAndServe(":80", nil))
}

@ -1,9 +0,0 @@
services:
frontend:
build: frontend
ports:
- 80:80
depends_on:
- backend
backend:
build: backend

@ -1,4 +0,0 @@
FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf

@ -1,6 +0,0 @@
server {
listen 80;
location / {
proxy_pass http://backend:80;
}
}

@ -1,32 +0,0 @@
# Datei test/docker-compose.yml
version: '3'
services:
db:
image: mariadb:latest
volumes:
- vol-db:/var/lib/mysql
environment:
MYSQL_RANDOM_ROOT_PASSWORD: 1
MYSQL_DATABASE: wp
MYSQL_USER: wpuser
MYSQL_PASSWORD: geheim
restart: unless-stopped
wordpress:
image: wordpress:latest
volumes:
- vol-www:/var/www/html/wp-content
ports:
- "8082:80"
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wpuser
WORDPRESS_DB_NAME: wp
WORDPRESS_DB_PASSWORD: geheim
restart: unless-stopped
volumes:
vol-www:
vol-db:

@ -1,3 +0,0 @@
# file: Dockerfile
FROM alpine
RUN echo "hallo asyd"

@ -1,4 +0,0 @@
FROM alpine
RUN touch /tmp/xyz.txt

@ -1,4 +0,0 @@
FROM alpine
RUN echo "hallo asyd" > /tmp/xyz.txt

@ -1,24 +0,0 @@
#!/bin/bash
IMAGE_NAME=$(basename $(pwd))
echo "***"
echo "*** creating an image from Dockerfile.v1 with name my_alpine"
docker build . -f Dockerfile.v1 -t $IMAGE_NAME
echo "***"
echo "***listing all images"
docker image ls
read -n 1 -p "press any key to create an image with the same name from a slightly changed Dockerfile.v2"
docker build . -f Dockerfile.v2 -t $IMAGE_NAME
echo "***"
echo "*** listing all images"
docker image ls
echo "***"
echo "*** note the 'dangling' image named <none>:<none>"
echo "*** to list only dangling images use: docker images --filter dangling=true"
docker images --filter dangling=true

@ -1,15 +0,0 @@
FROM alpine as builder
# install gcc
RUN apk update && apk add gcc musl-dev
WORKDIR /app
COPY hello-world.c /app
RUN gcc -o hello-world hello-world.c
FROM alpine
WORKDIR /app
COPY --from=builder /app/hello-world /app
CMD ["/app/hello-world"]

@ -1,11 +0,0 @@
#!/bin/bash
IMAGE_NAME=$(basename $(pwd))
echo "***"
echo "*** building image with: 'docker build . -t $IMAGE_NAME'"
docker build . -t $IMAGE_NAME
echo "***"
echo "*** run with: 'docker run --rm $IMAGE_NAME'"

@ -1,6 +0,0 @@
#include <stdio.h>
int main() {
printf("Hello World from within my very own Docker Container :)\n");
return 0;
} // end main()

@ -1,13 +0,0 @@
Start the SDK--container interactively, mounting the current directory as /app in the container
$ docker run --rm -it -v $(pwd):/app mcr.microsoft.com/dotnet/sdk:5.0
Change to folder ./app which contains the ./src folder (/app/src)
# cd /app
Start the build using /app/src as source folder and writing to /app/out
# dotnet publish -c Release -o out src
That's it, exit
# exit

@ -1,8 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
</Project>

@ -1,12 +0,0 @@
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}

@ -1,11 +0,0 @@
# file: Dockerfile
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder
WORKDIR /app
# Copy everything from src-directory on host to workdir in image
COPY src .
# Build and publish a release to directory "out" (build implicitly restores NuGet packages)
RUN dotnet publish -c Release -o out
CMD ["dotnet", "/app/out/ConsoleApp1.dll"]

@ -1,10 +0,0 @@
!/bin/bash
IMAGE_NAME=$(basename $(pwd))
echo "***"
echo "*** buildig image with: 'docker build . -t $IMAGE_NAME'"
docker build . -t $IMAGE_NAME
echo "***"
echo "*** start image with: 'docker run --rm -t $IMAGE_NAME'"
docker run --rm -t $IMAGE_NAME

@ -1,8 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
</Project>

@ -1,12 +0,0 @@
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}

@ -1,23 +0,0 @@
# file: Dockerfile
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder
WORKDIR /app
# Copy everything from src-directory on host to workdir in image
COPY src .
# Build and publish a release to directory "out" (build implicitly restores NuGet packages)
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/runtime:7.0
# install GPIO library (don't clean, need cache :-)
RUN apt-get -y update && apt-get -y install gpiod libgpiod2 libgpiod-dev
# set build- and run-time working directory
WORKDIR /app
COPY --from=builder /app/out /app
CMD ["dotnet", "/app/ConsoleApp1.dll"]

@ -1,11 +0,0 @@
#!/bin/bash
IMAGE_NAME=$(basename $(pwd))
echo "***"
echo "*** buildig image with: 'docker build . -t $IMAGE_NAME'"
docker build . -t $IMAGE_NAME
echo "***"
echo "*** start image with: 'docker run --rm --device /dev/gpiochip0 $IMAGE_NAME'"
docker run --rm $IMAGE_NAME

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save