Thursday, October 20, 2011

CUPSPDF

http://embraceubuntu.com/2006/03/23/print-to-pdf-using-cups-pdf/

Thursday, October 13, 2011

Wednesday, October 12, 2011

Python File Globbing

#!/usr/bin/python
#Author: Balasubramaniam Natarajan
#Date: 12-Oct-2011
#Purpose: Demonstrating File Globbing using python
import glob

find = raw_input("Enter the file or directory to be searched : ")

result = glob.glob(find)

if result:
 for element in result:
  print element
 print "The total number of files are : ", len(result)
else:
 print "No match found"

#END

Output

bala@bala-laptop:~/python$ python glob.py
Enter the file or directory to be searched : /home/bala/Pictures/*.jpeg
/home/bala/Pictures/dslInside.jpeg
/home/bala/Pictures/RSA_Thumbnail.jpeg
/home/bala/Pictures/dslDMZ.jpeg
/home/bala/Pictures/dslOutside.jpeg
/home/bala/Pictures/python.jpeg
The total number of files are :  5
bala@bala-laptop:~/python$

McAfee's Free Tools

http://www.mcafee.com/us/downloads/free-tools/index.aspx

http://www.mcafee.com/us/downloads/free-tools/stinger.aspx

Get Suspected files
https://kc.mcafee.com/corporate/index?page=content&id=KB69385

Monday, October 10, 2011

Python RE

#!/usr/bin/python
#Author: Balasubramaniam Natarajan
#Demonstrate how to use Regular Expression to match email
import re

re1 = re.compile('\d+',re.IGNORECASE)

f1 = open("data2","r")
f2 = open("changedfile","w")

for searchstr in f1.readlines():
#The count is optional, this will change the number of occurance in the line.
#IF count is not given it will change every match in that line
  print re1.sub("Changed_here",searchstr,count = 2)
  changed = re1.sub("Changed_here",searchstr,count = 2)
  f2.writelines(changed)

#END

Output

bala@bala-laptop:~/python$ cat data2
4562
234
 15.00
 1
234.234.234.234

bala@bala-laptop:~/python$ python RE.py
Changed_here

Changed_here

 Changed_here.Changed_here

 Changed_here

Changed_here.Changed_here.234.234

bala@bala-laptop:~/python$ cat changedfile
Changed_here
Changed_here
 Changed_here.Changed_here
 Changed_here
Changed_here.Changed_here.234.234

bala@bala-laptop:~/python$

Python RE

#!/usr/bin/python
#Author: Balasubramaniam Natarajan
#Demonstrate how to use Regular Expression
import re

def search(searchstr):
    print "*********************************"
    print "searchstr = ", searchstr
    print "*********************************"

searchstr = raw_input("Enter a searching string '\d+\s+\w+' : ")
search(searchstr)

re1 = re.compile('\d+\s+\w+',re.IGNORECASE)

#Finditer will return a search which we are iterate through
finditer = re1.finditer(searchstr)

if finditer:
   for i in finditer:
    print i.group()
else:
   print "No search match"

#END

Output

bala@bala-laptop:~/python$ python RE.py
Enter a searching string '\d+\s+\w+' : Those are 500 toys, 100 games and 20 infants
*********************************
searchstr =  Those are 500 toys, 100 games and 20 infants
*********************************
500 toys
100 games
20 infants
bala@bala-laptop:~/python$

Python RE

#!/usr/bin/python
#Author: Balasubramaniam Natarajan
#Demonstrate how to use Regular Expression
import re

def search(searchstr):
    print "*********************************"
    print "searchstr = ", searchstr
    print "*********************************"

searchstr = raw_input("Enter a searching string '\d+\s+\w+' : ")
search(searchstr)

re1 = re.compile('\d+\s+\w+',re.IGNORECASE)

#Match will look only at the start of the string
match1 = re1.match(searchstr)
#Search will look even in the middle of the string
search = re1.search(searchstr)
#Findall will look even look for additional matches in the string
findall = re1.findall(searchstr)

if match1:
   print "match1 Matching \d+\s+\w+ : ",match1.group()
if search:
   print "Search matching \d+\s+\w+ : ",search.group()
if findall:
   print "Findall matchin \d+\s+\w+ : ",findall
else:
   print "No search match"

#END

Output

bala@bala-laptop:~/python$ python RE.py
Enter a searching string '\d+\s+\w+' : 500 apples
*********************************
searchstr =  500 apples
*********************************
match1 Matching \d+\s+\w+ :  500 apples
Search matching \d+\s+\w+ :  500 apples
Findall matchin \d+\s+\w+ :  ['500 apples']

bala@bala-laptop:~/python$ python RE.py
Enter a searching string '\d+\s+\w+' : Those are 500 toys
*********************************
searchstr =  Those are 500 toys
*********************************
Search matching \d+\s+\w+ :  500 toys
Findall matchin \d+\s+\w+ :  ['500 toys']

bala@bala-laptop:~/python$ python RE.py
Enter a searching string '\d+\s+\w+' : Those are 500 toys and 100 games
*********************************
searchstr =  Those are 500 toys and 100 games
*********************************
Search matching \d+\s+\w+ :  500 toys
Findall matchin \d+\s+\w+ :  ['500 toys', '100 games']
bala@bala-laptop:~/python$



Friday, October 7, 2011

Disable Registry & Taskmgr

  • The newly created Registry Values are:
    • [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]
      • DisableRegistryTools = 0x00000001
      • DisableTaskMgr = 0x00000001

      to disable the Windows registry editors (Regedt32.exe and Regedit.exe)
      to prevent users from starting Task Manager (Taskmgr.exe)
       
       
      http://www.threatexpert.com/report.aspx?md5=8baf88111af782aaef0a0581b47ced68

Monday, October 3, 2011

Python Regular Expression

#!/usr/bin/python
#Author: Balasubramaniam Natarajan
#Demonstrate how to use Regular Expression
import re

def search(searchstr):
    print "*********************************"
    print "searchstr = ", searchstr
    print "*********************************"

searchstr = raw_input("Enter a searching string : ")
search(searchstr)

re1 = re.compile('\w+\s\w+\s\w+\s\d',re.IGNORECASE)
match1 = re1.match(searchstr)

if match1:
   print "Matching \w+\s\w+\s\w+\s\d : ",match1.group()
else:
   print "No match"

#END

Output

bala@bala-laptop:~/python$ python RE.py
Enter a searching string : Apples cost RS 20
*********************************
searchstr =  Apples cost RS 20
*********************************
Matching \w+\s\w+\s\w+\s\d :  Apples cost RS 2
bala@bala-laptop:~/python$

Python Regular Expression

#!/usr/bin/python
#Author: Balasubramaniam Natarajan
#Demonstrate how to use Regular Expression
import re

def search(searchstr):
    print "*********************************"
    print "searchstr = ", searchstr
    print "*********************************"

searchstr = "This is a test string"
search(searchstr)

re1 = re.compile('^T')
match1 = re1.match(searchstr)
print "Match for '^T' = ", match1.group()

re1 = re.compile('.*',re.DOTALL)
match1  = re1.match(searchstr)
print "Match for '.*' = ", match1.group()

searchstr = "this is first line\nthis is second line"
search(searchstr)

re1 = re.compile('.*',re.DOTALL)
match1 = re1.match(searchstr)
print "Match for '.*',re.DOTALL = ", match1.group()

re1 = re.compile('line$')
match1 = re1.match(searchstr)
print "Match for 'line$' = ", match1

re1 = re.compile('[a-z]')
match1 = re1.match(searchstr)
print "Match for '[a-z]' = ", match1

# Repeating metacharacter * (Zero or many), + (One or many), ? (Zero or one)

re1 = re.compile('[a-z]+')
match1 = re1.match(searchstr)
print "Match for '[a-z]+' = ", match1.group()

re1 = re.compile('[a-z]+.*')
match1 = re1.match(searchstr)
print "Match for '[a-z]+.*' = ", match1.group()

#The BackSlash will be interepreted by python to avoid that we specify lowercase r "raw expression"
#The \s stands for the space
re1 = re.compile(r'[a-z]+\s')
match1 = re1.match(searchstr)
print "Match for '[a-z]+\s' = ", match1.group()

#Here we want the next word as well
re1 = re.compile(r'[a-z]+\s[a-z]+')
match1 = re1.match(searchstr)
print "Match for r'[a-z]+\s[a-z]+' = ", match1.group()

re1 = re.compile(r'[a-z]+\s[a-z]+\s[a-z]+\s[a-z]+')
match1 = re1.match(searchstr)
print "Match for r'[a-z]+\s[a-z]+\s[a-z]+\s[a-z]+' = ", match1.group()

searchstr = "This is first LINE"
search(searchstr)

re1 = re.compile(r'[a-z]+\s[a-z]+\s[a-z]+\s[a-z]+',re.IGNORECASE)
match1 = re1.match(searchstr)
print "Match for r'[a-z]+\s[a-z]+\s[a-z]+\s[a-z]+',re.IGNORECASE = ", match1.group()

searchstr = "this is line number 987"
search(searchstr)

re1 = re.compile(r'[a-z]+\s[a-z]+\s\w+\s\w+\s\d+')
match1 = re1.match(searchstr)
print "Match for r'[a-z]+\s[a-z]+\s\w+\s\w+\s\d+' = ",match1.group()

#END

OUTPUT

bala@bala-laptop:~/python$ python RE.py
*********************************
searchstr =  This is a test string
*********************************
Match for '.*',re.DOTALL =  T
Match for '.*' =  This is a test string
*********************************
searchstr =  this is first line
this is second line
*********************************
Match for '.*',re.DOTALL =  this is first line
this is second line
Match for 'line$' =  None
Match for '[a-z]' =  <_sre.SRE_Match object at 0x7fa5ecf69238>
Match for '[a-z]+' =  this
Match for '[a-z]+.*' =  this is first line
Match for '[a-z]+\s' =  this
Match for r'[a-z]+\s[a-z]+' =  this is
Match for r'[a-z]+\s[a-z]+\s[a-z]+\s[a-z]+' =  this is first line
*********************************
searchstr =  This is first LINE
*********************************
Match for r'[a-z]+\s[a-z]+\s[a-z]+\s[a-z]+',re.IGNORECASE =  This is first LINE
*********************************
searchstr =  this is line number 987
*********************************
Match for r'[a-z]+\s[a-z]+\s\w+\s\w+\s\d+' =  this is line number 987
bala@bala-laptop:~/python$ clear

bala@bala-laptop:~/python$ python 30RE.py
*********************************
searchstr =  This is a test string
*********************************
Match for '^T' =  T
Match for '.*' =  This is a test string
*********************************
searchstr =  this is first line
this is second line
*********************************
Match for '.*',re.DOTALL =  this is first line
this is second line
Match for 'line$' =  None
Match for '[a-z]' =  <_sre.SRE_Match object at 0x7f646e2c0238>
Match for '[a-z]+' =  this
Match for '[a-z]+.*' =  this is first line
Match for '[a-z]+\s' =  this
Match for r'[a-z]+\s[a-z]+' =  this is
Match for r'[a-z]+\s[a-z]+\s[a-z]+\s[a-z]+' =  this is first line
*********************************
searchstr =  This is first LINE
*********************************
Match for r'[a-z]+\s[a-z]+\s[a-z]+\s[a-z]+',re.IGNORECASE =  This is first LINE
*********************************
searchstr =  this is line number 987
*********************************
Match for r'[a-z]+\s[a-z]+\s\w+\s\w+\s\d+' =  this is line number 987
bala@bala-laptop:~/python$