titbits from the world less travelled

Archive for August, 2008

Simple test for your firewalls when you buy one

Many of us would be of the opinion that you firewall would protect you from the ugly world. But this might not be the case. Even though your firewall works fine when you have logged in, it might not work when you have logged off.

Intruders can access a powered on machine with a login screen, even though you have logged off.
A simple test to start with can be:
1) Note down the ip address of your machine, using command prompt in windows.
2) Log Off
3) From some other machine, other than this try to ping this machine. If its possible to ping this machine with a firewall ON, then your firewall sucks. Its time to get our money back.
posted by admin in Uncategorized and have No Comments

Python script to download pictures/Jpegs/jpgs from a website

Here is script to download images, from a website. I have taken the example of zune.net to download the images to my local disk.

you can alter it as you please:

import sgmllib
import re

class MyParser(sgmllib.SGMLParser):
A simple parser class.

def parse(self, s):
Parse the given string s.
self.feed(s)
self.close()

def __init__(self, verbose=0):
Initialise an object, passing verbose to the superclass.

sgmllib.SGMLParser.__init__(self, verbose)
self.hyperlinks = []

def start_a(self, attributes):
Process a hyperlink and its attributes.

for name, value in attributes:
if name == href:
self.hyperlinks.append(value)

def get_hyperlinks(self):
Return the list of hyperlinks.

return self.hyperlinks

import urllib, sgmllib

# Get something to work with.
f = urllib.urlopen(http://www.zune.net/en-us/mp3players/backgrounds/default.htm)
s = f.read()

# Try and process the page.
# The class should have been defined first, remember.
myparser = MyParser()
myparser.parse(s)

# Get the hyperlinks.
#print myparser.get_hyperlinks()
hlist = myparser.get_hyperlinks()
for links in hlist:
var_extn = links[-3:]
if(var_extn == jpg):
finalURL = http://www.zune.net+links
print finalURL
start = finalURL.find(480×640_)
end = finalURL.find(.jpg)
finalName = finalURL[start:end]
image = urllib.URLopener()
image.retrieve(finalURL,finalName+.jpg)

posted by admin in python and have No Comments