Skip to content
Permalink
Browse files

Added output code type, added copy icon.

  • Loading branch information...
Silvenga committed Apr 15, 2018
1 parent 1728a1f commit 71485b0139e21c9b1915e8aaae8ecadbf38ebc96
@@ -10,12 +10,14 @@ In early October of 2017, researchers announced, publicly, a cryptographic vulne
Since the point of TPM's is to perform key protection inside hardware, a software fix is impossible. This is so difficult to mitigate that Window's just resorts to emitting a warning in the Event Logs like the one below:

```ps1
> Get-EventLog -LogName System -Source Microsoft-Windows-TPM-WMI -EntryType Error | select Message
Get-EventLog -LogName System -Source Microsoft-Windows-TPM-WMI -EntryType Error | select Message
```
```output
The Trusted Platform Module (TPM) firmware on this PC has a known security problem.
Please contact your PC manufacturer to find out if an update is available.
For more information please go to https://go.microsoft.com/fwlink/?linkid=852572
```

Now, 6 months later and over a year since Infineon was notified of this issue, Asus and Gigabyte have yet to release updates for their TPM's. Although, I'm not particularly surprised considering most consumers would likely brick their machine's when trying to update (or not need to update to begin with). Thankfully, many enterprise-centered company's use these Infineon based TPM's, meaning we, the consumers, can piggyback off of enterprise clients shouting for a fix.

In this case, it turns out that the Asus and Gigabyte TPM's are effectively the same one's found in some Supermicro servers, and of course, Supermicro had to release firmware updates - updates that we can use.
@@ -25,8 +27,9 @@ In this case, it turns out that the Asus and Gigabyte TPM's are effectively the
Before I get started, I want to make sure the TPM is working in my device. I can ask Window's about it via the `Get-TPM` command.

```ps1
> Get-Tpm
Get-Tpm
```
```output
TpmPresent : True
TpmReady : False
ManufacturerId : 1229346816
@@ -54,8 +57,9 @@ cd '.\9665FW update package_1.1\'
Looking through the files extracted files, there are two directories:

```ps1
> ls | select Name
ls | select Name
```
```output
Firmware
Tools
9665.nsh
@@ -80,8 +84,9 @@ cp .\Tools\WinPE\Bin\x64\* .\workspace\
Now `.\workspace` contains the following files:

```ps1
> ls | select Name
ls | select Name
```
```output
License_FW_Images.pdf
TPM12_4.40.119.0_to_TPM12_4.43.257.0.BIN
TPM12_4.40.119.0_to_TPM20_5.62.3126.0.BIN
@@ -112,8 +117,9 @@ Now to upgrading the firmware!
Let's make sure `TPMFactoryUpd.exe` detects the TPM.

```ps1
> .\TPMFactoryUpd.exe -info
.\TPMFactoryUpd.exe -info
```
```output
**********************************************************************
* Infineon Technologies AG TPMFactoryUpd Ver 01.01.2212.00 *
**********************************************************************
@@ -130,8 +136,9 @@ Let's make sure `TPMFactoryUpd.exe` detects the TPM.
And it does, sweet! Now to run the upgrade.

```ps1
> .\TPMFactoryUpd.exe -update config-file -config TPM20_latest.cfg
.\TPMFactoryUpd.exe -update config-file -config TPM20_latest.cfg
```
```output
**********************************************************************
* Infineon Technologies AG TPMFactoryUpd Ver 01.01.2212.00 *
**********************************************************************
@@ -178,8 +185,9 @@ Now to disable the TPM.
After booting back into Windows, it looks like disabling the TPM fixes the `Empty Buffer` problem:

```ps1
> .\TPMFactoryUpd.exe -info
.\TPMFactoryUpd.exe -info
```
```output
**********************************************************************
* Infineon Technologies AG TPMFactoryUpd Ver 01.01.2212.00 *
**********************************************************************
@@ -198,7 +206,8 @@ Now I can try to update the TPM again.
```ps1
cd '.\9665FW update package_1.1\workspace\'
.\TPMFactoryUpd.exe -update config-file -config TPM20_latest.cfg
```
```output
**********************************************************************
* Infineon Technologies AG TPMFactoryUpd Ver 01.01.2212.00 *
**********************************************************************
@@ -243,8 +252,9 @@ And since this vulnerability is for RSA key generation, it's best to reset all g
After getting back into Windows, I'm greeted with a lovely success message.

```ps1
> Get-EventLog -LogName System -Source Microsoft-Windows-TPM-WMI | select Message
Get-EventLog -LogName System -Source Microsoft-Windows-TPM-WMI | select Message
```
```output
The TPM was successfully provisioned and is now ready for use.
The TBS device identifier has been generated.
The Ownership of the Trusted Platform Module (TPM) hardware on this computer was successfully taken (TPM TakeOwnership command) by the system.
@@ -253,8 +263,9 @@ The Ownership of the Trusted Platform Module (TPM) hardware on this computer was
And as a final check, it looks like the `ManufacturerVersion` was updated to `5.62`.

```ps1
> Get-Tpm
Get-Tpm
```
```output
TpmPresent : True
TpmReady : True
ManufacturerId : 1229346816
@@ -9,22 +9,24 @@ namespace MarkdigExtensions.CodeHeader
{
public class CodeHeaderRenderer : HtmlObjectRenderer<CodeBlock>
{
public readonly Dictionary<string, string> CodeLanguageMap = new Dictionary<string, string>
public readonly Dictionary<string, (string Human, string Class)> CodeLanguageMap = new Dictionary<string, (string Human, string Class)>
{
{ "ps1", "PowerShell" },
{ "ps", "PowerShell" },
{ "powershell", "PowerShell" },
{ "cmd", "Windows Command Line" },
{ "bat", "Windows Command Line" },
{ "bash", "Bash" },
{ "js", "JavaScript" },
{ "ts", "TypeScript" },
{ "log", "Logs" },
{ "logs", "Logs" },
{ "json", "JSON" },
{ "gpg", "GPG Key" },
{ "term", "Terminal" },
{ "dockerfile", "Dockerfile" },
{ "ps1", ("PowerShell", "powershell") },
{ "ps", ("PowerShell", "powershell") },
{ "powershell", ("PowerShell", "powershell") },
{ "cmd", ("Windows Command Line", "cmd") },
{ "bat", ("Windows Command Line", "cmd") },
{ "bash", ("Bash", "bash") },
{ "js", ("JavaScript", "js") },
{ "ts", ("TypeScript", "ts") },
{ "log", ("Logs", "logs") },
{ "logs", ("Logs", "logs") },
{ "json", ("JSON", "json") },
{ "gpg", ("GPG Key", "gpg") },
{ "term", ("Terminal", "cli") },
{ "cli", ("Terminal", "cli") },
{ "dockerfile", ("Dockerfile", "dockerfile") },
{ "output", ("Output", "output") },
};

protected override void Write(HtmlRenderer renderer, CodeBlock obj)
@@ -41,28 +43,32 @@ protected override void Write(HtmlRenderer renderer, CodeBlock obj)
// </button>
// </div>

var language = "Code";
var languageHuman = "Code";
var languageClass = "code";
var info = (obj as FencedCodeBlock)?.Info;
if (info != null && CodeLanguageMap.ContainsKey(info))
{
language = CodeLanguageMap[info];
languageHuman = CodeLanguageMap[info].Human;
languageClass = CodeLanguageMap[info].Class;
}
else if (info != null && info.StartsWith("file-"))
{
var file = info.Substring("file-".Length);
language = file;
languageHuman = file;
languageClass = "file";
}

var copyId = Guid.NewGuid().ToString("N");

renderer.Write("<div class=\"code-header\">");
renderer.Write($" <span class=\"language\">{language}</span>");
renderer.Write($"<div class=\"code-header lang-{languageClass}\">");
renderer.Write($" <span class=\"language\">{languageHuman}</span>");
renderer.Write($" <button class=\"copy\" data-copy-id=\"{copyId}\">");
renderer.Write(" <i class=\"copy-icon\"></i>");
renderer.Write(" <span>Copy</span>");
renderer.Write(" </button>");
renderer.Write("</div>");

renderer.Write("<pre");
renderer.Write($"<pre class=\"lang-{languageClass}\"");

renderer.Write($"><code data-copy-target=\"{copyId}\"");

@@ -0,0 +1,4 @@
<svg aria-hidden="true" data-icon="copy" role="img"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
<path d="M433.941 65.941l-51.882-51.882A48 48 0 0 0 348.118 0H176c-26.51 0-48 21.49-48 48v48H48c-26.51 0-48 21.49-48 48v320c0 26.51 21.49 48 48 48h224c26.51 0 48-21.49 48-48v-48h80c26.51 0 48-21.49 48-48V99.882a48 48 0 0 0-14.059-33.941zM266 464H54a6 6 0 0 1-6-6V150a6 6 0 0 1 6-6h74v224c0 26.51 21.49 48 48 48h96v42a6 6 0 0 1-6 6zm128-96H182a6 6 0 0 1-6-6V54a6 6 0 0 1 6-6h106v88c0 13.255 10.745 24 24 24h88v202a6 6 0 0 1-6 6zm6-256h-64V48h9.632c1.591 0 3.117.632 4.243 1.757l48.368 48.368a6 6 0 0 1 1.757 4.243V112z"></path>
</svg>
@@ -1 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;"><path d="M50,4.104c25.302,0 45.843,20.565 45.843,45.896c0,25.331 -20.541,45.896 -45.843,45.896c-25.302,0 -45.843,-20.565 -45.843,-45.896c0,-25.331 20.541,-45.896 45.843,-45.896Zm-0.004,4.238c-23.016,0 -41.682,18.664 -41.682,41.691c0,18.415 11.943,34.041 28.508,39.553c2.086,0.382 2.846,-0.906 2.846,-2.009c0,-0.99 -0.036,-3.611 -0.057,-7.091c-11.595,2.521 -14.041,-5.586 -14.041,-5.586c-1.897,-4.817 -4.63,-6.099 -4.63,-6.099c-3.785,-2.587 0.287,-2.533 0.287,-2.533c4.184,0.294 6.385,4.294 6.385,4.294c3.718,6.372 9.758,4.532 12.132,3.465c0.379,-2.695 1.457,-4.532 2.647,-5.574c-9.257,-1.052 -18.989,-4.629 -18.989,-20.603c0,-4.55 1.625,-8.271 4.292,-11.186c-0.43,-1.054 -1.861,-5.292 0.409,-11.032c0,0 3.498,-1.121 11.462,4.273c3.325,-0.923 6.892,-1.387 10.436,-1.402c3.542,0.015 7.107,0.479 10.436,1.402c7.959,-5.394 11.452,-4.273 11.452,-4.273c2.275,5.74 0.845,9.978 0.417,11.032c2.672,2.915 4.284,6.636 4.284,11.186c0,16.015 -9.747,19.539 -19.032,20.57c1.495,1.287 2.828,3.831 2.828,7.721c0,5.573 -0.051,10.07 -0.051,11.436c0,1.114 0.752,2.411 2.866,2.004c16.552,-5.522 28.485,-21.138 28.485,-39.548c0,-23.027 -18.666,-41.691 -41.69,-41.691Z" style="fill:#808080;"/></svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 100 100" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"
xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;">
<path d="M50,4.104c25.302,0 45.843,20.565 45.843,45.896c0,25.331 -20.541,45.896 -45.843,45.896c-25.302,0 -45.843,-20.565 -45.843,-45.896c0,-25.331 20.541,-45.896 45.843,-45.896Zm-0.004,4.238c-23.016,0 -41.682,18.664 -41.682,41.691c0,18.415 11.943,34.041 28.508,39.553c2.086,0.382 2.846,-0.906 2.846,-2.009c0,-0.99 -0.036,-3.611 -0.057,-7.091c-11.595,2.521 -14.041,-5.586 -14.041,-5.586c-1.897,-4.817 -4.63,-6.099 -4.63,-6.099c-3.785,-2.587 0.287,-2.533 0.287,-2.533c4.184,0.294 6.385,4.294 6.385,4.294c3.718,6.372 9.758,4.532 12.132,3.465c0.379,-2.695 1.457,-4.532 2.647,-5.574c-9.257,-1.052 -18.989,-4.629 -18.989,-20.603c0,-4.55 1.625,-8.271 4.292,-11.186c-0.43,-1.054 -1.861,-5.292 0.409,-11.032c0,0 3.498,-1.121 11.462,4.273c3.325,-0.923 6.892,-1.387 10.436,-1.402c3.542,0.015 7.107,0.479 10.436,1.402c7.959,-5.394 11.452,-4.273 11.452,-4.273c2.275,5.74 0.845,9.978 0.417,11.032c2.672,2.915 4.284,6.636 4.284,11.186c0,16.015 -9.747,19.539 -19.032,20.57c1.495,1.287 2.828,3.831 2.828,7.721c0,5.573 -0.051,10.07 -0.051,11.436c0,1.114 0.752,2.411 2.866,2.004c16.552,-5.522 28.485,-21.138 28.485,-39.548c0,-23.027 -18.666,-41.691 -41.69,-41.691Z" style="fill:#808080;"/>
</svg>
@@ -1 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 256 256" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;"><rect x="8" y="64" width="152" height="32"/><rect x="8" y="112" width="240" height="32"/><rect x="8" y="160" width="192" height="32"/></svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 256 256" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"
xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;">
<rect x="8" y="64" width="152" height="32"/>
<rect x="8" y="112" width="240" height="32"/>
<rect x="8" y="160" width="192" height="32"/>
</svg>
@@ -112,8 +112,8 @@
flex-grow: 1;
}
.copy {
padding-right: 1rem;
padding-left: 1rem;
padding-right: 0.8rem;
padding-left: 0.8rem;
background: transparent;
border: 0 solid;
cursor: pointer;
@@ -126,6 +126,18 @@
&:focus {
outline: 5px auto -webkit-focus-ring-color;
}
.copy-icon {
background-image: url(./../../assets/copy.svg);
background-repeat: no-repeat;
background-position: center;
width: 11px;
height: 14px;
margin-right: 5px;
opacity: 0.40;
}
}
&.lang-output {
margin-top: -1rem;
}
}
pre {

0 comments on commit 71485b0

Please sign in to comment.
You can’t perform that action at this time.