Home Page
  • July 19, 2024, 02:55:19 am *
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Official site launch very soon, hurrah!


Pages: [1] 2 3 ... 10
 1 
 on: July 12, 2024, 10:36:53 pm 
Started by Dakusan - Last post by Dakusan

Since I have been moving my primary workstation to Linux, I have been in need of finding a new password manager after Roboform failed me. I decided to try out KeePassXC but was having trouble since my Ungoogled Chromium browser was sandboxed in Flatpak. The instructions for this on Unix Stack Exchange were no longer working so I had to dig into it myself.


The 2 primary problems were that:
1) The browsers’ sandboxes did not have the QT libs.
2) The interprocess communication pipe socket had been renamed from kpxc_server to org.keepassxc.KeePassXC.BrowserServer.


The following are the instructions to get KeePassXC running in Flatpak versions of both Chrome and Firefox. This was tested on Linux Mint 21.3 with both Ungoogled Chromium and Firefox. You will need to change the KP_FLATPAK_PACKAGE if you use other versions of Chrome.

  1. Run the relevant below environment variables in your command shell before running the commands in the following steps:


    #Shared environment variables:
    KP_CUSTOM=/home/$USER/keepass-browser
    KP_JSON_NAME=org.keepassxc.keepassxc_browser.json

    #Chrome environment variables:
    KP_FLATPAK_PACKAGE=io.github.ungoogled_software.ungoogled_chromium
    KP_JSON_START=~/.config/chromium/NativeMessagingHosts
    KP_JSON_END=~/.var/app/$KP_FLATPAK_PACKAGE/config/chromium/NativeMessagingHosts

    #Firefox environment variables:
    KP_FLATPAK_PACKAGE=org.mozilla.firefox
    KP_JSON_START=~/.mozilla/native-messaging-hosts
    KP_JSON_END=~/.var/app/$KP_FLATPAK_PACKAGE/.mozilla/native-messaging-hosts
          
  2. Install and enable the browser extension:
    KeePassXD > Tools > Settings > Browser Integration:
    • Check “Enable Browser Integration”
    • Check “Chromium” and/or “Firefox”
    • Download the plugin listed on this screen in your browser
    • Click "OK"
    Note: This creates $KP_JSON_START/$KP_JSON_NAME
  3. Set up the needed files in the sandbox:

    #Put KeePass proxy and needed library files in user directory
    mkdir -p $KP_CUSTOM/lib
    mkdir -p $KP_JSON_END #Needed for firefox
    cp /usr/bin/keepassxc-proxy $KP_CUSTOM/
    rsync -a /usr/lib/x86_64-linux-gnu/libicudata* /usr/lib/x86_64-linux-gnu/libicuuc* /usr/lib/x86_64-linux-gnu/libicui* /usr/lib/x86_64-linux-gnu/libdouble* /usr/lib/x86_64-linux-gnu/libsodium* /usr/lib/x86_64-linux-gnu/libQt5* $KP_CUSTOM/lib

    #Copy the JSON file to the Flatpak app directory and change the executable path in the file
    cp $KP_JSON_START/$KP_JSON_NAME $KP_JSON_END/
    sed -i "s/\/usr\/bin\//"$(echo $KP_CUSTOM | sed 's_/_\\/_g')"\//" $KP_JSON_END/$KP_JSON_NAME
          
  4. Add permissions to the Flatpak:

    flatpak override --user --filesystem=$KP_CUSTOM:ro $KP_FLATPAK_PACKAGE #Only required if home directory is not shared to the Flatpak
    flatpak override --user --filesystem=xdg-run/org.keepassxc.KeePassXC.BrowserServer:ro $KP_FLATPAK_PACKAGE
    flatpak override --user --env=LD_LIBRARY_PATH=$(flatpak info --show-permissions $KP_FLATPAK_PACKAGE | grep -oP '(?<=LD_LIBRARY_PATH=).*')";$KP_CUSTOM/lib" $KP_FLATPAK_PACKAGE
          

 2 
 on: July 04, 2024, 01:37:42 am 
Started by Dakusan - Last post by Dakusan

Part 0: Installation

I’ve been moving from Windows to Linux recently and my latest software move attempt is Roboform, a password manager that I use in offline mode. Just running it under Wine works fine for the primary software interaction, but I was unable to get it fully integrated with its chrome extension. Below is the information for my attempt to get it working, in case someone could use the information or wanted to try continuing my attempts.

To move your RoboForm profile to Linux, copy the data from C:\Users\USERNAME\AppData\Local\RoboForm\Profiles\Default Profile to ~/.wine/drive_c/users/USERNAME/Local Settings/Application Data/RoboForm/Profiles/Default Profile.


Part 1: Redirect the extension to the executable

The chrome extension talks to its parent, rf-chrome-nm-host.exe, through the native messaging API. To direct the extension to talk to the windows executable you have to edit ~/.config/chromium/NativeMessagingHosts/com.siber.roboform.json and change the path inside it to /home/USERNAME/chrome-robo.sh, a script file that you will create. You can’t link directly to the rf-chrome-nm-host.exe because it has to be run through Wine, and the path cannot contain arguments.

Create a file with executable permissions at ~/chrome-robo.sh and set its contents to cd "/home/USERNAME/.wine/drive_c/Program Files (x86)/Siber Systems/AI RoboForm/9.6.1.1/"; /usr/bin/wine ./rf-chrome-nm-host.exe chrome-extension://pnlccmojcmeohlpggmfnbbiapkmbliob/ --parent-window=0.


Part 2: Debugging why it isn’t working

It should have worked at this point, but it still wasn’t, so I had to go further into debug mode. The full copy of the C source code can be found at the bottom of this post. Make sure to replace USERNAME in the source (and instructions in this post) with your username, as using “~” to specify your home directory often doesn’t work in this setup. You may also need to replace version numbers (9.6.1.1 for this post).

First, I created a simple C program to sit in between the chrome extension and the rf-chrome-nm-host.exe. All it did was forward the stdin/stdout between both programs (left=chromium, right=rf-chrome-nm-host.exe) and output their crosstalk to a log file (./log) that I monitored with tail -f. I pointed to the generated executable in the ~/chrome-robo.sh file.

All that was generated on the Linux config was: left=ping, right=confirm ping, left=get product info, END.

I then modified the program to specifically handle chrome native messaging packets, which are always a 4 byte number specifying the packet length, followed by the packet data (IsChrome=1). If this variable is turned off there is a place in the code where you can set a different executable with parameters to run.

Next, I ran the program in Windows with a working left+right config so I could see what packets were expected.

I then added a hack to the program (AddRoboformAnswerHacks=1) to respond to the 2nd-4th packets sent from the left (get-product-info, get-product-info, Initialize2) with what was expected from the right. rf-chrome-nm-host.exe crashed on the 5th packet, and debugging further from there would have taken too more time than I was willing to put in, so at that point I gave up.


Part 3: Trying with windows

I next decided to see if I could get the chromium extension to play nicely by talking directly to the rf-chrome-nm-host.exe on my Windows machine via an SSH tunnel. To do this, I changed the char *cmd[]= line to: char *cmd[]={"/usr/bin/ssh", "USERNAME@HOSTNAME", "cd c:/Program\\ Files\\ \\(x86\\)/Siber\\ Systems/AI\\ RoboForm/9.6.1.1; ./rf-chrome-nm-host.exe chrome-extension://pnlccmojcmeohlpggmfnbbiapkmbliob/ --parent-window=0", NULL};.

While the first 4 packets succeeded in this setup, the following packets (rf-api-request) were all met with: pipe open error: The system cannot find the file specified.  (error 2).

This was another stopping point because debugging this would also have taken too long. Though I did do some initial testing using Process Monitor and handle lookups in Process Explorer.


Part 4: The C source code

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <string.h>

FILE *SideLog; //This logs all events to the file "log"
FILE *RecordLeft; //This logs the exact packets that the left side sends to the file "left"
int IsChrome=1; //True for roboform chrome compatibility, false to just pass through data as is
int DisplayStatus=1; //Whether to show the "Status: x" updates
int AddRoboformAnswerHacks=0; //Whether to force send fake responses that the rf-chrome server is not responding to
const char* HomePath="/home/USERNAME/.wine/drive_c/Program Files (x86)/Siber Systems/AI RoboForm/9.6.1.1/"; //This must be set.
const char* ExePath="/home/USERNAME/.wine/drive_c/Program Files (x86)/Siber Systems/AI RoboForm/9.6.1.1/rf-chrome-nm-host.exe"; //This must be set. You can make sure rf-chrome-nm-host.exe is running with a 'ps'

//Send back a custom packet to the left. This will show in the log file BEFORE the packet it is responding to.
void SendLeft(char *str)
{
   char Buffer[255];
   int StrSize=strlen(str);
   *(int*)Buffer=StrSize;
   strcpy(Buffer+4, str);

   write(STDOUT_FILENO, Buffer, StrSize+4);
   fprintf(SideLog, "OVERRIDE REQUEST: %s\n\n", Buffer+4);
   fflush(SideLog);
}

//Forward data from left to right or vice versa. Also saves to logs and "left" file
void ForwardSide(int InFileHandle, int OutFileHandle, fd_set* ReadFDS, int IsLeft)
{
   //Exit here if no data
   if(!FD_ISSET(InFileHandle, ReadFDS))
      return;

   //Create a static 1MB+1K buffer - Max packet with chrome is 1MB
   const int BufferLen=1024*(1024+1);
   static char* Buffer=0;
   if(!Buffer)
      Buffer=malloc(BufferLen);

   //If not chrome, just pass the data as is
   char* Side=(IsLeft ? "left" : "right");
   if(!IsChrome) {
      int ReadSize=read(InFileHandle, Buffer, BufferLen);
      write(OutFileHandle, Buffer, ReadSize);
      if(IsLeft)
         fwrite(Buffer, ReadSize, 1, RecordLeft);
      Buffer[ReadSize]=0;
      fprintf(SideLog, "%s (%d): %s\n\n", Side, ReadSize, Buffer);
      fflush(SideLog);
      return;
   }

   //Read the 4 byte packet size and store it at the beginning of the buffer
   unsigned int PacketSize;
   read(InFileHandle, &PacketSize, 4);
   *(unsigned int*)Buffer=PacketSize;

   //Read in the packet and zero it out at the end for the string functions
   read(InFileHandle, Buffer+4, PacketSize);
   Buffer[PacketSize+4]=0;

   //Send fake product-info packet since rf-chrome-nm-host.exe was not responding to it
   if(AddRoboformAnswerHacks && IsLeft && strstr(Buffer+4, "\"name\":\"getProp\"") && strstr(Buffer+4, "\"args\":\"product-info\"")) {
      //The return packet with header at the front
      char VersionInfo[]="{\"callbackId\":\"2\",\"result\":\"{\\\"version\\\":\\\"9-6-1-1\\\",\\\"haveReportAnIssue\\\":true,\\\"haveBreachMon\\\":true,\\\"haveLoginIntoAccount\\\":true}\"}";

      //Simplistic version counter hack since chrome always sends 2 version info requests at the beginning
      static int VersionCount=2;
      VersionInfo[15]='0'+VersionCount;
      VersionCount++;

      SendLeft(VersionInfo);
   //Send fake initialization info packet since rf-chrome-nm-host.exe was not responding to it
   } else if(AddRoboformAnswerHacks && IsLeft && strstr(Buffer+4, "\"name\":\"Initialize2\"")) {
      SendLeft("{\"callbackId\":\"4\",\"result\":\"rf-api\"}");
   //Forward the packet to the other side and store in the "left" file if left side
   } else {
      write(OutFileHandle, Buffer, PacketSize+4);
      if(IsLeft)
         fwrite(Buffer, PacketSize+4, 1, RecordLeft);
   }

   //Output the packet to the log
   fprintf(SideLog, "%s (%d): %s\n\n", Side, PacketSize, Buffer+4);
   fflush(SideLog);
}

int main(void) {
   //Create pipes
   int pipe1[2]; //Parent writes to child
   int pipe2[2]; //Child writes to parent
   if(pipe(pipe1)==-1 || pipe(pipe2)==-1) {
      perror("pipe");
      exit(EXIT_FAILURE);
   }

   //Fork the current process
   pid_t pid = fork();
   if(pid==-1) {
      perror("fork");
      exit(EXIT_FAILURE);
   }

   //New (child) process
   if(pid == 0) {
      //Close unused ends of the pipes
      close(pipe1[1]); // Close write end of pipe1
      close(pipe2[0]); // Close read end of pipe2

      //Redirect stdin to the read end of pipe1
      dup2(pipe1[0], STDIN_FILENO);
      close(pipe1[0]);

      //Redirect stdout to the write end of pipe2
      dup2(pipe2[1], STDOUT_FILENO);
      close(pipe2[1]);

      //Move to the roboform home directory
      if(IsChrome) {
         if(chdir(HomePath) == -1) {
            perror("chdir");
            exit(EXIT_FAILURE);
         }
      }

      //Execute a command that reads from stdin and writes to stdout. The default is the chrome command. If not in chrome, you can fill in the exe and parameter you wish to use
      char *cmd[] = {"/usr/bin/wine", (char*)ExePath, "chrome-extension://pnlccmojcmeohlpggmfnbbiapkmbliob/", "--parent-window=0", NULL};
      if(!IsChrome) {
         cmd[0]="/usr/bin/php";
         cmd[1]="echo.php";
      }
      execvp(cmd[0], cmd);
      perror("execlp");
      exit(EXIT_FAILURE);
   }

   //---Parent process - forwards both sides---
   //Close unused ends of the pipes
   close(pipe1[0]); // Close read end of pipe1
   close(pipe2[1]); // Close write end of pipe2

   //Open the log files
   SideLog = fopen("./log", "w+");
   RecordLeft = fopen("./left", "w+");

   //Run the main loop
   int max_fd=pipe2[0]+1; //Other pipe is STDIN which is 0
   while(1) {
      //Create the structures needed for select
      fd_set read_fds;
      FD_ZERO(&read_fds);
      FD_SET(STDIN_FILENO, &read_fds);
      FD_SET(pipe2[0], &read_fds);

      struct timeval timeout;
      timeout.tv_sec = 10;
      timeout.tv_usec = 0;
   
      //Listen for an update
      int status = select(max_fd, &read_fds, NULL, NULL, &timeout);

      //Display "Status: x" if its setting is true
      if(DisplayStatus) {
         fprintf(SideLog, "Status: %d\n", status);
         if(status==0)
            fflush(SideLog);
      }

      //Exit on bad status
      if (status==-1) {
         perror("select");
         break;
      }

      //Check both sides to see if they need to forward a packet
      ForwardSide(STDIN_FILENO, pipe1[1], &read_fds, 1);
      ForwardSide(pipe2[0], STDOUT_FILENO, &read_fds, 0);
   }

   //Close pipes
   close(pipe1[1]);
   close(pipe2[0]);

   //Wait for the child process to finish
   wait(NULL);

   return EXIT_SUCCESS;
}

 3 
 on: May 02, 2024, 10:33:44 pm 
Started by Dakusan - Last post by Dakusan
Original post for RME Babyface Pro in Linux can be found at https://www.castledragmire.com/Posts/RME_Babyface_Pro_in_Linux.
Originally posted on: 05/03/24

After years of saying I’d do it, I'm finally moving my ecosystem from Windows to Linux. After some experimenting and soul searching, I've decided to go with Linux Mint, as it's not exactly Ubuntu with their atrociously horrible decisions, but it provides stability, ease of setup, and a similar enough interface to Windows so as to not lower my productivity.

Getting all of my legacy hardware working, including my 6-monitor setup, was mostly painless, but my beloved Babyface Pro (external professional audio mixer hardware) has been absolute hell to get working. It only natively supports Windows, OSX, and iOS for the “PC” (USB audio passthrough) mode, and the CC mode (class compliant) does not offer my custom waveform transforms. So, my only real option was to use the other analog input interfaces on the Babyface (XLR, SPDIF, or quarter inch audio).


The first hurdle was the power. Normally the device is powered through USB, however if I was going to be using the other audio inputs, I didn't want to leave the USB plugged in all the time, and the Babyface doesn't come with a power adapter. Fortunately, I had a 12V 1A+ power adapter in my big box of random power adapters. The second hurdle was when I discovered that the Babyface does not store the mixer settings when it's powered off. So, every time it gets powered on, it needs to be hooked to another (Windows) machine that can push the mixer settings to it. This also isn't too big a deal as I keep it on a UPS so it generally won't lose power, and if it does, I can use a VM to push the settings.

The next problem was deciding what interface to go through. I was really hoping to use SPDIF/optical since it is a digital signal that does not suffer from interference and degradation, but all the SPDIF interfaces I tried (4 in total) all sounded like garbage. I guess the SPDIF interface on the Babyface is a piece of Junk, which was very disheartening.


My only remaining option was using the analog inputs. I decided to use a mini (3.5mm; 1/8") stereo to quarter inch (6.35mm) mono splitter cord to run into “IN 3/4” and this worked perfectly. However, if the USB interface is plugged in at the same time then this actually creates very audible line noise on the analog inputs within the Babyface itself! This is a horrible design flaw of the device that I was shocked to run into. Fortunately, as mentioned in step 1, I already planned on having the USB cord unplugged, so not a deal breaker.

I first tried the headphone and line out jacks on my motherboard, but the audio quality was only at about 90%. I next tried the line out on my Creative Sound Blaster Audigy from 2014 and the audio was at about 95% quality. It also felt like a cardinal sin to plug in a PCIE 1.0 1x device (0.250 GB/s) into a PCIE 5.0 16x slot (63 GB/s) - lol. So, I bought a Sound Blaster Play 3! USB to mini audio adapter and the audio was perfect! I finally had my setup figured out.


As a fun note, I went to an audiologist a few days ago to have my hearing tested, and the waveform I had devised (through brute force testing) that I had been using through the Babyface for the last 7 years was the exact inverse of the results on the hearing loss frequency chart.


 4 
 on: April 14, 2024, 11:11:15 pm 
Started by Dakusan - Last post by Dakusan

The nulltypes system has been overhauled so all null types are under a generic type named NullType in the top level package. For example, instead of using nulltypes.NullUint8 you would now use NullType[uint8]. This also really helped clean up the null types code. This is a version breaking change, hence the minor version number update.

Other minor changes:
       
  •        Readme file and package information has been updated with the following changes:        
                     
    • The type support section has been redone for clarity
    •                
    • The structs in the code examples have had the members labeled to explain their used supported type
    •        
       
  •    
  • Marshled JSON strings are now properly json escaped
  •    
  • Added bypass for my RawBytes bug fix, now that it has been fixed in go v1.23
  •    
  • Removed test case that is no longer compatible with go 1.21+

 5 
 on: March 23, 2024, 08:44:56 am 
Started by Dakusan - Last post by Dakusan
Original update for Updated resume can be found at https://www.castledragmire.com/Updates/Updated_resume.
Originally posted on: 03/23/24
Regarding: Resume

I made a pretty massive overhaul of my resume. Both the PDF and the copy on this site’s resume section have been updated.


 6 
 on: March 16, 2024, 03:08:08 am 
Started by Dakusan - Last post by Dakusan
Original update for GoFasterSql project added can be found at https://www.castledragmire.com/Updates/GoFasterSql_project_added.
Originally posted on: 03/16/24
Regarding: GoFasterSql

GoFasterSQL is a tool designed to enhance the efficiency and simplicity of scanning SQL rows into structures in Go[lang].

While this project was first released in December of 2023 on github and has already had 7 releases there, I’ve finally gotten around to adding it here. I don’t anticipate there being many more releases any time soon as the project is feature complete.


 7 
 on: March 16, 2024, 02:50:14 am 
Started by Dakusan - Last post by Dakusan
Full content for the GoFasterSql project can be found at https://www.castledragmire.com/Projects/GoFasterSql.

Description: GoFasterSQL is a tool designed to enhance the efficiency and simplicity of scanning SQL rows into structures.
Information:

The flaw in the native library scanning process is its repetitive and time-consuming type determination for each row scan. It must match each field’s type with its native counterpart before converting the data string (byte array). Furthermore, the requirement to specify each individual field for scanning is tedious.


GoFasterSQL instead precalculates string-to-type conversions for each field, utilizing pointers to dedicated conversion functions. This approach eliminates the need for type lookups during scanning, vastly improving performance. The library offers a 2 to 2.5 times speed increase compared to native scan methods (5*+ vs sqlx), a boost that varies with the number of items in each scan. Moreover, its automatic structure determination feature is a significant time-saver during coding.


See the github page for full documentation.


Languages: MySQL, GoLang

 8 
 on: March 16, 2024, 02:33:50 am 
Started by Dakusan - Last post by Dakusan
Original update for Gol10n project added can be found at https://www.castledragmire.com/Updates/Gol10n_project_added.
Originally posted on: 03/16/24
Regarding: Gol10n

Gol10n is a highly space and memory optimized l10n (localization) library for Go (GoLang) pronounced “Goal Ten”.

While this project was first released in December of 2023 on github and has already had 5 releases there, I’ve finally gotten around to adding it here. I don’t anticipate there being many more releases any time soon as the project is feature complete.


 9 
 on: March 16, 2024, 02:00:13 am 
Started by Dakusan - Last post by Dakusan
Full content for the Gol10n project can be found at https://www.castledragmire.com/Projects/Gol10n.

Description: This is a highly space and memory optimized l10n (localization) library for Go (GoLang) pronounced “Goal Ten”.
Information:

Translation strings are held, per language, in text files (either YAML or JSON), and compile into .gtr or .gtr.gz (gzip compressed) files.


Translations can be referenced in Go code either by an index, or a namespace and translation ID. Referencing by index is the fastest, most efficient, and what this library was built for. Indexes are stored as constants in generated Go dictionary files by namespace, and are also held in the dictionary.


See the github page for full documentation.


Languages: GoLang

 10 
 on: March 16, 2024, 12:15:03 am 
Started by Dakusan - Last post by Dakusan
Original update for Site overhaul for the 21st century can be found at https://www.castledragmire.com/Updates/Site_overhaul_for_the_21st_century.
Originally posted on: 03/16/24
Regarding:

I finally got around to bringing this ~20 year old website somewhat up to date.
  • Hid ~10 old projects that noone would care about or are silly to download an executable for when a website could just as easily handle it.
  • Redid the projects page to list projects by type, cleaned up the layout, and removed the silly sorting and smart table stuff.
  • Changed background to a solid color instead of 1px stripes, which didn’t work well on mobile.
  • Fixed layout issues with dynamic section borders
  • Fixed other layout issues with CSS that are now compatible with modern browsers
  • Added mobile compatibility tags and standardized to webfonts for mobile compatibility
  • Fixed anything that used adobe/macromedia flash
  • Removed IE6 compatibility layer
  • Updated copyright and license information
  • Got rid of the silly glossary functionality
  • Made sure all links now use https instead of http
  • Added my email address to the contact page
  • Overhauled the search page

Pages: [1] 2 3 ... 10