quarta-feira, julho 06, 2022

Zsh on Windows via MSYS2

Source -> Visit the author

Zsh on Windows via MSYS2

set CHERE_INVOKING=1 & 
	set MSYSTEM=MINGW64 & 
	set MSYS2_PATH_TYPE=inherit & 
	set "MSYS2_PATH=D:\Users\USER\scoop\apps\msys2\current" & 
	set "PATH=%MSYS2_PATH%\usr\bin;%MSYS2_PATH%\mingw64\bin;%PATH%" & 
	"%ConEmuBaseDirShort%\conemu-msys2-64.exe" "/usr/bin/bash.exe" --login -i -new_console:p:C:"%MSYS2_PATH%\msys2.ico"

MSYS2

  • MSYS2 (usually upper case) consists of three relatively separate subsystems: msys2 , mingw32 and mingw64.
  • msys2 (sometimes called just msys) is an emulation layer — fully POSIX compatible but slow.
  • mingw subsystems provide native Windows binaries, with Linux calls rewritten at compile time to their Windows equivalents. For example, Git for Windows is a mingw64 binary (unlike msys Git which utilizes the compatibility layer and is therefore slow).
  • Each subsystem has its own shell and it’s important to be in the right one. The msys shell has a PATH starting with /usr/local/bin:/usr/bin:/bin:... while the mingw64 shell adds /mingw64/bin before it. This means that /mingw64/bin/git.exe is only available in the mingw64 shell.
  • MSYS2 comes with Pacman, a package manager ported from Arch Linux, and many packages installable by pacman -S <package>.
pacman -Syu # repeat if necessary
pacman -Su

$HOME

HOME = C:\Users\You
db_home: windows cygwin desc

ConEmu with mingw shell

  1. I didn’t hit any issues installing packages from the mingw shell.
  2. did hit issues installing mingw-w64-x86_64-git-lfs from the msys shell, because it uses git as part of its installation which is not in msys’ PATH.
  3. Worrying about two shells, two ConEmu tasks, two PATH configurations, etc. is IMO not worth it until proven otherwise.
set CHERE_INVOKING=1 & set MSYSTEM=MINGW64 & set MSYS2_PATH_TYPE=inherit & set “PATH=%ConEmuDrive%\msys64\mingw64\bin;%ConEmuDrive%\msys64\usr\bin;%PATH%” & %ConEmuBaseDirShort%\conemu-msys2–64.exe -new_console:p %ConEmuDrive%\msys64\usr\bin\bash.exe — login -i -new_console:C:”%ConEmuDrive%\msys64\msys2.ico”

Essential utilities

pacman -S man vim nano
pacman -S openssh rsync make
pacman -S zip unzip
pacman -S mingw64/mingw-w64-x86_64-jq

Git for Windows

[git-for-windows]
Server = https://wingit.blob.core.windows.net/x86-64
curl -L https://raw.githubusercontent.com/git-for-windows/build-extra/master/git-for-windows-keyring/git-for-windows.gpg |
pacman-key --add - &&
pacman-key --lsign-key 1A9F3986
pacman -Syu
pacboy sync git:x git-credential-manager:x git-lfs:x git-doc-html:x git-doc-man:x
$ git --version
git version 2.18.0.windows.1
$ git config --list --show-origin
# ... verifies that your ~/.gitconfig is read

Update Windows path

C:\msys64\mingw64\bin
C:\msys64\usr\bin
Microsoft Windows [Version 10.0.17134.112]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\Borek>git --version
git version 2.18.0.windows.1
C:\Users\Borek>ls -la
...

Zsh

pacman -S zsh
set CHERE_INVOKING=1 & set MSYSTEM=MINGW64 & set MSYS2_PATH_TYPE=inherit & set “PATH=%ConEmuDrive%\msys64\mingw64\bin;%ConEmuDrive%\msys64\usr\bin;%PATH%” & %ConEmuBaseDirShort%\conemu-msys2–64.exe -new_console:p %ConEmuDrive%\msys64\usr\bin\zsh.exe — login -i -new_console:C:”%ConEmuDrive%\msys64\msys2.ico”

Oh My Zsh

# Use the path where you installed Antigen
source "${funcsourcetrace[1]%/*}/antigen.zsh"
# Load Oh My Zsh
antigen use oh-my-zsh
# Example of how to add other useful things
antigen bundle zsh-users/zsh-completions
antigen apply
# Make /c/... autocompletion work, see Alexpux/MSYS2-packages#38
zstyle ':completion:*' fake-files /: '/:c'
# Convenient path navigation, e.g., `cd vp`
setopt CDABLE_VARS
vp="/c/Dev/VersionPress/versionpress"
temp="/c/Dev/temp"
# VSCode as an editor
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='vim'
else
export EDITOR='code-insiders --wait'
fi

Prompt

  1. It should be simple, like Pure.
  2. It must be asynchronous so that querying Git info doesn’t block the actual work.
antigen theme borekb/agkozak-zsh-theme@prompt-customization

terça-feira, maio 24, 2022

taskbar icons error or generic on windows 11 - Rebuild the Icon Cache

 https://www.tenforums.com/tutorials/5645-rebuild-icon-cache-windows-10-a.html



To Rebuild the Icon Cache in the Command Prompt


1 Close and save anything that you are working on before proceeding. The next steps will involve killing explorer and restarting the PC.

2 Open a command prompt.

3 Copy and paste each command below one at a time into the command prompt, and press Enter after each command.

ie4uinit.exe -show

taskkill /IM explorer.exe /F

DEL /A /Q "%localappdata%\IconCache.db"

DEL /A /F /Q "%localappdata%\Microsoft\Windows\Explorer\iconcache*"

shutdown /r /f /t 00

This last command will instantly restart the computer.

4 If the icons are still not displaying properly after rebuilding the icon cache, then download and merge the .reg file for the .ico (ICO) option here to restore the default associations of .ico (icon) files in Windows 10.

terça-feira, março 29, 2022

Run Google Chrome with different profiles in Windows

https://winaero.com/run-google-chrome-with-different-profiles/


 Chrome for Windows 10 supports the mentioned command line argument, --profile-directory. Use it as follows:

chrome.exe --profile-directory="profile name"
  1. Duplicate your existing Chrome shortcut. For example, select it on the Desktop, press Ctrl + C to copy it, then press Ctrl + V to paste. See this article: How to create a copy for a file quickly in Explorer.
  2. Right click the shortcut you created and select Properties from the context menu.
  3. Add the mentioned command line argument to the Target box:It will look as follows:
    chrome.exe --profile-directory="my other profile"

    Correct the profile name according to your preferences.

  4. Repeat these steps for all profiles you need to create and you are done.

Now, you can run different Chrome profiles using shortcuts you created simultaneously.

Run Google Chrome with different profiles on Linux

In Linux, you can create a special *.desktop file to launch the Chrome browser with an alternative profile. Do it as follows.

  1. Open the following folder with your favorite file manager:
    /usr/share/applications


  2. Find a file named "google-chrome.desktop" there.
  3. Copy that file to the folder
    /home/your user name/.local/share/applications

    If you don't have such a folder, then just create it.

  4. Rename the ~/.local/share/applications/google-chrome.desktop file to something else to indicate that it will refer to a custom profile.
  5. Edit it with your favorite editor. Change the Name section to something like Google Chrome (My Profile):
  6. Change all the Exec sections in the file to make them look like this:
    /usr/bin/google-chrome-stable --profile-directory="my other profile" %U

    So, you need to add the --profile-directory parameter to Chrome's command line.

  7. Repeat these steps for all profiles you need to create and you are done.

Your custom profiles will be visible in the apps menu of your Desktop environment. Here is how it looks in my XFCE+Whisker menu plugin:

That's it.

sexta-feira, março 18, 2022

INSTALL KALI LINUX ON WINDOWS 10 – WSL 2 KEX GUI HACKING SETUP

 Source for this is https://www.the-digital-life.com/install-kali-linux-wsl-2/

Please visit the souce.


INSTALL KALI LINUX IN WSL 2

First, install the Windows Subsystem for Linux by executing the following two commands. Alternatively, you can also search for “Turn Windows Features on or off”. Then you click on “Windows Subsystem for Linux” and “Virtual Machine Platform”.


dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart


Windows want’s you to restart your PC. After you did that you can now download the WSL 2 Kernel Modules and install the package:


https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi


Also, don’t forget to set WSL 2 as your default version with the following command:


wsl --set-default-version 2

Now, you’re ready to install Kali Linux from the Microsoft Store:


https://www.microsoft.com/en-us/p/kali-linux/9pkr34tncv07?activetab=pivot:overviewtab


Open the Kali Linux App, this will present you a console window, where you set up your username and password. You can also hide the welcome message by executing the following command in the terminal.


touch ~/.hushlogin

MAKE YOUR TERMINAL AWESOME

Kali Linux is now installed and you can use it to configure the system. However, the default console window doesn’t look nice. To change this you should use the “Windows Terminal”, which is a nice open-source project of Microsoft. I’ve recently made a video about how to make your WSL 2 terminal look awesome in Windows by setting up the Windows Terminal with zsh and a custom template, but only with Ubuntu WSL. However, this will also work exactly the same with Kali Linux. Check out my article, if you want to know how to set up this.


INSTALL KALI LINUX DESKTOP AND TOOLS WITH KEX

You should now have a cool Kali Linux terminal running in your WSL 2. But what about all the cool penetration testing tools? Because, the Kali Linux WSL version doesn’t come with any of these and doesn’t have any graphical user interface.


There is a pretty easy and quick solution to set up this in WSL, that is called Kex. Let’s install this in our Kali Linux and set up a Desktop environment and install the Kali Linux tools.


First, let’s update the package sources and install the newest distribution version of Kali Linux.


sudo apt update && sudo apt dist-upgrade

Then, you can install the Kali Linux Kex extension.


sudo apt install kali-win-kex

At least, you should also install the Kali Linux tools. There are different variants of tool-sets existing. I’ve chosen the “large” environment, so that you have all the tools.


sudo apt install kali-linux-large

USE THE DESKTOP ENVIRONMENT IN KALI LINUX WSL 2

We now have all necessary tools installed and you can simply run your desktop environment in Kali Linux WSL2. There are three different modes existing and I’ll show you them one by one.


WINDOW MODE WITH VNC

kex -s

WINDOW MODE WITH RDP

kex --esm -s

SEAMLESS MODE

kex --sl -s

segunda-feira, janeiro 10, 2022