website automation
overview
Have you ever had to constantly log into 40+ different systems just to check something?
Ever wish you could just use a cli instead to check on something quickly on a website?
Well you can do this and so much more, essentially you can quickly and easily generate your own API's for websites to automate for free! and securely too!
set up overview todo: add code
despite my love for linux, this was all done on windows, but can easily be transferred to linux.
1. encrypt credentials, firstly we need to be as secure as possible but maintain ease of use, so there are two convienient ways to do this, we store an encrypted file with our logins on our PC using windows dpapi now we can either load this directly into our scripts, or load it into powershell as $env. I prefer $env as if password changes etc you can update for session only and update the encrypted file another time.
Why is this good? Well windows will auto decrypt this file when you're logged in, and no password for decryption ever needs to be saved. If someone is on your PC then they probably already can get at the passwords via browser instead so this is limited risk.
2. we use the browser networking tab to work out what the browser is doing during key things we care about - login + specific pages, most pages are just a POST/GET/PATCH to a specific URL, so we can emulate that easily enough in say python
3. Once main features are emulated, we can write our own API to access them, lets say searching on a specific page, we could add a powershell alias for our script to just 'tt' and then type tt -s "seach this" and then get the response straight to our cli, no login information required.
4. Saving sessions, to speed up the above and limit 2FA requirements, we should save sessions encrypted with windows dpapi as well.
5. The cool thing is that since most responses are structed json or similar, it is very easy to parse this data and get very clear responses for the things you care about - say for instance a page had a large table with lots of numbers but you only care about ones that are too high/low? Well you can simply parse it using above steps, and then output highest/lowest values so you can instantly check - hell you can run this on a loop and send an alert to a webhook/email/etc if value is outside a good range
actual code and design
todo: