ptreport

Differences between revisions 1 and 2
Revision 1 as of 2008-02-15 06:21:55
Size: 1338
Editor: host83-220-dynamic
Comment:
Revision 2 as of 2008-02-17 21:41:45
Size: 5666
Editor: host83-220-dynamic
Comment:
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
#!/bin/bash #!/usr/bin/env python
Line 7: Line 7:
# ptreport V 0.0.1 Alpha # anteater V 0.1 Alpha
Line 11: Line 11:
# Giorgio Carlo Gigli Tos <gionnyboss@gmail.com>
Line 13: Line 14:
# 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 19:
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)"
Line 26: Line 26:
# 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
        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."
Line 34: Line 29:
# Including CoC in *-report.txt
cat up-coc.txt >> ${infra_name}-report.txt
        cocFilename = "coc.txt"
        editor = "nano"
Line 37: Line 32:
echo "
      Ubuntu Pentest Evangelist Informations:
      USER: https://edge.launchpad.net/~${l_id}
      IP: ${pt_ip}
Line 42: Line 33:
            * Starting Report for ${infra_name}:
     
     
      
     " >> ${infra_name}-report.txt
        def __init__(self):
Line 49: Line 35:
# Write report
nano ${infra_name}-report.txt
                self.__getOptions()
Line 52: Line 37:
# gpg sign
gpg --clearsign ${infra_name}-report.txt
                # Displaying code of conduct
                os.system("more " + self.cocFilename)
Line 55: Line 40:
# Move signed report for attach in bug
mv ${infra_name}-report.txt.asc ${infra_name}-report.txt
                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 58: Line 47:
# launchpd sending bug ... (we will add python-launchpad-bugs script for automated open bugs)                 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()

Include(UbuntuPentest/Header)

bash alpha version

# 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()

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