Sunday, March 28, 2010

Entry 2: How to save time scanning your removable Flash Drive from Virus

Hey guys! I just want to share a very helpful precautionary measure that we can do for our beloved and susceptible computers running in Windows.

As we all know, computer viruses have been quite a headache (sad to say, I'm a victim of it now) and its fast propagation is commonly due to transfers from flash drives.

The basic mode of virus infection in flash drives is the autorun.inf file. This file, when altered by any type of harmful programs, automatically activates a command causing your system to be infested by naughty viruses, malwares, and adwares upon opening the flash drive.

But the catch is, we may use the autorun.inf file for our own convenience of knowing whether our flash drives contain viruses.

Logically speaking, the autorun.inf may be manually created such that it would contain a "Finger Print" of the owner (i.e. an icon). Whenever this "Finger Print" is lost, its a sign that the drive is infected.

How to do this:

Step 1: Choose an image you want to be your "Finger Print".

Example: Warning.jpeg

Step 2: Convert the image into a *.ico file. (http://www.coolutils.com/Online/Image-Converter/)

Step 3: Open notepad (or any editor that may serve the purpose).

Step 4: Create an autorun.inf file.


What does this mean?
[autorun] ------> declares that the file is an autorun.inf file
icon = .\warning.ico ------> specify the icon which you
will use as "Finger Print"
note: replace warning.ico with the
name of your converted image.
label=Virus ------> this will be your drive name.

Step 5: Save this as autorun.inf file.

Step 6: Copy both the autorun.inf file you made along with the converted .ico image into your flash drive.

Step 7: Your Done!


How it works:

Whenever you insert your healthy flash drive in your computer, it should show your "Finger Print" and thus, you are assured that your system is safe when you access your flash drive and you don't need to run any virus scans anymore (That saves time!).

On the other hand, when your flash drive gets infected by a virus, your personalized autorun.inf file gets overwritten by the virus-triggering autorun.inf file and so your "Finger Print" will not show indicating that your drive needs some cleanup before opening it.

Result:


Hope this helps!

Entry 1: Interfacing ADC using Parallel port with Python

This Python code will suffice the need of interfacing an ADC (analog-to-digital converter) using a Parallel Port. Tested with ADC0804 (8-bit ADC ).

'''This module facilitates ADC interfacing in Python using a Parallel port'''

__author__ = 'Aivin V. Solatorio'

import parallel
import ctypes

_ppt = ctypes.windll.simpleio
_ppt.init()

class ParallelADC(object):
'''Definition of ADC interfacing class'''
def __init__(self):
self.dataAdr = 0x0378
self.statAdr = self.dataAdr + 1
self.ctrlAdr = self.dataAdr + 2
def getData(self):
'''Acquires signal from data register'''
return _ppt.inp(self.dataAdr)
def setCtrl(self, val):
'''Dictates the value of control register'''
_ppt.outp(self.ctrlAdr, val)
def getStat(self):
'''Acquires value of status register'''
return _ppt.inp(statAdr)

'''Start of data gathering'''
gather_time = 100 #100 number of sample points
ADC = ParallelADC()

for i in xrange(gather_time):
lc = 0
ADC.setCtrl(0x32) #initializes ADC to start
ADC.setCtrl(0x36) #converting signal

while ((ADC.getStat() & 8) == 0) and (lc != 256):
lc += 1 #wait for ADC to finish converting
if (lc == 256):
print "Timed Out, check device or connection!"
else:
ADC.setCtrl(0x37)
value = ADC.getData() & 0xFF
ADC.setCtrl(0x36)

print "The ADC reading is: ", value #prints out ADC value