r/ipfs • u/Ok-Supermarket-6747 • Oct 14 '22
Hiding sourcecode of html file in IPFS
I am trying to host a website on IPFS by uploading .html files
not sure if uploading these files directly is the right way to do it, but I have a login page and the password is visible in the html.
It doesn't show the sourcecode when run in a browser because I have disabled right click. However, I am not sure how to hide the code when I upload the .html file to IPFS, but still make it able to be run by whoever downloads it
3
Oct 14 '22
Still visible in view>developer>source.
It’s just text, can’t hide it.
-1
u/Ok-Supermarket-6747 Oct 14 '22
yeah I know html source is visible. I am gonna look into using some java…
1
u/Article_Used Oct 14 '22
… javascript?
java is to javascript as ham is to hamburger, fyi
1
u/Ok-Supermarket-6747 Oct 14 '22
javascript
1
u/topmilf Oct 14 '22
You can't hide the JavaScript either. You can obfuscate but with some effort it can be reconstructed. HTML and JavaScript (and CSS too) are executed client-side. And for the client to execute the code it needs to be able to read the code. And if the client can read the code, so can the user. Always. Preventing right-click, etc doesn't protect your content.
You could encrypt part of the HTML before publishing it and decrypt it client-side with a password, using AES for example. You will have to have include a library for AES decryption and some UI to use it.
But in general, you have completely the wrong approach for what you're trying to achieve. Username/password authentication is usually provided by a backend service that authorizes a user to access a protected resource. That resource isn't part of the same HTML as the login form.
Web security is a pretty deep rabbit hole in itself and if you're new to HTML and JS then security-related stuff isn't the best thing to start with.
1
u/Ok-Supermarket-6747 Oct 14 '22
Thank you! Very useful information❤️That makes sense that the code is executed client side and for my current purposes I don’t have the funds or need for a backend service (I assume third party?) though I will likely need it in the future (is there an ‘easy’ way to create my own backend service?)
For this project I think encrypting part of the code is exactly the route I need to go. The goal right now is to obfuscate but not necessarily make it impossible completely. Can I ask why you recommend AES over others?
Also, I am trying to understand IPFS as a repository. It is all public but I could ‘hide’ something simply by no one knowing where it is. Right now it seems the desktop client is a single node or ‘repository’ …is there a way to create another or would I need to run from another machine?
Also if I post php files I assume they wouldn’t run as smoothly client side as most users have html but not php installed? This confuses me because I could still view php websites before installing php.
Finally, how would I direct in the html or php login page to open to another file run by another IPFS node?
1
u/Hjulle Oct 23 '22
There are some free backend services available, so you could store the more sensitive data there and call out from that.
An alternative if you want it to be 100% on ipfs would be to encrypt the data using the password and use a javascript library to decrypt it. That way it doesn't matter if someone can read the source code, since it's all encrypted anyways.
2
u/the_good_time_mouse Oct 14 '22
1
u/Ok-Supermarket-6747 Oct 14 '22
don’t give them ideas 😭 I’m not that great at html yet, I don’t know how to make a better login portal.
1
u/Ok-Supermarket-6747 Oct 23 '22
Okay so I have an idea on how to hide the next html page...which is obviously needed for businesses etc...it's like budget security for startups...or maybe an experimental portal...Anyway,
Load the next page onto another node. It's still public and still needs to be pointed to from previous node...which would make it seen in the source code on the original node...but maybe we can...
take the CID, encrypt it and use that as the password for the first page. So the password has been one-way encrypted in the source code and only opens the next window if you get the password correct, by putting in the CID.
At this point you're thinking...if you know the CID why wouldn't you just go there already?
Well, maybe there is some kind of test to see if you are human...like sliding the puzzle piece or something...and then the page gives you the CID. So it is still accessible to all humans...but maybe at least not to bots.
And the second page could be deleted and reloaded weekly so it has a new CID and the first page is continually updated
1
u/volkris Oct 14 '22
I'm also worried about the next step.
What's being protected behind the login page, and what's to stop someone from skipping the password entry altogether and heading right for the other html files?
Hopefully the OP has a good answer for that!
1
u/Ok-Supermarket-6747 Oct 15 '22 edited Oct 15 '22
my idea for this is to host on another IPFS node. The html content will publicly exist but you won’t know where it is unless you have the password and therefore the link to direct to it
(Edit: if there’s only 74 of us on IPFS then this may be easier to find but I am hoping it will become more obscure as the network expands)
1
u/volkris Oct 16 '22
Firstly, the thing I worry about in your case is that you're thinking about setting up an html file with some javascript saying, "If user enters password, print super secret address XXXXX."
Nobody actually has to enter the password in that case. They can just open the file and get the secret address from the javascript text, skipping all the password stuff altogether.But on to IPFS:
Well it's not about which node. A core idea of IPFS is that it doesn't matter where data physically exists, whether here or there or on one node or a thousand.
If you know the address (CID) of data, IPFS will find a node that has it, all behind the scenes.
Keep in mind, when you add content to your IPFS node, your node actively reaches out to other nodes and broadcasts that it has it. The nodes kind of keep track of what each other have, and they share content between themselves, all behind the scenes.
Because again: the whole point is to get away from thinking of content as existing on this node or that node.
If you want something secret on IPFS you have to deal with encryption. There's no walling off content in this system that's specifically about getting past walls.
1
u/Ok-Supermarket-6747 Oct 16 '22
Yes, the approach I am taking is encryption I just haven’t found a function to use in html yet so I was looking at js. If I host the secret page on my same node, wouldn’t it be easier to find it even without the CID? I’m not sure about how the abilities are to search through the files of a specific node. So even if I redirect to a hashed/encrypted CID, it would still be better to keep it on a different node
1
u/volkris Oct 17 '22
No. From the operational/enduser perspective IPFS is all about there being no such things as nodes. It is a core principle of IPFS that effectively all data just lives out in the vague and amorphous cloud.
Think about it this way: if you're running a webserver, which track of hard drive or chip of ram is your webpage sitting on? Technically, yes, the data is sitting on some particular chip or square millimeter of hard disk platter, but we only think of the webserver as a whole.
Same with IPFS. Think of it as a whole system. You don't really host it on your node any more than a webserver hosts a webpage on its chip number three.
Technically fine, we do things like pin to our node or add a faster hard drive to a webserver, but all of that stuff is hidden to end users.
And again, keep in mind that (as I understand) any information that you add to any node is immediately broadcast to the rest of the cloud, which immediately means you can't think of the information as just being on one particular node.
1
u/Ok-Supermarket-6747 Oct 17 '22
Okay well in that case, is there a way for an external computer, which perhaps knows my IP, to find what files my specific computer is hosting? I assume I host the files I upload and other nodes help. How hard would it be to find which files my computer hosts?
1
u/volkris Oct 17 '22
Not only is there a way to find out, but your node will be actively advertising to everyone else that it has those files.
Every time you add a file, your computer will broadcast a message to the world saying, "Hey everyone! I have this file! So talk to me if you're looking for it!"
Your node WANTS everyone to know what files it's providing, so your node will actively try to let them know.
So again: if you upload something to IPFS, assume that you're uploading it to the entire cloud. Nothing you upload can be assumed to stay private to your node or to authorized nodes.
Like I said, don't think of IPFS in terms of nodes. It's a big cloud system. What you upload to IPFS effectively exists throughout that cloud, not in a specific node.
1
u/Ok-Supermarket-6747 Oct 18 '22 edited Oct 18 '22
There is a difference between files being openly available and knowing who is hosting them. I understand it is open for anyone to find but you still have to know what to look for. This does not answer the question of how closely my personal node or IP is attached to the content
Edit: Maybe I should have asked more clearly, where is that information about my node in the file path or in the source code of the page? and how would someone search my node for other files? Would they have a file path for it such as ipfs.io/thenodeiseek/content ?
1
u/volkris Oct 18 '22
I don't know how to put it any more simply since I feel like I answered your question multiple times above.
Your node broadcasts to the world the entire list of content it has, inviting the world to come to your node to get it.
In the difference between files being openly available and knowing who is hosting them, your node is broadcasting to the world that it is hosting the content and telling the world that you are hosting it.
Your node is itself telling everyone what you're uploading regardless of any webpage. This is a core part of IPFS.
1
u/Ok-Supermarket-6747 Oct 18 '22
I already understood the open-source, decentralized concept. Yes you are repeating yourself ad nauseam without providing technical detail that I need. I am looking for a code-based answer.
Or something like: You logon to IPFS and search for the CID of the resource. Once you get there, you copy the /thenode/file at the end of the URL, remove the file and redirect to all the resources hosted on that node.
Or something like: You paste the IPFS URL into your search bar, when the page loads you right click and display the sourcecode, You can find the node ID in line 23 under IPFS.<node2345>, add <node2345> at the end of the URL in the search bar to redirect to all resources hosted on that node
Anyway I think I found a good thread for building pages so I will be headed over there now and wonder about this along the way https://www.reddit.com/r/ipfs/comments/y6swre/how_does_ipfs_handle_mutability_of_subpages_of/
→ More replies (0)
1
u/namelesscreature0 Oct 14 '22
How did you disable right click?
2
u/Ok-Supermarket-6747 Oct 15 '22
I think it was <body>oncontectmenu=“return false”><body>
1
u/namelesscreature0 Oct 15 '22
If the site is deployed without IPFS, wget command can still access the page and see the contents, right?
1
u/Ok-Supermarket-6747 Oct 15 '22
If that's true then at that point you gotta be pretty brainy and will probably figure out how to get to the next page anyway
1
u/immibis Oct 28 '22 edited Jun 14 '23
1
u/Ok-Supermarket-6747 Oct 29 '22
I don’t have the funds to host it so it will have to be downloaded and run. Right now I am thinking github pages and ipfs further down the line
1
u/immibis Oct 29 '22 edited Jun 14 '23
1
u/Ok-Supermarket-6747 Oct 29 '22
No. Do they accept crypto? I have $2 in my bank account.
Edit: after Amazon charges me for a nightgown and some showerheads
1
u/immibis Oct 29 '22 edited Jun 14 '23
1
u/Ok-Supermarket-6747 Oct 29 '22
I tried a few places online already and this one is not easily dehashed
1
u/immibis Oct 29 '22 edited Jun 14 '23
Sex is just like spez, except with less awkward consequences.
1
0
Oct 14 '22
[deleted]
1
u/Ok-Supermarket-6747 Oct 14 '22
I’m just a n00b I wanna do it simple yet secure. I don’t mind hiding it behind third parties if it’s easier
2
0
Oct 14 '22
[deleted]
2
u/Ok-Supermarket-6747 Oct 14 '22
Thanks for the recommendation, I’ll definitely look into it
2
u/Article_Used Oct 14 '22
yeah passwords should never be stored in code. always encrypt stuff
1
u/Ok-Supermarket-6747 Oct 14 '22
This is for a login so it’s just a few lines which follows to the next page if ‘password’ entered, if not ‘popup box says try again’
1
u/Article_Used Oct 14 '22
but if your code says
var password = “secret”that’s not secure.correct way to do it would be
var password = “<encrypted pw here>”where “encrypted pw here” would be the output of
encrypt(“secret”)then when you’re checking if input is the right password,
encrypt(input) == passwordencrypt is a one-way algorithm, so even though i see the encrypted password in your code, i won’t be able to reverse engineer it.
see here for more info https://auth0.com/blog/hashing-passwords-one-way-road-to-security/
1
1
1
1
u/ferdau Nov 01 '22
Sorry for the late response but wanted to point out this is false.
Encryption is NOT a one-way algorithm. Hashing is a one-way algorithm.
Encryption is not the same as hashing.The entire use of encryption is that you can decrypt the value when needed. The entire use of hashing is that you can not get the original value.
9
u/amreo0x Oct 14 '22
It is not doable. In fact the source code can still be viewed in the browser in orher ways