Example #1
0
def showTokenDash(request, cloudItem):
    """ Displays the dashboard and manage the menu choices """
    data = {}

    ci = checkCloudItem(cloudItem, request.user.id)
    data['showToken'] = True
    data['objID'] = ci.id
    data['dropAuthURL'] = oauth.dropboxAuthorizeURL()
    data['gdriveAuthURL'] = oauth.googleAuthorizeURL()

    #for cred
    res = openReport(ci)
    if res is not None:
        data['browsers'] = res[1]["objects"]
    else:
        data['browsers'] = None

    data['accessTable'] = render_to_string(
        "dashboard/tokenTable.html", {
            'tknTable': DbInterface.getAccessTokenList(ci),
            'id': ci.id
        })

    return render_to_response("dashboard/cloud.html",
                              data,
                              context_instance=RequestContext(request))
Example #2
0
	def downloadInfo(self):
		""" Displays the information about the download """

		self.story.append(Paragraph("Download Information",styles['Heading1']))
		
		d = DbInterface.getDownload(self.t)
		zipVerification = Verifier(self.t).verifyZIP()
		mbSize = float(d.finalFileSize) / math.pow(2,20)

		startT = str(timezone.localtime(d.downTime))
		endT = str(timezone.localtime(d.endDownTime))

		data = []
		data.append([Paragraph("Start Time: <b>" + startT + "</b>",self.normalStyle)])
		data.append([Paragraph("End Time: <b>" + endT + "</b>",self.normalStyle)])
		data.append([Paragraph("Size: <b>" + str(mbSize) + " MB </b>",self.normalStyle)])
		data.append([Paragraph("ZIP Signature Hash: <b>" + d.verificationZIPSignatureHash + " (" + zipVerification['zipHashBase64']  + ")</b>",self.normalStyle)])
		data.append([Paragraph("Digital Timestamp Authoritiy: <b>" + str("https://www.digistamp.com")+ "</b>",self.normalStyle)])

		t = Table(data)
		t.setStyle(TableStyle([('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
				       ('BOX', (0,0), (-1,-1), 0.25, colors.black),
				      ]
				     )
			)

		self.story.append(t)
Example #3
0
class AbstractAnalyzer():
	""" This class represent an abstract analyzer """

	__metaclass__ = abc.ABCMeta

	def __init__(self,token):
		self.db = DbInterface()
		self.t = token
		self.metadata = self.db.getMetadataParsed(token)

	@abc.abstractmethod
	def metadataAnalysis(self):
		""" Display the stats about metadata """
		return

	@abc.abstractmethod
	def metadataSearch(self,searchType,mimeType,startDate,endDate):
		""" Search through the metadata """
		return

	@abc.abstractmethod
	def fileInfo(self,fileId):
		""" Display single file information """
		return

	@abc.abstractmethod
	def fileHistory(self,fileObject):
		""" Display file history """
		return
Example #4
0
	def __init__(self,tokenID):
		self.t = DbInterface.getToken(tokenID)
		self.normalStyle = styles['Normal']
		self.wrappedStyle = styles["BodyText"]

		self.response = HttpResponse(content_type='application/pdf')
		self.response['Content-Disposition'] = 'attachment; filename="report'+str(self.t.id)+'.pdf"'

		self.reportId = str(binascii.hexlify(os.urandom(32)))
		self.genTime = str(timezone.localtime(timezone.now()))

		self.doc = SimpleDocTemplate(self.response,pagesize=landscape(A4))
		self.story = [Spacer(1,2*inch)]
Example #5
0
    def __init__(self, tokenID):
        self.t = DbInterface.getToken(tokenID)
        self.normalStyle = styles['Normal']
        self.wrappedStyle = styles["BodyText"]

        self.response = HttpResponse(content_type='application/pdf')
        self.response[
            'Content-Disposition'] = 'attachment; filename="report' + str(
                self.t.id) + '.pdf"'

        self.reportId = str(binascii.hexlify(os.urandom(32)))
        self.genTime = str(timezone.localtime(timezone.now()))

        self.doc = SimpleDocTemplate(self.response, pagesize=landscape(A4))
        self.story = [Spacer(1, 2 * inch)]
Example #6
0
	def verifyZIP(self):
		""" Verify the signature and the digital timestamp """
		
		d = DbInterface.getDownload(self.t)
		folderName = d.folder

		#path of signature files
		request = os.path.join(settings.VERIFIED_ZIP,folderName+constConfig.EXTENSION_REQUEST)
		signature = os.path.join(settings.VERIFIED_ZIP,folderName+constConfig.EXTENSION_SIGNATURE)
		zipData = os.path.join(settings.VERIFIED_ZIP,folderName+constConfig.EXTENSION_ZIP)

		zipHash = d.verificationZIPSignatureHash
		zipHashBase64 = binascii.b2a_base64(binascii.unhexlify(zipHash))
		signatureDownloadPath = "/verSign/" + folderName + constConfig.EXTENSION_SIGNATURE				

		if os.path.isfile(request) and os.path.isfile(signature):
			dtaVer = DTAVerifier(None)
			res = dtaVer.verifyTimestamp(request,signature)
			return {'res':res,'zipHashBase64':zipHashBase64,'zipHash':zipHash,'downLink': signatureDownloadPath ,'reqName': folderName+constConfig.EXTENSION_REQUEST,'sigName':folderName+constConfig.EXTENSION_SIGNATURE}
Example #7
0
def showTokens(request,ci):
	""" Show the tokens """

	dajax = Dajax()

	try:
		data = dict()
		cloudItemObj = checkCloudItem(ci,request.user.id)
		data['tknTable'] = DbInterface.getAccessTokenList(cloudItemObj)
		data['id'] = cloudItemObj.id
		table = render_to_string("dashboard/tokenTable.html",data)
		dajax.assign("#tokenTable", "innerHTML", table)
		dajax.assign("#tokenError", "innerHTML","")
		dajax.add_css_class("#tokenError",[])
	except Exception as e:
		dajax.assign("#tokenError", "innerHTML",formatException(e))
		dajax.add_css_class("#tokenError",['alert','alert-danger'])

	return dajax.json()
Example #8
0
def showTokens(request, ci):
    """ Show the tokens """

    dajax = Dajax()

    try:
        data = dict()
        cloudItemObj = checkCloudItem(ci, request.user.id)
        data['tknTable'] = DbInterface.getAccessTokenList(cloudItemObj)
        data['id'] = cloudItemObj.id
        table = render_to_string("dashboard/tokenTable.html", data)
        dajax.assign("#tokenTable", "innerHTML", table)
        dajax.assign("#tokenError", "innerHTML", "")
        dajax.add_css_class("#tokenError", [])
    except Exception as e:
        dajax.assign("#tokenError", "innerHTML", formatException(e))
        dajax.add_css_class("#tokenError", ['alert', 'alert-danger'])

    return dajax.json()
Example #9
0
class AbstractMaps():
    """ This class is used to represent an abstract maps """

    __metaclass__ = abc.ABCMeta

    def __init__(self, token):
        self.t = token
        self.d = Download.objects.get(tokenID=self.t,
                                      threadStatus=constConfig.THREAD_TS)
        self.db = DbInterface()
        self.metadata = self.db.getMetadataParsed(self.t)

    @abc.abstractmethod
    def findExif(self):
        return

    @abc.abstractmethod
    def mailFinder(self):
        return
Example #10
0
    def downloadInfo(self):
        """ Displays the information about the download """

        self.story.append(Paragraph("Download Information",
                                    styles['Heading1']))

        d = DbInterface.getDownload(self.t)
        zipVerification = Verifier(self.t).verifyZIP()
        mbSize = float(d.finalFileSize) / math.pow(2, 20)

        startT = str(timezone.localtime(d.downTime))
        endT = str(timezone.localtime(d.endDownTime))

        data = []
        data.append(
            [Paragraph("Start Time: <b>" + startT + "</b>", self.normalStyle)])
        data.append(
            [Paragraph("End Time: <b>" + endT + "</b>", self.normalStyle)])
        data.append([
            Paragraph("Size: <b>" + str(mbSize) + " MB </b>", self.normalStyle)
        ])
        data.append([
            Paragraph(
                "ZIP Signature Hash: <b>" + d.verificationZIPSignatureHash +
                " (" + zipVerification['zipHashBase64'] + ")</b>",
                self.normalStyle)
        ])
        data.append([
            Paragraph(
                "Digital Timestamp Authoritiy: <b>" +
                str("https://www.digistamp.com") + "</b>", self.normalStyle)
        ])

        t = Table(data)
        t.setStyle(
            TableStyle([
                ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                ('BOX', (0, 0), (-1, -1), 0.25, colors.black),
            ]))

        self.story.append(t)
Example #11
0
	def fileInfo(self):
		""" Displays information about the downloaded files """

		history = []
                rowElem = list()

		self.story.append(Paragraph("Downloaded Files",styles['Heading1']))
		
		#files
		files = DbInterface.getAllFileDownload(self.t)
		
		data = [[Paragraph("<b>ID</b>",self.normalStyle),
			Paragraph("<b>File Name</b>",self.normalStyle),
			Paragraph("<b>Download Time</b>",self.normalStyle),
			Paragraph("<b>Signature</b>",self.normalStyle)]]

		for f in files:
			line = [Paragraph(str(f.id),self.normalStyle),
				Paragraph(f.fileName,self.wrappedStyle),
				Paragraph(str(timezone.localtime(f.downloadTime)),self.wrappedStyle),
				Paragraph(crypto.sha256(f.fileHash).hexdigest(),self.wrappedStyle)
				]

			data.append(line)
			
                        hist = DbInterface.getHistoryForFile(f)

                        #if we have an history
                        if len(hist) > 0:

                            #history.append([f.id,DbInterface.getHistoryForFile(f)])
                            histData = [[Paragraph("<b>ID</b>",self.normalStyle),
                            Paragraph("<b>Revision</b>",self.normalStyle),
                            Paragraph("<b>Download Time</b>",self.normalStyle),
                            Paragraph("<b>Signature</b>",self.normalStyle)
                            ]]

                            for h in hist:
                                histData.append([
                                Paragraph(str(h.id),self.normalStyle),
                                Paragraph(h.revision,self.normalStyle),
                                Paragraph(str(timezone.localtime(h.downloadTime)),self.normalStyle),
                                Paragraph(crypto.sha256(h.fileRevisionHash).hexdigest(),self.normalStyle)
                                ])

                            histT = Table(histData, colWidths=(1.5*cm,6*cm,6*cm,6*cm))
                            histT.setStyle(TableStyle([('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
                            ('BOX', (0,0), (-1,-1), 0.25, colors.black),]))

                            data.append(["",histT,"",""])

                            #row to which apply the colspan
                            rowElem.append(('BACKGROUND',(0,len(data)-1),(0,len(data)-1),colors.green))
                            rowElem.append(('SPAN',(1,len(data)-1),(3,len(data)-1)))

		t = Table(data, colWidths=(2*cm,9*cm,5*cm,8.5*cm))
                styleParam = [('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),('BOX', (0,0), (-1,-1), 0.25, colors.black),]
                styleParam.extend(rowElem)
                print rowElem
                print styleParam
                ts = TableStyle(styleParam)
		t.setStyle(ts)

		self.story.append(t)
		self.story.append(PageBreak())
Example #12
0
    def fileInfo(self):
        """ Displays information about the downloaded files """

        history = []
        rowElem = list()

        self.story.append(Paragraph("Downloaded Files", styles['Heading1']))

        #files
        files = DbInterface.getAllFileDownload(self.t)

        data = [[
            Paragraph("<b>ID</b>", self.normalStyle),
            Paragraph("<b>File Name</b>", self.normalStyle),
            Paragraph("<b>Download Time</b>", self.normalStyle),
            Paragraph("<b>Signature</b>", self.normalStyle)
        ]]

        for f in files:
            line = [
                Paragraph(str(f.id), self.normalStyle),
                Paragraph(f.fileName, self.wrappedStyle),
                Paragraph(str(timezone.localtime(f.downloadTime)),
                          self.wrappedStyle),
                Paragraph(
                    crypto.sha256(f.fileHash).hexdigest(), self.wrappedStyle)
            ]

            data.append(line)

            hist = DbInterface.getHistoryForFile(f)

            #if we have an history
            if len(hist) > 0:

                #history.append([f.id,DbInterface.getHistoryForFile(f)])
                histData = [[
                    Paragraph("<b>ID</b>", self.normalStyle),
                    Paragraph("<b>Revision</b>", self.normalStyle),
                    Paragraph("<b>Download Time</b>", self.normalStyle),
                    Paragraph("<b>Signature</b>", self.normalStyle)
                ]]

                for h in hist:
                    histData.append([
                        Paragraph(str(h.id), self.normalStyle),
                        Paragraph(h.revision, self.normalStyle),
                        Paragraph(str(timezone.localtime(h.downloadTime)),
                                  self.normalStyle),
                        Paragraph(
                            crypto.sha256(h.fileRevisionHash).hexdigest(),
                            self.normalStyle)
                    ])

                histT = Table(histData,
                              colWidths=(1.5 * cm, 6 * cm, 6 * cm, 6 * cm))
                histT.setStyle(
                    TableStyle([
                        ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                        ('BOX', (0, 0), (-1, -1), 0.25, colors.black),
                    ]))

                data.append(["", histT, "", ""])

                #row to which apply the colspan
                rowElem.append(('BACKGROUND', (0, len(data) - 1),
                                (0, len(data) - 1), colors.green))
                rowElem.append(
                    ('SPAN', (1, len(data) - 1), (3, len(data) - 1)))

        t = Table(data, colWidths=(2 * cm, 9 * cm, 5 * cm, 8.5 * cm))
        styleParam = [
            ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
            ('BOX', (0, 0), (-1, -1), 0.25, colors.black),
        ]
        styleParam.extend(rowElem)
        print rowElem
        print styleParam
        ts = TableStyle(styleParam)
        t.setStyle(ts)

        self.story.append(t)
        self.story.append(PageBreak())
Example #13
0
def showTokenDash(request,cloudItem):
	""" Displays the dashboard and manage the menu choices """
	data = {}
	
	ci = checkCloudItem(cloudItem,request.user.id)
	data['showToken'] = True
	data['objID'] = ci.id
	data['dropAuthURL'] = oauth.dropboxAuthorizeURL()
	data['gdriveAuthURL'] = oauth.googleAuthorizeURL()

        #for cred
	res = openReport(ci)
	if res is not None:
		data['browsers'] = res[1]["objects"]
	else:
		data['browsers'] = None

        data['accessTable'] = render_to_string("dashboard/tokenTable.html",{'tknTable':DbInterface.getAccessTokenList(ci),'id':ci.id}) 

	return render_to_response("dashboard/cloud.html", data, context_instance=RequestContext(request))
Example #14
0
	def __init__(self,token):
		self.db = DbInterface()
		self.t = token
		self.metadata = self.db.getMetadataParsed(token)
Example #15
0
 def __init__(self, token):
     self.t = token
     self.d = Download.objects.get(tokenID=self.t,
                                   threadStatus=constConfig.THREAD_TS)
     self.db = DbInterface()
     self.metadata = self.db.getMetadataParsed(self.t)