Search This Blog

Tuesday, September 19, 2023

Maintenance: Updating your Surface Pro 7

In my job I have been updating a few docking stations with fresh firmware. Personally I find it to be a nice little routine to keep the firmware and software up to date, like putting things to order.

For example there is firmware for both Lenovo and Dell docking stations, and keeping that in mind I was looking for a way to update the firmware for my Surface Dock 2.

Updating your Surface Dock 2:
The easy way is to use the Surface app, downloadable from the Microsoft Store.
After installing it and opening it, you get an easy to use menu. You can interact with your dock, mouse and pen for example.


By clicking clicking on the dock you can make sure that your firmware is up to date. There you can also turn different ports on and off.

For someone that would need a manual update, it seems like Microsoft offers a few versions as well, based on your device.

Updating your Surface Pro 7 drivers:
You can also update the driver kit with a roughly 600 mb sized file with all the drivers. 
To download it go here.

Running a diagnostic toolkit to identify errors:
You might also want to grab the Surface Diagnostic Toolkit, it let's you test the functionality of your device, a great tool for singling out various issues that you might have with your computer.
To get the toolkit, go to this link.

Now you have been provided with some simple and easy to access tools to service your device.

Sunday, September 17, 2023

Hardware: Finding device info using PowerShell

The hunt for more information began with a new keyboard I have. A wireless keyboard called "Deltaco TB-632". As an avid Deltaco fan I also knew that they rarely make their own products, but they rebrand devices that they source from other companies.

One example is their smart home devices that in at least one case seems to come from China.

So how did I go about finding more information about this keyboard? Well, old trusty PowerShell of course. After first trying to find a way using the control panel and settings to see a MAC address or other identifying information I simply turned to the command Get-Pnpdevice.

If you run this command you will discover practically all devices that has been connected to the computer since the last OS installation. They will be listed as Unknown if they aren't connected and OK if they are working fine.

This is the main code I ran: get-pnpdevice -Class USB | Select-Object status, friendlyname, instanceid | Sort-Object -Property friendlyname

First I ran the command without the USB wireless receiver attached.

Then I attached the receiver and ran the command again. By doing this I could see which device that turned from Unknown to OK.

In this specific case I got a result looking like this:

OK USB Composite Device USB\VID_248A&PID_8367\5&194485C0&0&1

Now that you have the VID (vendor ID) and PID (device ID) for your device you can simply Google these identifiers.

My result indicated that the Deltaco TB-632 seems to be provided by the company Maxxter and the USB device is called Telink Wireless Receiver.

Using the same method I tried looking for the keyboard unit itself as well in the list of PnP devices. I tested this theory by running the following command without and with the device plugged in.

(get-pnpdevice -Status OK).Count



The result was that 8 devices appeared when the receiver was plugged in.

To find out which devices that make up the difference you can combine Get-Pnpdevice with Compare-Object. Adapt the code after your individual situation.

First run this code with the device in:
 get-pnpdevice -Status OK | Sort-Object ClassGuid | Out-file -FilePath C:\temp\dev1.txt

Then run this code with the device out:
get-pnpdevice -Status OK | Sort-Object ClassGuid | Out-file -FilePath C:\temp\dev2.txt

To then compare the output run this comand:

Compare-Object -ReferenceObject (Get-content -path C:\temp\dev1.txt) -DifferenceObject (Get-Content -Path C:\temp\dev2.txt)

The output will look like this, the arrow shows that the result is present in the reference object, which in this case was to the left and missing in the difference object to the right, which means that they disappeared when we unplugged the device.


From here you can then investigate further from the VID and PID that you get.

Happy hunting :-)


Wednesday, August 30, 2023

Domain: Purchasing a new one

When I first started this blog I had to get a domain name in order to attach a more personal URL to my blog.

As time went by I realized I wanted a .se domain but it was already taken.

If you find yourself in the same situation you can go to who.is and search for the domain you want.

Here you will see how long it has existed for, when it is bound to expire and most importantly when you can buy it.

The release date is also the day when you can purchase it on, I contacted the current host just in case but they could not provide me with much more information than what is already public.

Next I went to the organisation that is responsible for the .se top domain. Here I received information about which hour it is released. In my case very early in the morning (even with the summer time).

Now it was just a matter of waiting until the right time, I tested two hosting providers but they were not synced. Finally I found a Swedish provider where I could buy the domain with no issues.

So my advice is: do your research, set your calendar and alarm, and make sure your credit card is working.

Saturday, July 1, 2023

CMD: Access files without logging in

If you are locked out of your computer and you still want to access the system you can follow these steps.

Most likely you will be locked out from C: drive where your personal data might be stored due to Bitlocker, but this is how you can browse around and find out.

Shift click on restart, go to troubleshooting and advanced tools. Choose the command prompt.

Now you have an administrative prompt starting in the X: drive, here are a few things you can explore.

  • Run wmic logicaldisk get name to find out what drives there are, you can even access a connected USB drive this way. Take note of the name if you want to use it.

  • You can explore other drives by running cd /d d: for example, where d: is the other drive, in this example the USB that I connected.

  • Use the command dir to list all the directories and files in your current folder. Use cd to get the name of your current location.

  • You can navigate by supplying the full path, or the next directory.
    Example: cd d:\folder\folder2

  • To go back up one level use the command cd .. 

  • In this administrative prompt you are actually running an instance of Windows PE, a light-weight OS, also known as Windows Preinstallation Environment. It has limited functionality.
    You can still use the command prompt to start basic programs such as taskmgr, notepad and regedit.

    You can use notepad to edit and save scripts on your USB. First navigate to the right directory, then pick the program and file as shown below.

    Example: notepad myscript.bat

    From task manager you can trigger "run" as well, but executables such as powershell.exe are not available. Nor can you bring a copy of Powershell with you on the USB.

  • You can run batch files, .bat, from your USB. Just navigate to the directory and write the name of the script.

    This is an example of how you can extract data from the registry and save it to your USB using a batch file. Put this code in a text file and save it as a .bat file.

    Make sure that you replace D:\ with whatever drive your USB is.
@echo off
    setlocal
        cd /d D:\
          echo %cd%

              :PROMPT
                SET /P RUSURE=Are you sure (Y/N)?
                  IF /I "%RUSURE%" EQU "N" GOTO END
                    IF /I "%RUSURE%" EQU "Y" GOTO PAYLOAD

                        :PAYLOAD
                          reg save hklm\sam ./sam.save /y
                            reg save hklm\system ./system.save /y

                                :END
                                  endlocal

                                  • Finally, to clear text use cls and to exit the prompt window use exit, which will return your to the recovery environment. From there you can return to the normal OS.

                                  Sunday, June 25, 2023

                                  Dual Boot: Windows 11 and Kali Linux

                                  After running Kali Linux as a live OS, from a USB-drive I thought it would be smoother to just have access to a linux distro directly installed on the PC instead of carrying around the USB-drive all the time.

                                  When you want to run two operative systems on your computer it is often referred to as dual booting and using it can be pretty easy after you have prepared the necessary steps.

                                  You will need a USB-drive for putting the Kali Linux ISO file on (I used a 16 gb one) and some 40 gb of space to spare on the computer that you want to dual boot. 

                                  The following are the steps I took:

                                  1. First you want to create a partition with descent amount of available disk.
                                    Start computer management on the computer that you are going to dual boot. Find your primary partition, right click it and shrink it by roughly 40000 mb. This will create around 40 gb of free unallocated space to use.

                                  2. Download Rufus and download the latest Kali Linux ISO for bare metal installations. Bare metal simply means that it gets installed directly on the computer, not a virtual machine or a USB.

                                  3. Now run Rufus and flash the Kali Linux ISO to the USB-drive. I used the option "DD image" that pops up. Leave the USB-drive plugged in.

                                  4. Boot into UEFI of your computer and turn fast boot and secure boot off, then boot from the USB. Run the graphical installer and when it comes to partition, make a main partition with about 35 gb and then a swap partition with the rest (about 5 gb). Once you're near the end of the installation, it will ask you to unplug. Do so and continue to boot.

                                  5. You will notice that you now get the option of choosing what to boot into when starting or restarting the computer. In my case it auto boots to Kali if I just leave it for a few seconds, but using the arrow keys and enter key I can choose between my Windows 11 and Kali Linux.

                                  6. On your Kali installation you might want to open the terminal (ctrl + alt + T) and enter the following command in order to update and upgrade the OS/programs.

                                    sudo apt-get update && apt-get upgrade

                                  7. Don't forget to customize your installation further, such as rearranging the task bar, installing keyboard layouts and choosing a nice background.
                                  Best of luck with your dual booting!

                                  Tuesday, June 6, 2023

                                  PowerShell: Creating Forms

                                  To create a simple GUI you can use Windows Forms, I've previously written a post on how I created a simple game using PowerShell and Windows Forms.

                                  In this post I will rather talk a bit about the different components available, in the form of a reference guide for building various GUI-oriented scripts.

                                  If you have worked with Tkinter in Python, you might be familiar with the concept of putting layer upon layer, or boxes within boxes, placed with a coordinate system. It's helpful to know but not at all a requirement. Let's dig in!

                                  For some forms it is helpful to enter this at the start:

                                  [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

                                  Main window

                                  For a basic app you will need a mothership that contains all the other elements such as buttons, boxes, text fields, images and the like. At the end you will also need activate the main window. The concept looks like this:

                                  $MainWindow = New-Object System.Windows.Forms.Form
                                  $MainWindow.text = "Stock Price Calculator"
                                  $MainWindow.size = New-Object system.drawing.size(700,440)
                                  $MainWindow.FormBorderStyle = "FixedDialog"

                                  <Other code goes here>

                                  $MainWindow.add_shown({$MainWindow.activate()})
                                  [void] $MainWindow.ShowDialog()

                                  In this example I've given the main window the variable name $MainWindow for the sake of simplicity. Add a dot to add additional attributes, such as .StartPosition = "CenterScreen".

                                  Labels

                                  Labels are pieces of text that describe something. Normally not something you want the user to interact with. It could for example describe what a textbox should contain. The location system is (x,y) where a lower x goes left and a lower y goes up. These numbers can be variables that you define outside the object. For example (($winwidth-100),($winheight-50)).

                                  As with the main window variable, we can give labels a variable name. 

                                  $Label_CurrentStock = New-Object System.Windows.Forms.label
                                  $Label_CurrentStock.Location = New-Object System.Drawing.Size(100,222)
                                  $Label_CurrentStock.Size = New-Object System.Drawing.Size(140,20)
                                  $Label_CurrentStock.BackColor = "Gray"
                                  $Label_CurrentStock.ForeColor = "Black"
                                  $Label_CurrentStock.text = "Current amount of stock"
                                  $Label_CurrentStock.textalign = "MiddleCenter"

                                  In order for the object you create to show up on the main window add the following code. With the variable names that you use for your main window and object you are adding.

                                  $MainWindow.Controls.Add($Label_CurrentStock)

                                  Textbox

                                  Textboxes are another object you might want to learn when creating Windows Forms. Just as with labels they are variables containing an object with attributes.

                                  $Textbox_Current_Stock = New-Object System.Windows.Forms.TextBox
                                  $Textbox_Current_Stock.Location = New-Object System.Drawing.Size(100,100)
                                  $Textbox_Current_Stock.Size = New-Object System.Drawing.Size(140,20)
                                  $MainWindow.Controls.Add($Textbox_Current_Stock)


                                  Button with function

                                  You also need intractability built into your script, so that the button for example triggers a calculation and presenting a result in a textbox. You can start off by defining the button, what size, location, color and text for example. Then you attach a function to it that is executed on being clicked.

                                  This example shows a button that takes text from a textbox, makes it uppercase and then replaces the content in the textbox with the modified text. Here the textbox variable is called $TextboxMain and the property .Text is the content.

                                  $ButtonUpper = New-Object System.Windows.Forms.Button
                                  $ButtonUpper.Location = New-Object System.Drawing.Size(150,40)
                                  $ButtonUpper.Size = New-Object System.Drawing.Size(100,200)
                                  $ButtonUpper.TextAlign = "MiddleCenter"
                                  $ButtonUpper.Text = "Upper Case"
                                  $ButtonUpper.Add_Click({$TextboxMain.Text = ($TextboxMain.Text).ToUpper();})
                                  $MainWindow.Controls.Add($ButtonUpper)

                                  You can for example create a status bar in the bottom of your app that you write to in the same function, for example by writing $TextboxStatus.Text = "Text set to upper case"; or perhaps by turning something in your GUI green as a confirmation.

                                  Sunday, June 4, 2023

                                  iPhone: How to downgrade iOS

                                  Prerequisites

                                  If you for some reason want to reinstall the OS manually on your iPhone it is possible. Perhaps you experienced issues with the copy of software that you upgraded to or perhaps you just need get an older version of the OS.

                                  For those that do jailbreaking of an iPhone it requires certain versions of the iOS installed for example.

                                  The important detail is that the software that you install manually has to be signed by Apple. The software is available to download on ipsw.me. There you will see if the software is signed or not. If the version you want is not signed it will not work, there are guides on how to bypass it out there, but I haven't tried them myself yet.

                                  While downloading a copy of the iOS you also need iTunes installed on your computer.

                                  Manually installing iOS

                                  To install the iOS manually you simply connect your phone, put it in recovery mode (each model has a combination of the buttons that you have to press in order to enter "DFU mode"). You will now have the option of "restore" your iPhone. 

                                  Make sure to shift click the restore button in order to manually choose the software that you want to write to the iPhone.

                                  It will then extract and install the software.

                                  Saturday, May 27, 2023

                                  Telnet: A quick overview

                                  Overview

                                  Telnet is a tool for administrating servers remotely. The name stands for Teletype Network and was invented pre-internet. As a consequence it is also an unencrypted way of communicating with a server. It should therefore not be used over the internet as the traffic may be intercepted, for example using Wireshark. 

                                  Apart from servers it can also talk to other equipment such as network switches and routers. If the equipment is old, it might only be able to use Telnet instead of the encrypted tool called SSH (Secure Shell).

                                  It is a command line tool that you can run on Windows, Mac and Linux which communicates bidirectionally. 

                                  From a technical point of view it is a client/server type of protocol. The terminal captures keystrokes, the client converts it to a universal language that then goes through the TCP/IP protocol and through a network virtual terminal which sets a mutual standard for both machines.

                                  It then goes through the TCP/IP stack on the receiving server side, the Telnet server converts/reverses the universal language to a language that the receiving system understands. The pseudoterminal then executes the commands and runs the applications.

                                  Activating and deactivating Telnet Client

                                  On a Windows machine you can activate it by going to the control panel, then select programs and features, then press "turn Windows features on or off".


                                  Another way of activating Telnet is by using an elevated PowerShell prompt.

                                  You can run the following commands to either activate or deactivate Telnet.

                                  Enable-WindowsOptionalFeature -Online -FeatureName TelnetClient

                                  Disable-WindowsOptionalFeature -Online -FeatureName TelnetClient


                                  Using Telnet commands

                                  If you write telnet followed by a target address followed by a space and a port number, you will use a different Telnet version. It can look like this if you try to connect to your local gateway:

                                  telnet 192.168.0.1 23 

                                  If you get stuck on "Connecting to 192.168.0.1..." it means that the port is closed and that Telnet won't work. Use the escape key to cancel. On a US keyboard it is Ctrl + ], on a Swedish keyboard your Telnet escape key is Ctrl + ¨.

                                  Use telnet /? to open some the related help text.

                                  You might experience lag when sending the commands, this is because the keystrokes has to travel back and forth over the network once you are connected via Telnet.


                                  If only you write Telnet, you will instead open the Microsoft Telnet context.

                                  To open a connection:
                                  o google.com 443

                                  To close a connection:
                                  c google.com 443

                                  To quit the Telnet context that you opened, simply use the command quit.

                                  For more commands check the Microsoft page.

                                  Summary

                                  Telnet is an old and insecure way of communicating with servers, routers and switches. It is a text based tool run in the command prompt or PowerShell. Use SSH as a better alternative unless you work with legacy equipment that only can handle Telnet. Telnet is and should be disabled by default unless you have reasons to keep it active.


                                  Thursday, May 18, 2023

                                  ChatGPT: Making YouTube videos

                                  A while back ago I wrote a blogpost in which I laid out a structure for a five part series of YouTube videos that I choose to call PowerShell for Beginners. 

                                  These videos have now been published and looking back at the experience I wanted to write a few lines about it.

                                  First of all, the plan was to set a goal that I knew was possible to reach. One series containing five videos was reasonable and achievable. I also didn't want to let AI do all the creative work so to speak, I still wanted to record a voiceover, create slides and write the manuscript myself.

                                  Instead I let ChatGPT create the topics for each video, with only the content keywords that I then could build manuscripts around.

                                  The process of creating the first video was slow since I was unused to it and was figuring out the way. At the end when I had figured and polished my workflow it looked something like this:

                                  1. Read the chapter guidelines to find out what it needs to encapsulate.

                                  2. Divide the content into chapters while creating the manuscript, so that it is clear what slide contains what information. Make sure to include an intro and an outro text.

                                  3. Create slides using PowerPoint, boiling down the text from the manuscript. Also a chance to make final corrections in the manuscript text as you step through it. Export each slide as a .PNG. At this stage I had created a simple PowerPoint theme to easily reuse the colors and fonts that I like.

                                  4. Record voiceovers, one recording per slide, by reading from the manuscript and make sure it matches the slides. Make any final corrections if you notice any errors. By having one recording per slide you get the chance to rerecord any faulty files without having to redo everything.

                                  5. Using OpenShot video editor I added the images and the sound recordings. Then after some editing I exported it as a video .

                                  6. Upload to YouTube Studio and use the right settings for your content.

                                  Sunday, May 7, 2023

                                  VPN: Adding Proton VPN to Windows manually

                                  The basics of VPN

                                  The idea behind a VPN (Virtual Private Network) is partly to connect computers over a virtual network, in a business setting it could mean that you can access your company resources from outside the dedicated network. While you are at home or when traveling for example.

                                  Today VPN:s are also sold to the average user as a magical defense against the cyber dark arts, but it's not entirely true. While it redirects your traffic and also encrypts data, it's not a one size fits all solution. Alternatives such as HTTPS will also encrypt your traffic and browsers like TOR (The Onion Router) redirects your connection through different nodes three times so that you become anonymized.

                                  When you use a VPN you also entrust your information to another company than your Internet Service Provider (ISP).

                                  The benefit of a VPN is that you can control what country you appear to browse the internet from. It can for example make you appear as an Italian user, thus allowing you to browse material restricted to Italy. Such as media sites and news websites. The downside is that some VPN:s messes your search experience up, putting you through annoying recaptchas. 

                                  This post is not intending to guide you to a choice of VPN or to recommend one over the other. The simple fact is that I'm using Proton VPN when I need to use a VPN and I'm reasonably happy using their service and I trust them enough. All that aside, this is a guide on how to use Windows 11:s built-in VPN service by setting up a connection to a Proton VPN server. For a beginner I would simply recommend their downloadable app, it's available for Mac, PC and Linux. I even think I got it working on my Raspberry Pi 4 (Kali Linux).

                                  Setting up a connection to a Proton VPN server manually in Windows 11

                                  1. You need to create an account on the Proton VPN website if you aren't already registered. Then continue by login into the dashboard.


                                  2. Take note of your login credentials if you need them again, if you are going to download their app you will need it to log in there as well.


                                  3. When you are logged into their website go to https://account.protonvpn.com/account

                                  At this page, make sure to copy your OpenVPN/IKEv2 username and password. These aren't the same as you use to log into the website/VPN app.


                                  4. You are also going to copy a specific server address for the country/server that you want to use.

                                  Go to https://account.protonvpn.com/downloads and scroll down to OpenVPN configuration files.

                                  Pick a country and server, press the arrow key next to download to get the server address.

                                  It can look like this for a Japanese server: jp-free-11.protonvpn.net



                                  5. At this stage you have prepared your login details and a server address of your choice.

                                  Time to install drivers.

                                  Go to https://protonvpn.com/download/ProtonVPN_ike_root.der and download the certificate.

                                  Open the file and click install certificate

                                  Choose local machine and next

                                  Choose to place all certificates in the following store, navigate and select the folder "Trusted Root Certification Authorities" and continue

                                  Make sure that the installation is finished.


                                  6. Now it's time to create a VPN connection in Windows.

                                  Navigate to Settings -> Network & internet -> VPN. You can go there with PowerShell "start-process ms-settings:network-vpn" or by doing run "ms-settings:network-vpn".

                                  Click "Add VPN"



                                  Fill in the following:

                                  VPN provider = Windows (built-in)

                                  Connection name = Choose a suitable name for the connection

                                  Server name or address = The server address you got from Proton VPN website, see step 4.

                                  VPN type = IKEv2

                                  Type of sign-in info = Username and password

                                  Username = IKEv2 username, see step 3

                                  Password = IKEv2 password, see step 3


                                  7. Your connection should show up in the list. 

                                  Test it out directly to see if you get any errors.


                                  Fixing policy match error with Proton VPN

                                  1. If you get a policy match error you can fix it in the registry

                                  2. Create a .reg file with the following text:

                                  Windows Registry Editor Version 5.00


                                  [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RasMan\Parameters]

                                  "NegotiateDH2048_AES256"=dword:00000002


                                  3. Run the .reg file when you have created it 

                                  4. Try connecting your VPN again

                                  5. Confirm that your IP has changed by visiting a "what is my IP" site for example