RITESH'S BLOG

Just another TECHNICAL BLOG….

  • Categories

  • Archives

Archive for the ‘technology’ Category

How to Test the Working of your Antivirus – EICAR Test

Posted by RITESH JAIN on May 7, 2010

Have you ever wondered how to test your Antivirus software to ensure it’s proper working? Well here is a quick and easy way to test your antivirus. The process is called EICAR test which will work on any antivirus and was developed by European Institute of Computer Antivirus Research. This process can be used by people, companies and antivirus programmers to test the proper functioning of the antivirus/antimalware software without having to deal with the real computer virus which can cause damage to the computer. Here is a step-by-step procedure to test your antivirus.

Read the rest of this entry »

Posted in technology | 1 Comment »

Batch code for html to text conversion

Posted by RITESH JAIN on February 18, 2010

Hi friend here i am wirting code for converting html to text ….

This is a batch that cleanly converts Web documents into plain text files. You might have to convert the HTML file into DOS format by loading into EDIT then saving (or using other means) before converting if the source document is in UNIX format. This does not interpret codes like <br> or <p>, it goes only by the line breaks in the source. If it’s one of those documents where everything’s on one line, this won’t work very well. The WORDWRAP batch can help if the file comes out with long lines.

QBasic must be on the path, it is supplied with MSDOS versions 5 and above. To use, simply enter:

   html2 infile.htm outfile.txt

If you want to preserve embedded http/ftp hyperlinks then use:

   html2 infile.htm outfile.txt /link

(substitute the actual file names, they don’t have to be .htm and .txt)

HTML2.BAT removes all HTML tags that begin with a letter, ! or / then it converts &lt; &gt; < > &nbsp; &quot; & &amp; and &middot; codes to their proper characters, hopefully resulting in readable text or working batch code. It gets a little flaky when mixing &#.. codes and other & codes when right next to each other, but I think I can live with that.

This code has been HTML-converted for proper display. To recover the code, copy/paste from the browser screen or get the UTILBATS collection.

:: HTML2.BAT – HTML to text converter (c)2009,2010 RITESH JAIN
:: Syntax:  html2 infile.htm outfile.ext [/link]
::  /link option leaves hypertext urls in text
@echo off
if %2.==. goto done
if not exist %1 echo Input file not found
if not exist %1 goto done
echo.>%2
if not exist %2 echo Cannot create output file
if not exist %2 goto done
del %2
echo Working…
:: create temporary qbasic program…
echo> proc$.bas :on error goto closeout
echo>>proc$.bas open “%1” for input as #1
echo>>proc$.bas open “%2” for output as #2
::======== main loop – get input line ======
echo>>proc$.bas floop:line input #1,a$
::======== html code stripper ==============
echo>>proc$.bas q=1
echo>>proc$.bas qloop:p=instr(q,a$,”<“):if p=0 goto qend
echo>>proc$.bas q=p+1:if mid$(a$,q,1)=”/” goto qconv
echo>>proc$.bas if mid$(a$,q,1)=”!” goto qconv
echo>>proc$.bas if ucase$(mid$(a$,q,1))=lcase$(mid$(a$,q,1)) goto qloop
echo>>proc$.bas qconv:if p=1 then b$=”” else b$=left$(a$,p-1)
echo>>proc$.bas p=instr(q,a$,”>”):if p=0 goto qend
echo>>proc$.bas le=len(a$):if p=le then c$=”” else c$=right$(a$,le-p)
if not %3.==/link. if not %3.==/LINK. goto nolink
echo>>proc$.bas d$=mid$(a$,q,p-q):e$=lcase$(d$):r1=0
echo>>proc$.bas r=instr(e$,”http://&#8221;):if r=0 then r=instr(e$,”ftp://&#8221;)
echo>>proc$.bas if not(r=0) then r1=instr(r,e$,chr$(34))
echo>>proc$.bas if not(r1=0) then c$=”(“+mid$(d$,r,r1-r)+”) “+c$
:nolink
echo>>proc$.bas a$=b$+c$:q=q-1:goto qloop
echo>>proc$.bas qend:
::======== convert “&lt;” to “<” =========
echo>>proc$.bas a:p=instr(lcase$(a$),”&lt;”):if p=0 goto b
echo>>proc$.bas if p=1 then b$=”” else b$=left$(a$,p-1)
echo>>proc$.bas le=len(a$)-3:if p=le then c$=”” else c$=right$(a$,le-p)
echo>>proc$.bas a$=b$+”<“+c$:goto a
::======== convert “&gt;” to “>” =========
echo>>proc$.bas b:p=instr(lcase$(a$),”&gt;”):if p=0 goto c
echo>>proc$.bas if p=1 then b$=”” else b$=left$(a$,p-1)
echo>>proc$.bas le=len(a$)-3:if p=le then c$=”” else c$=right$(a$,le-p)
echo>>proc$.bas a$=b$+”>”+c$:goto b
::======== convert “<” to “<” =========
echo>>proc$.bas c:p=instr(lcase$(a$),”<“):if p=0 goto d
echo>>proc$.bas if p=1 then b$=”” else b$=left$(a$,p-1)
echo>>proc$.bas le=len(a$)-4:if p=le then c$=”” else c$=right$(a$,le-p)
echo>>proc$.bas a$=b$+”<“+c$:goto c
::======== convert “>” to “>” =========
echo>>proc$.bas d:p=instr(lcase$(a$),”>”):if p=0 goto e
echo>>proc$.bas if p=1 then b$=”” else b$=left$(a$,p-1)
echo>>proc$.bas le=len(a$)-4:if p=le then c$=”” else c$=right$(a$,le-p)
echo>>proc$.bas a$=b$+”>”+c$:goto d
::======== convert “&nbsp;” to ” ” =========
echo>>proc$.bas e:p=instr(lcase$(a$),”&nbsp;”):if p=0 goto f
echo>>proc$.bas if p=1 then b$=”” else b$=left$(a$,p-1)
echo>>proc$.bas le=len(a$)-5:if p=le then c$=”” else c$=right$(a$,le-p)
echo>>proc$.bas a$=b$+” “+c$:goto e
::======== convert “&quot;” to ” ===========
echo>>proc$.bas f:p=instr(lcase$(a$),”&quot;”):if p=0 goto g
echo>>proc$.bas if p=1 then b$=”” else b$=left$(a$,p-1)
echo>>proc$.bas le=len(a$)-5:if p=le then c$=”” else c$=right$(a$,le-p)
echo>>proc$.bas a$=b$+chr$(34)+c$:goto f
::======== convert “&” to “&” =========
echo>>proc$.bas g:p=instr(lcase$(a$),”&”):if p=0 goto h
echo>>proc$.bas if p=1 then b$=”” else b$=left$(a$,p-1)
echo>>proc$.bas le=len(a$)-4:if p=le then c$=”” else c$=right$(a$,le-p)
echo>>proc$.bas a$=b$+”&”+c$:goto g
::======== convert “&amp;” to “&” =========
echo>>proc$.bas h:p=instr(lcase$(a$),”&amp;”):if p=0 goto i
echo>>proc$.bas if p=1 then b$=”” else b$=left$(a$,p-1)
echo>>proc$.bas le=len(a$)-4:if p=le then c$=”” else c$=right$(a$,le-p)
echo>>proc$.bas a$=b$+”&”+c$:goto h
::======== convert “&middot;” to “·” =========
echo>>proc$.bas i:p=instr(lcase$(a$),”&middot;”):if p=0 goto wrline
echo>>proc$.bas if p=1 then b$=”” else b$=left$(a$,p-1)
echo>>proc$.bas le=len(a$)-7:if p=le then c$=”” else c$=right$(a$,le-p)
echo>>proc$.bas a$=b$+”·”+c$:goto i
::======== write line and loop ============
echo>>proc$.bas wrline:print #2,a$:goto floop
::======== done – close up ================
echo>>proc$.bas closeout:close #1:close #2:system
:: run the qbasic program…
qbasic /run proc$.bas
del proc$.bas
if exist %2 echo %2 text file created
if not exist %2 echo Something didn’t work…
:done

have some commment on it …..

Posted in technology | Tagged: | 1 Comment »

MD5

Posted by RITESH JAIN on January 28, 2010

What is MD5 Hash and How to Use it?

In this post I will explain you about one of my favorite and interesting cryptographic algorithm called MD5 (Message-Digest algorithm 5). This algorithm is mainly used to perform file integrity checks under most circumstances. Here I will not jump into the technical aspects of this algorithm, rather will tell you about how to make use of this algorithm in your daily life. Before I tell you about how to use MD5, I would like to share one of my recent experience which made me start using MD5 algorithm.

Recently I made some significant changes and updates to my website and as obvious I generated a complete backup of the site on my server. I downloaded this backup onto my PC and deleted the original one on the server. But after a few days something went wrong and I wanted to restore the backup that I downloaded. When I tried to restore the backup I was shocked! The backup file that I used to restore was corrupted. That means, the backup file that I downloaded onto my PC wasn’t exactly the one that was on my server. The reason is that there occured some data loss during the download process. Yes, this data loss can happen often when a file is downloaded from the Internet. The file can be corrupted due to any of the following reasons.

  • Data loss during the download process, due to instability in the Internet connection/server
  • The file can be tampered due to virus infections or
  • Due to Hacker attacks

So whenever you download any valuable data from the Internet it is completely necessary that you check the integrity of the downloaded file. That is you need to ensure that the downloaded file is exactly the same as that of the original one. In this scenario the MD5 hash can become handy. All you have to do is generate MD5 hash (or MD5 check-sum) for the intended file on your server. After you download the file onto your PC, again generate MD5 hash for the downloaded file. Compare these two hashes and if it matches then it means that the file is downloaded perfectly without any data loss.

A MD5 hash is nothing but a 32 digit hexadicimal number which can be something as follows

e4d909c290d0fb1ca068ffaddf22cbd0

This hash is unique for every file irrespective of it’s size and type. That means two .exe files with the same size will not have the same MD5 hash even though they are of same type and size. So MD5 hash can be used to uniquely identify a file.

How to use MD5 Hash to check the Integrity of Files?

Suppose you have a file called backup.tar on your server. Before you download, you need to generate MD5 hash for this file on your server. To do so use the following command.

For UNIX:

md5sum backup.tar

When you hit ENTER you’ll see something as follows

e4d909c290d0fb1ca068ffaddf22cbd0

This is the MD5 hash for the file backup.tar. After you download this file onto your PC, you can cross check it’s integrity by again re-generating MD5 hash for the downloaded file. If both the hash matches then it means that the file is perfect. Otherwise it means that the file is corrupt. To generate the MD5 hash for the downloaded file on your Windows PC use the following freeware tool

MD5 Summer (Click on the link to download)

I hope you like this post. For further doubts and clarifications please pass your comments. Cheers!

Posted in technology, Uncategorized | Leave a Comment »