Posts in Powershell (5 found)
Kix Panganiban 1 months ago

Unhogging RAM from WSL

I have 64 gigs of RAM. I thought that was plenty, but recently I've noticed Libre Hardware Monitor reporting that I was consistently at 90% RAM usage. Opening Task Manager reveals that VmmemWSL.exe was consuming 30GB of RAM -- but when I ran inside Ubuntu running on the Windows Subsystem for Linux (WSL), it was only reporting 6GB of use. I also run Docker, but it's reporting only 2GB of use. So where did the rest of the ~22GB go? It turns out it has something to do with the way WSL's dynamic memory allocation works (hence VmmemWSL.exe), and how it doesn't immediately free up memory from the host OS even that memory is no longer in use by the Linux OS. The fix was to do: So now, WSL only ever hogs up to 16GB of idle RAM -- which is still a lot -- but I now have plenty of RAM available again for my Windows host. in Powershell to force free the memory Create with the following contents Restart WSL with in Powershell Comet was eating 6GB of RAM with only a few tabs open. Chromium, am I right? I wish there was Orbstack for Windows

0 views
Takuya Matsuyama 4 months ago

How to automate signing your Windows app with Certum's SimplySign app

I’ve been running a SaaS for 9 years, which includes an Electron app for Windows. For code signing, I’ve been using Certum's Code Signing Certificate: The pricing has been great, but there’s been one small annoyance that makes automation a bit tricky. In this post, I’ll share how I worked around it. Certum uses an app called SimplySign to handle authentication. This app is required for signing but unfortunately makes it impossible to automate the code-signing process out of the box. By default, SimplySign Desktop isn’t connected: You need to manually double-click the tray icon and enter a TOTP (Time-based One-Time Password): The code is generated by their mobile app. This manual step breaks automation because, without completing it, you can’t use — the private key isn't loaded until SimplySign authenticates. While setting up SimplySign, you scan a QR code to activate your account: It turns out that this QR code contains a standard URI. You can scan it with other password managers like 1Password — and indeed, 1Password shows the exact same token as the SimplySign app. When you click the Edit button, you can reveal the underlying URI. This means you can generate the token programmatically using a script! Here’s a PowerShell snippet that generates a TOTP using inline C#: This alone gives you the token. Now, let’s use it to automate the authentication step. PowerShell can simulate keystrokes sent to a window. This snippet searches for the SimplySign Desktop window and, if found, sends the TOTP code via simulated keystrokes. Here’s the full PowerShell script you can use to automate the entire process: You’ll need to define these environment variables: I keep these in a file and use to load them when running the script. I hope this helps you automate code signing with Certum and SimplySign! Looking for a good Markdown tech note-taking app? Here is what I'm building:

0 views
dfir.ch 1 years ago

ScriptBlock Smuggling

Introduction PowerShell’s Script Block Logging is a security feature that records and logs the contents of all scripts and commands executed within PowerShell. This includes both legitimate administrative scripts and potentially malicious commands. When enabled, Script Block Logging generates detailed logs stored in the Windows Event Log under Microsoft-Windows-PowerShell/Operational. I have previously tweeted several times about PowerShell and why monitoring the executed PowerShell scripts is so important. A few of these tweets are listed here.

0 views
Danny McClelland 2 years ago

Running Powershell Script an Elevated User

When running a powershell script, I often find I need to run the script in an elevated prompt. The nature of my job is that often these scripts will be run by people that don’t really know what Powershell is. I have found it quite useful to first create a bash script that the user executes, which in turn calls the actual Powershell script as an elevated user. To keep this handy, I’m posting it here for future me.

0 views
W. Jason Gilmore 17 years ago

Improving the Windows Console

Although over the years I've run a number of Linux distributions on my main development laptop, for some time now I've been running Windows XP. Of course, anybody who is even vaguely familiar with Linux' powerful command-line interface shudders at the notion of using Windows pathetic console, and accordingly I regularly gnash my teeth over dealing with even rudimentary administration issues. Personally I've never been a fan of Cygwin, and so have sought out other alternatives to the console. As an alternative to Windows' terminal window, I've long used Console, an open source terminal window replacement which among other things allows the window to be resized. It also supports tabbed windows, meaning you can easily navigate between your MySQL client, Rails console, and Rails log windows for instance. But even a vastly improved terminal window doesn't resolve one of Windows' other wildly annoying features, or rather lack thereof: crucial commands such as "tail". DOS' built-in “more” command doesn't allow you to view the last X lines of a file, and for crying out loud you'd think they'd have thought to add the tail command to Powershell (such a command exists, but they've mysteriously decided to call it "get-content". "tail" must have been too obvious a choice). Seriously, admitting Unix got something right must be akin to devil worship in Redmond. At any rate, you can add “tail” to your system by installing the Windows Server 2003 Resource Kit Tools package, which is freely available from the Microsoft site. Once installed, you'll have a very Unix-like tail command at your disposal.

0 views