ptreport

Differences between revisions 1 and 6 (spanning 5 versions)
Revision 1 as of 2008-02-15 06:21:55
Size: 1338
Editor: host83-220-dynamic
Comment:
Revision 6 as of 2008-02-19 01:32:58
Size: 4405
Editor: host185-223-dynamic
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
bash alpha version '''anateater''' V 0.1 alpha
[http://thc.emanuele-gentili.com/~emgent/anateater/anteater.py anateater.py]

Line 5: Line 8:
#!/bin/bash #!/usr/bin/env python
Line 7: Line 10:
# ptreport V 0.0.1 Alpha # anteater V 0.1 Alpha
Line 11: Line 14:
# Giorgio Carlo Gigli Tos <gionnyboss@gmail.com>
Line 13: Line 17:
# Show ubuntu-pentest code of conduct
more "up-coc.txt"
echo "Do you accept Ubuntu Pentest Code of Conduct? (y/n)"
read coc
import sys
import os
from stat import *
import re
Line 18: Line 22:
case ${coc} in
     Y|y) ;;
[Yy][Ee][Ss]) ;;
     N|n) exit ;;
[Nn][Oo]) exit ;;
       *) exit ;;
esac
class Application():
 NAME = "anteater.py"
 VERSION = 0.1
 AUTHORS = \
   "Emanuele Gentili (emgent)\n" \
   + "Giorgio Carlo Gili Tos (GionnyBoss)"
 
 LICENSE = "This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.\n" \
   + "There is NO WARRANTY, to the extent permitted by law."
 
 cocFilename = "coc.txt"
 editor = "nano"
Line 26: Line 35:
# Insert informations
echo "Please insert your Launchpad ID: "
read l_id
echo "Please insert your current IP: "
read pt_ip
echo "Please, enter the name of the platform where you make pt: "
read infra_name
Line 34: Line 36:
# Including CoC in *-report.txt
cat up-coc.txt >> ${infra_name}-report.txt
 def __init__(self):
Line 37: Line 38:
echo "
      Ubuntu Pentest Evangelist Informations:
      USER: https://edge.launchpad.net/~${l_id}
      IP: ${pt_ip}
  self.__getOptions()
Line 42: Line 40:
            * Starting Report for ${infra_name}:
     
     
      
     " >> ${infra_name}-report.txt
  # Displaying code of conduct
  os.system("more " + self.cocFilename)
  
  while True:
   reply = self.__getLine("Do you accept Ubuntu Code of Conduct? [y,n] ")
   if re.match("^\s*y\s*$", reply, re.IGNORECASE):
    break
   elif re.match("^\s*n\s*$", reply, re.IGNORECASE):
    sys.exit("You did not accept Ubuntu Code of Conduct.\nExiting application...")
Line 49: Line 50:
# Write report
nano ${infra_name}-report.txt
  self.start()
   
 # Get command line options
 def __getOptions(self):
  
  from optparse import OptionParser
  
  usage = self.NAME + " [OPTION]..."
  version = self.NAME + " " + str(self.VERSION) + "\n" + self.LICENSE + "\n\nWritten by " + self.AUTHORS
  description = "Application description"
  
  parser = OptionParser(usage=usage, version=version, description=description)
  parser.add_option("-e", "--editor", action="store", type="string", default="nano", help="command of the editor to use to edit your bug report [default: %default]", metavar="EDITOR")
  (options, args) = parser.parse_args()
  
  self.editor = options.editor
  # Checking if editor exists in path
  pathDirs = os.environ['PATH'].split(":")
Line 52: Line 69:
# gpg sign
gpg --clearsign ${infra_name}-report.txt
  editorValid = False
  for dir in pathDirs:
   file = os.path.join(dir, self.editor)
   if os.path.isfile(file):
    mode = os.stat(file)[ST_MODE]
    # Checking if file is executable to Others
    # TODO - Think if there is a better way to do this.
    if (S_IMODE(mode) & S_IXOTH) == S_IXOTH:
     editorValid = True
     break
Line 55: Line 80:
# Move signed report for attach in bug
mv ${infra_name}-report.txt.asc ${infra_name}-report.txt
  if not editorValid:
   sys.exit(self.NAME + ": specified editor `" + self.editor + "' is not in your path")
Line 58: Line 83:
# launchpd sending bug ... (we will add python-launchpad-bugs script for automated open bugs)  def __getLine(self, text):
  
  try:
   line = raw_input(text)
  except (EOFError, KeyboardInterrupt):
   print ""
   self.quit("Aborted by user")
  return line

 def start(self):
  launchpadID = self.__getLine("Please insert your Launchpad ID: ")
  ip = self.__getLine("Please insert your current IP: ")
  platformName = self.__getLine("Please, enter the name of the platform where you make pt: ")
  
  reportFilename = platformName + "-report.txt"

  # Opening coc file for reading and report file for writing
  cockFile = open(self.cocFilename, 'r')
  reportFile = open(reportFilename, 'w')
  # Writing coc file content to reportFile
  reportFile.write(cockFile.read())
  # Closing coc file
  cockFile.close()
  # Writing report intestation
  reportFile.write("Ubuntu Pentest Evangelist Informations:\n" \
    + "USER: https://edge.launchpad.net/~" + launchpadID + "\n" \
    + "IP: " + ip + "\n" \
    + "* Starting Report for " + platformName + ":\n")
  # Closing report file
  reportFile.close()

  os.system(self.editor + " " + reportFilename)

  # gpg sign
  os.system("gpg --clearsign " + platformName + "-report.txt")

  # Deleting report file and renaming signed report file to report file name
  try:
   os.remove(reportFilename)
  except OSError:
   sys.exit(self.NAME + ": cannot remove `" + reportFilename + "'")
  try:
   os.rename(reportFilename + ".asc", reportFilename)
  except OSError:
   sys.exit(self.NAME + ": cannot rename file `" + reportFilename + ".asc' to `" + reportFilename + "'")

  # launchpd sending bug ... (we will add python-launchpad-bugs script for automated open bugs)

 def quit(self, msg):
  sys.exit(msg)

# ------------------------------------------------------------------------------
# Application START

if __name__ == "__main__":
 application = Application()
Line 60: Line 140:

= Template report =

Include(UbuntuPentest/Header)

anateater V 0.1 alpha [http://thc.emanuele-gentili.com/~emgent/anateater/anteater.py anateater.py]

# anteater V 0.1 Alpha
# (C) 2008 Ubuntu Pentest, Emanuele Gentili
# Authors
# Emanuele Gentili <emgent@emanuele-gentili.com>
# Giorgio Carlo Gigli Tos <gionnyboss@gmail.com>
# GPLv2, see /usr/share/common-licenses/GPL

import sys
import os
from stat import *
import re

class Application():
        NAME = "anteater.py"
        VERSION = 0.1
        AUTHORS = \
                        "Emanuele Gentili (emgent)\n" \
                        + "Giorgio Carlo Gili Tos (GionnyBoss)"
        
        LICENSE = "This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.\n" \
                        + "There is NO WARRANTY, to the extent permitted by law."
        
        cocFilename = "coc.txt"
        editor = "nano"


        def __init__(self):

                self.__getOptions()

                # Displaying code of conduct
                os.system("more " + self.cocFilename)
                
                while True:
                        reply = self.__getLine("Do you accept Ubuntu Code of Conduct? [y,n] ")
                        if re.match("^\s*y\s*$", reply, re.IGNORECASE):
                                break
                        elif re.match("^\s*n\s*$", reply, re.IGNORECASE):
                                sys.exit("You did not accept Ubuntu Code of Conduct.\nExiting application...")

                self.start()
                        
        # Get command line options
        def __getOptions(self):
                
                from optparse import OptionParser
                
                usage = self.NAME + " [OPTION]..."
                version = self.NAME + " " + str(self.VERSION) + "\n" + self.LICENSE + "\n\nWritten by " + self.AUTHORS
                description = "Application description"
                
                parser = OptionParser(usage=usage, version=version, description=description)
                parser.add_option("-e", "--editor", action="store", type="string", default="nano", help="command of the editor to use to edit your bug report [default: %default]", metavar="EDITOR")
                (options, args) = parser.parse_args()
                
                self.editor = options.editor
                # Checking if editor exists in path
                pathDirs = os.environ['PATH'].split(":")

                editorValid = False
                for dir in pathDirs:
                        file = os.path.join(dir, self.editor)
                        if os.path.isfile(file):
                                mode = os.stat(file)[ST_MODE]
                                # Checking if file is executable to Others
                                # TODO - Think if there is a better way to do this.
                                if (S_IMODE(mode) & S_IXOTH) == S_IXOTH:
                                        editorValid = True
                                        break

                if not editorValid:
                        sys.exit(self.NAME + ": specified editor `" + self.editor + "' is not in your path")

        def __getLine(self, text):
                
                try:
                        line = raw_input(text)
                except (EOFError, KeyboardInterrupt):
                        print ""
                        self.quit("Aborted by user")
                return line

        def start(self):
                launchpadID = self.__getLine("Please insert your Launchpad ID: ")
                ip = self.__getLine("Please insert your current IP: ")
                platformName = self.__getLine("Please, enter the name of the platform where you make pt: ")
                
                reportFilename = platformName + "-report.txt"

                # Opening coc file for reading and report file for writing
                cockFile = open(self.cocFilename, 'r')
                reportFile = open(reportFilename, 'w')
                # Writing coc file content to reportFile
                reportFile.write(cockFile.read())
                # Closing coc file
                cockFile.close()
                # Writing report intestation
                reportFile.write("Ubuntu Pentest Evangelist Informations:\n" \
                                + "USER: https://edge.launchpad.net/~" + launchpadID + "\n" \
                                + "IP: " + ip + "\n" \
                                + "* Starting Report for " + platformName + ":\n")
                # Closing report file
                reportFile.close()

                os.system(self.editor + " " + reportFilename)

                # gpg sign
                os.system("gpg --clearsign " + platformName + "-report.txt")

                # Deleting report file and renaming signed report file to report file name
                try:
                        os.remove(reportFilename)
                except OSError:
                        sys.exit(self.NAME + ": cannot remove `" + reportFilename + "'")
                try:
                        os.rename(reportFilename + ".asc", reportFilename)
                except OSError:
                        sys.exit(self.NAME + ": cannot rename file `" + reportFilename + ".asc' to `" + reportFilename + "'")

                # launchpd sending bug ... (we will add python-launchpad-bugs script for automated open bugs)

        def quit(self, msg):
                sys.exit(msg)

# ------------------------------------------------------------------------------
# Application START

if __name__ == "__main__":
        application = Application()

Template report

UbuntuPentest/ptreport (last edited 2008-08-06 16:40:37 by localhost)