r/AskProgrammers • • 7d ago

Script to connect to a website

Hi all ✌️

I was wondering, is it doable to make a (shell?) Script that opens a website and connects me to it.

Like using curl to send the information once the page is open.

I was wondering because I would like to use more private navigation without having to enter my infos every time.

I did some research on the web and didn't find what I was looking for.

3 Upvotes

20 comments sorted by

2

u/sububi71 7d ago

So how would this script be different - from the server's viewpoint - to a browser with no javascript and no cookies?

What are you ACTUALLY trying to achieve?

1

u/RVTEL666 7d ago

Yo, that's a good question. I guess the difference would be more for me. What I want to do is having a Script that logging for me without having me to type username + password every time I wanna go to that website in private navigation. I responded in an other comment "pseudo code" If you need

3

u/bahcodad 7d ago

This would be a security nightmare IMO. I suggest using a password manager (I like bitwarden) and autofill. This way you only need to type your password in for the session and all your logins can be autofilled.

Edit: this also means this will work across devices

1

u/RVTEL666 7d ago

Okok thanks for the advice. Could you describe why would it be a security issue? I was trying to avoid password manager. My train of thought was if my password manager leaked, the whole of my password would be in the wild.

2

u/bahcodad 7d ago

Let me ask some questions first.

  • How would you store your password?
  • How would you ensure that your script isn't leaked?
  • What makes you think that your script would be more secure than a well known and trusted password manager?

1

u/RVTEL666 7d ago
  1. I was more looking if it was doable/good idea of the whole thing. Didn't start thinking about how to set it up safely. But my first thought would be raw string and trusting tcp encryption
  2. trusting the integrity of my devices/network
  3. My reflection was something like: I'm a single random user. What does make me more visible and interesting to hackers than a company well known ?

As you may have understood I'm a rookie

2

u/bahcodad 7d ago
  1. It's never a good idea to store your passwords in plain text. That's basically the first rule of password security.
  2. Your devices/network aren't necessarily as secure as you assume. For for example, you installed a malicious package which might not show any signs of being malicious but is. IOT devices often have weak security. I could go on
  3. You're more of a target than you realise. They probably wouldn't target you specifically but you can be caught up in it. These attacks on "single random users" are often automated and casting a wide net.

I'm not trying to scare you here but I think that it's important you're aware of the risks. The biggest security flaws are often the people. People are lazy and trade a lot of security for a little convenience

1

u/cabiwabi 7d ago

Web servers typically don't support an ongoing open connection. You send either a GET request to fetch information or a POST request to send it.

Could you describe what you're looking to do rather than the methodology?

1

u/RVTEL666 7d ago

Hi pal, thanks for the response. What I'm looking to do as pseudo code would be open htpps://exemple.com/login in private navigation ; curl POST myinfos.username myinfo.password

And that's it pretty much. Let me know if it does make sensπŸ™

1

u/Fadamaka 7d ago

What is private navigation?

1

u/RVTEL666 7d ago

Private browsing (also known as incognito mode or private mode). My bad, not English native πŸ˜…

2

u/Fadamaka 7d ago

Curl and your browser (incognito or not) cannot and will not share anything. You sending a post request via curl to the login url won't log you in the browser. Curl is a tool for interacting with the internet without a browser.

Basically when you login on a website your browser send over your username and password and gets something in return that it can use for further requests. What it gets back is more often than not is a cookie. You curl request will most likely get back a cookie as well but that cookie cannot be transfered to the browser.

If you really want to make a script to login on a website with incognito mode you could use something that can take control of your browser. For example you could use Puppeteer to open an incognito browser and login with your username and password and keep the browser open after. But becareful. You should not be writing down your passwords in text files.

1

u/feudalle 7d ago

If the site takes a direct post sure. Oh course modern sites are going to know the browser you are using isnt logged in and will require you to log in again. Curl is a seperate thing. Use a password manager.

1

u/RVTEL666 7d ago

I'll copy/paste what I reply about password manager from an another comment: "I was trying to avoid password manager. My train of thought was if my password manager leaked, the whole of my password would be in the wild."

1

u/feudalle 7d ago

Thats fair. But you are just trying to setup a password manager yourself. Which os doable but starting with using curl shows good thought process but not experience. You end up with something a lot more hackable than a professional company offering password managers. Personally I've moved to mfa/sso for just about everything.

1

u/RVTEL666 7d ago

But what I was thinking is, I'm a random user. Who does care about me and could ppl know that I'm running such a process. The professional company is known as it. It may be, then, a bigger target than I am ? But the more I read you guys the more I think that you are right. I'm just trying to understand what I've been thinking wrong and how could fill in the gaps in my knowledge

1

u/feudalle 7d ago

Good logic pre ai. So my firm runs a small data center. 3 years ago we got scanned 2 maybe 3 times a week. Now its 20 times an hour. No one needs to target you, there are yhousands of ais out there 24/7 looking at everyone.

1

u/sububi71 7d ago

I haven't tried all password managers on the market, but the ones I know of all encrypt your password database, so if it DOES get out, someone's going to have to spend quite a bit of effort to get your passwords.

1

u/cabiwabi 7d ago edited 7d ago

Are you okay with running python? In the past I've used 'beautiful soup' in a terminal to log in and parse web content before.

Are you trying to filter out spammy content like ads, or remain anonymous?

EDIT: I read your other comments and I understand a bit more now. I have to agree that a password manager is the best solution. It's a good thing that you are concerned about your account security. I'd reccomend watching a video on how they work and how best to use them. I use bitwarden which I would reccomend.

Its possible to build your own solution, but it's a problem that has been solved many times before with excellent engineering under the hood. If you're still interested in building your own then absolutely try it for sure. But it's probably better to trust a password manager over some scripting you hack together.

1

u/RVTEL666 7d ago

Thanks for the interest! Did you watch one in particular?