0

I want to open a website(say www.google.com) automatically whenever I am logon. This can be achieved through batch script and VBA macros but it can not be implemented on organisational level due to security concerns.

Is there any secure way to open a particular website using some piece of code.

Please let me know. Thanks in advance.

Regards,

Shrikant Salunke

1 Answers1

0

There are lots of ways to do this, but I'm not sure exactly when you mean by "whenever I am logon".

Basically, if you want the most portable, multilingual way to open a web page with a program you are going to be passing a shell command that looks like this (following your example)

open https://www.google.com

This will open the specified URL (I think it must be a complete URL - including scheme) on the default browser.

Now the "when I am logon" part is what could make things complicated.

If by "when I am logon" you mean whenever you open your browser, then you don't even need to do this you can just reset your browser's homepage.

If you mean whenever you logon to your proxy, you just have to make sure that the first proxy request you send contains the correct request URI. In the case of google the correct URI would be google.com:443. The URI will have the format <hostname>:<portnumber>. The default HTTPS port number is 443. The default HTTP port number is 80.

If you mean whenever you logon to your system then you just need to execute the command open https://www.google.com within a login shell script. Login scripts are system dependent but you may refer to this post if you use a Unix-like or Posix compliant OS. If you use Windows I don't know how to help you but I'm sure there's a way to do it.

If you mean whenever you log into some program you wrote then things get really easy. You just have to make a call to that open command. Almost every language has a built in method for interacting with a shell. You just have to find that method in whatever platform you're using.

I honestly don't know if this will be helpful but good luck!

Edit

How to Run a Batch Shell Script Securely

What you need to do is run the script with a different trustlevel. Since you're using Batch you can do this by executing your script using the runas command (docs). This command allows you to adjust the trustlevel under which the script is executed without changing users. By changing the privileges of the executable, you can prevent it doing anything malicious. All it needs is enough "trust" to execute the open command.

If you need this fully automated throughout your organization, you can wrap your Batch file in a second Batch file that will call the runas command. This wrapper script will not run with reduced privileges but it also won't interact with the internet so you don't have to worry about it as much. You would be able to execute the wrapper script as a login script, and then everything should work.

Honestly I'm not a Windows person but I hope this helps!

Community
  • 1
  • 1
William Rosenbloom
  • 2,506
  • 1
  • 14
  • 37
  • Hey @William its really helpful for me. Thanks man. I just written this code open https://www.google.com into batch file but it has security concerns. I need to apply this at organisation level. So is there any secure way to do this. – Shrikant Salunke Dec 01 '15 at 06:37
  • @ShrikantSalunke What exactly do you mean by "organization level"? Do you mean you want to open a particular page whenever anyone logs into your VPN? – William Rosenbloom Dec 01 '15 at 06:38
  • organization level in the sense this should be apply on every system in organization so I want to avoid security concerns which could be caused by batch script. – Shrikant Salunke Dec 01 '15 at 06:47
  • @ShrikantSalunke ok I think I understand. Here's my second shot. – William Rosenbloom Dec 01 '15 at 07:06
  • Thank you for help. I will check with it and try to implement it. – Shrikant Salunke Dec 01 '15 at 10:11
  • Hey @William would you please help me out to create one secure batch script which will open "http:\\www.google.com" I am also trying but didn't understood the wrapper script concept. – Shrikant Salunke Dec 01 '15 at 10:32
  • @ShrikantSalunke so basically you have a Batch file (`A.bat`) that opens the web page. You should create a Batch file (`B.bat`) that executes the `runas` command on `A.bat`. You then use `B.bat` as a login script. – William Rosenbloom Dec 01 '15 at 12:30
  • Thanks William Rosenbloom. I will try and check. – Shrikant Salunke Dec 03 '15 at 04:31