Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Hosts File Related


  • Please log in to reply
11 replies to this topic

#1 Tehsplink

Tehsplink

  • Members
  • 120 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Near London
  • Local time:08:14 PM

Posted 02 January 2009 - 06:46 AM

I was wondering if there was a simple way to code an executable file which adds the specified text onto the end of the hosts file, much like Spybot Search&Destroy does in its 'immunization' process.
Another question, is how easy would it be to make it possible to check if updates were available, and if not then add them to the hosts file.


I never really got into the whole programming apart from some basic VB.NET and HTML.



Cheers,



James
Please PM me if i have been assisting you and do not reply for 24 hours!

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:01:14 PM

Posted 02 January 2009 - 11:29 AM

To add a line to a file, one needs to merely open it, append the line of text to the end, and then close the file. This is a common programming exercise for beginning programmers. I would rate this as an easy programming exercise.

To see if there is an updated version of a file, one needs to be able open a file locally, retrieve a file from a server somewhere, and then compare the two. Once any differences are found, then ad them to the first file. If one has programming experience with using web services, then this exercise is not too hard either. If not, this is extremely difficult.

#3 Tehsplink

Tehsplink
  • Topic Starter

  • Members
  • 120 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Near London
  • Local time:08:14 PM

Posted 02 January 2009 - 11:32 AM

Right, Thanks.



I'm talking not about a line or two, I'm talking about a huge/mass scale add, but also keeping all hosts file values already there. Its for a project my friend is wanting to work on, but he has no programming knowledge.
In short terms, if your not a programmer - you have no chance.



I kinda already knew that, but was just wondering if theres any sample code that i could put together to do this?
Please PM me if i have been assisting you and do not reply for 24 hours!

#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:01:14 PM

Posted 02 January 2009 - 01:22 PM

A huge, mass scale add is simply adding a single line at a time, and doing it over and over again, which as I already mentioned, is trivial. Using web services is not.

To do which part?

#5 Tehsplink

Tehsplink
  • Topic Starter

  • Members
  • 120 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Near London
  • Local time:08:14 PM

Posted 02 January 2009 - 01:45 PM

This guy who is kinda a mate of mine is basically looking for a small program, no install hopefully required, that simple adds lines fetched from a url to the hosts file to sort of make it blocked. Much like Spybot S&D's immunization.


It would be freeware, and he has no budget so he cant pay. I was just wondering if anyone had any ideas as to cost-free produce this.
If somebody else coded it they would get credit is what he says.
Please PM me if i have been assisting you and do not reply for 24 hours!

#6 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:01:14 PM

Posted 02 January 2009 - 05:27 PM

From where is the file being retrieved?

#7 Tehsplink

Tehsplink
  • Topic Starter

  • Members
  • 120 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Near London
  • Local time:08:14 PM

Posted 02 January 2009 - 05:29 PM

A webpage. Such as http://website.com/file.txt or file.xxx etc.
Please PM me if i have been assisting you and do not reply for 24 hours!

#8 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:01:14 PM

Posted 02 January 2009 - 07:25 PM

There is not generic solution to the question. How the program is written is specific to where it is being hosted. You can't just retrieve a file with the browser, because then the file would not have local access to the system, nor would any application on the system have access to the file. The browser sandboxes files away from the rest of the system for security purposes. Once the downloaded file is saved, then it can be accessed on the system. On Vista though it is problematic to alter the hosts file because of the file permissions.

If the file is being hosted on a system that uses web services, then there is an API that would tell you how to programatically retrieve the file. That is going to vary from web service to web service. From your description of the problem, you want to use a program to contact a web site, download a file, then compare the files, then add those lines to the host file that do not already exist. You can't do that from the browser. When I asked from where the file was going to be retrieved, I meant specifically where is it being hosted?

#9 Tehsplink

Tehsplink
  • Topic Starter

  • Members
  • 120 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Near London
  • Local time:08:14 PM

Posted 03 January 2009 - 06:49 AM

Hey there, thanks for your fantastically geeky answers and keep them coming :thumbsup:


The file is not yet being hosted, but it would be hosted of a webserver of some kind.
And I know that using a browser isn't possible for this; My friend means something like Anti-Virus Updates, where it downloads a file, checks if they're the same, and if they are not then it adds the missing values.
This would probably be silent, with a notice when it would be finished.


But if you would like i can tell him to stop dreaming and start learning?



Cheers,


James
Please PM me if i have been assisting you and do not reply for 24 hours!

#10 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:01:14 PM

Posted 03 January 2009 - 09:24 AM

But if you would like i can tell him to stop dreaming and start learning?

I suppose. Nobody in the world can design the code unless they know how it is being hosted. :thumbsup:

#11 Tehsplink

Tehsplink
  • Topic Starter

  • Members
  • 120 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Near London
  • Local time:08:14 PM

Posted 03 January 2009 - 09:36 AM

But if you would like i can tell him to stop dreaming and start learning?

I suppose. Nobody in the world can design the code unless they know how it is being hosted. :thumbsup:

I already said ;)

The file is not yet being hosted, but it would be hosted of a webserver of some kind.


Please PM me if i have been assisting you and do not reply for 24 hours!

#12 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:01:14 PM

Posted 03 January 2009 - 09:44 AM

"A web server of some kind" tells me nothing. It's like saying "I'll be buying a car of some kind." Unless one specifically knows how it is going to be hosted, and how it is going to be made available via the server, nobody can write the code. So when you next say, "It will be running Linux," I say, "I'll be driving a Chevy." When you say "It will be running Ubuntu Server," I say, "My Chevy will be red." You have no better an idea of what sort of vehicle I am going to be driving that I have about how the file is going to be hosted, or how an outside application will be allowed to access it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users