Search This Blog

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.