Can a computer get infected with virus just by visiting malicious website or only when you download something from it?
One common way that malicious websites infect computers is through drive-by downloads. This is when a website automatically downloads and installs malware onto your computer without your knowledge or consent. Drive-by downloads can occur when you visit a malicious website, click on a malicious link, or even just hover your mouse over a malicious element on the page.
Another way that malicious websites can infect computers is through browser exploits. These exploits take advantage of vulnerabilities in your web browser to allow attackers to execute arbitrary code on your computer. This code can then be used to install malware, steal your personal information, or even take control of your computer.
To protect your computer from malicious websites, it is important to keep your web browser and operating system up to date, and to use a reputable antivirus program. You should also be careful about clicking on links or downloading files from unfamiliar websites. If you are not sure whether a website is legitimate, it is best to err on the side of caution and avoid visiting it.