3 ms·
This reminds me of the ugliest hack I have ever written. For context: passwords rotate every 90 days, there are different passwords for client facing and "inte
by dijit 7y ago
This reminds me of the ugliest hack I have ever written.
For context: passwords rotate every 90 days, there are different passwords for client facing and "internal" servers, (and different passwords for linux machines vs Windows machines).
All connections to client facing servers (which is my job) must go via:
1) a VPN
2) a "local" jumphost (both ssh/rdp), only accessible via VPN
3) a "remote" jumphost (also, both ssh/rdp), only accessible via the "local" jumphost".
Additionally; The majority of my servers are Windows based.
So, what do you do when everything goes wrong? well, you VPN with your "normal" password, and your 2FA RSA token. Then you rdp (or SSH) to the local jumphost with the same password as the vpn, then you rdp (or, ssh) to the remote jumphost with a different password, then you finally RDP into the machine that is interesting.
So, being the lazy git that I am, I wrote a program that scrapes my passwords from 1password, and ssh's into those jumphosts creating a tunnel all the way through. Then I call freerdp on localhost.
For this to work I had to do a bunch of ugly things like:
1) figure out the dimensions of my display and scale everything, because freerdp doesn't do this automatically.
2) call python from bash because getting a unique random socket requires binding to "port 0" which is not something I think is possible inside of bash.
3) do the same on each hop.
4) determine which password is needed based on the "domain" of the machine
5) detect if the machine is actually accessible or not (IE; are you on the VPN? is the machine actually "local"?)
Anyway, I should share the code, we can all revel in its ugliness.
- 1cvmask 7y agoWhen will you share it?