Modify browser JS into Node JS script
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I have a JS script from a third party that is currently being run inside a browser upon user clicking on a button. It accepts an input string and then outputs some encrypted string. I need this to work inside a Node JS app where I can just import this script and call it with a simple function with an input parameter and then receive the output. And if possible also remove any DOM manipulation codes as well.

Thanks!

The zip file can be downloaded here:
https://filebin.net/9tiysa43wfti8f2u

Since the code is trying to connect to a Websocket server, it's actually pretty difficult to refactor the code and make sure that it works without having access to some sort of Websocket server that does the actual encoding. Can you send a sample response from the server?
kostasx 28 days ago
Are you able to point out to which part of the code you need the sample response from and I'll try to get a console output.
user0809 28 days ago
Inside the support-client.js, inside the var conn = function(){ and in ws.onmessage = function (e) {, you can JSON.stringify the e value so that we have a better understanding of what comes out the other end.
kostasx 28 days ago
I added a console.log function to output the e value but that part of the script either doesn't called or for some reason isn't outputting anything in console when the whole script is run.
user0809 28 days ago
Hi! I've investigated this a bit too. It seems that the client-side program is required for this script to work. The program is a SafeNet Authentication Client for PKI-Based Authentication Management. The SafeNet's authentication program is used to protect communications between client and server. If I may say so if the end goal is to just encrypt a string, can't we just use one of the standard encryption algorithms?
VladimirMikulic 28 days ago
I'm open to it if it works :)
user0809 28 days ago
But just to add that the script requires an authentication USB key plugged in to work and after unplugging it, the script doesn't encrypt anymore.
user0809 28 days ago
So, you use this SafeNet's program? In that case, it is more than simple string encryption. If it is not secret, how will your Node.js app be used?
VladimirMikulic 28 days ago
It's just for sending some data to the third party when they request it from our server but for some reason they're requiring this extra step to add an encryption key before sending the data.
user0809 28 days ago
Judging by the code, this appears to be for an eCommerce platform. Without this client-side software, it's simply not possible to generate the right encryption key. (we don't know the algorithm used for this)
VladimirMikulic 28 days ago
They also have a PHP script which seems to be a conversion of the javascript code, are you able to take a look at the attached php zip file and see if it's possible to find out the algorithm? https://filebin.net/9tiysa43wfti8f2u Thanks!
user0809 28 days ago
Unfortunately, the PHP code does the same thing as our JavaScript, just in PHP, of course. It still requires us to have this eCommerce program installed and running on our machine. This program then exposes Web Socket server which we connect to and get the encryption key.
VladimirMikulic 28 days ago
If I send you a TeamViewer remote access would it work for you? It's running on a barebones Windows Server 2008 virtual machine right now.
user0809 28 days ago
If that's where your app is running, then it would certainly be helpful to get a bigger picture.
VladimirMikulic 28 days ago
Okay no problem, do you have Telegram? It's easer this way and I can also send you the credentials.
user0809 28 days ago
Yes, I do. My username is the same as this one on Bountify.
VladimirMikulic 28 days ago
I sent you a message, did you receive it?
user0809 28 days ago
Received.
VladimirMikulic 28 days ago

Crowdsource coding tasks.

1 Solution


Solution

A wild ride but we did it :)

Thank you so much for your effort and hard work!
user0809 28 days ago