def testRC3(self): # Scenario 3 - User quits # Stop Processing M = Model("https://www.google.com/") r = M.validURL() self.assertEqual(r, "http://www.google.com/")
def testRC2(self): # Scenario 2 - Invalid URL # Display error message M = Model("https://www") r = M.validURL() self.assertEqual(r, "")
def testRC1_9(self): # Scenario 1-9 - URL is not found in cache and database # Check with the third party server and return valid result M = Model("https://www.google.com/") r = M.urlProcess("https://www.google.com/") self.assertEqual(r.BlacklistManager.maliciousType, 'safe URL')
def testRC1_8(self): # Scenario 1-8 - URL is not found in cache # Check in the database and return valid result M = Model("http://nigooglekbgo.xyz/uk/google22/5230/") r = M.urlProcess("http://nigooglekbgo.xyz/uk/google22/5230/") self.assertEqual(r.BlacklistManager.maliciousType, 'SOCIAL_ENGINEERING')
def testRC1_1(self): # Scenario 1-1 - Successful enter a URL and get result # Return valid result (no suspicious condition) M = Model("http://sample.com") r = M.urlProcess("http://sample.com") self.assertEqual(r.BlacklistManager.maliciousType, 'safe URL') self.assertEqual(r.SourceCodeHandler.isMining, False) self.assertEqual(r.SourceCodeHandler.miningType, 'Unrecognized') self.assertEqual(r.SourceCodeHandler.hasAutoDownload, False) self.assertEqual(r.SourceCodeHandler.hasPopUp, False) self.assertEqual(r.SourceCodeHandler.hasHiddenObject, False) self.assertEqual(r.SourceCodeHandler.hasNotification, False) self.assertEqual(r.SourceCodeHandler.hasHardwareAccess, {}) self.assertLessEqual(r.BrowserSimulator.usage.mem, 2000) self.assertNotEqual(r.BrowserSimulator.viewfilename, "")
def testRC1_5(self): # Scenario 1-5 - Successful enter a URL that has notification access and get result # Return valid result (find notification access) M = Model("https://kkplay3c.net/141126-2/") r = M.urlProcess("https://kkplay3c.net/141126-2/") self.assertEqual(r.BlacklistManager.maliciousType, 'safe URL') self.assertEqual(r.SourceCodeHandler.isMining, False) self.assertEqual(r.SourceCodeHandler.miningType, 'Unrecognized') self.assertEqual(r.SourceCodeHandler.hasAutoDownload, False) self.assertEqual(r.SourceCodeHandler.hasPopUp, False) self.assertEqual(r.SourceCodeHandler.hasHiddenObject, False) self.assertEqual(r.SourceCodeHandler.hasNotification, True) self.assertEqual(r.SourceCodeHandler.hasHardwareAccess, {}) self.assertLessEqual(r.BrowserSimulator.usage.mem, 2000) self.assertNotEqual(r.BrowserSimulator.viewfilename, "")
def testRC1_4(self): # Scenario 1-4 - Successful enter a URL that accesses hardware and get result # Return valid result (find hardware access) M = Model("https://davidwalsh.name/demo/camera.php") r = M.urlProcess("https://davidwalsh.name/demo/camera.php") self.assertEqual(r.BlacklistManager.maliciousType, 'safe URL') self.assertEqual(r.SourceCodeHandler.isMining, False) self.assertEqual(r.SourceCodeHandler.miningType, 'Unrecognized') self.assertEqual(r.SourceCodeHandler.hasAutoDownload, False) self.assertEqual(r.SourceCodeHandler.hasPopUp, False) self.assertEqual(r.SourceCodeHandler.hasHiddenObject, False) self.assertEqual(r.SourceCodeHandler.hasNotification, False) self.assertNotEqual(r.SourceCodeHandler.hasHardwareAccess, {}) self.assertLessEqual(r.BrowserSimulator.usage.mem, 2000) self.assertNotEqual(r.BrowserSimulator.viewfilename, "")
class Frontend(): def __init__(self): self.model=Model("") self.url="" print("init Frontend") def index(self,request): url_mode = 0 url_alert = 0 enterurl = request.POST.get('URL_input',None) self.model.renewModel("") if enterurl!=None: # type url self.url = enterurl self.model.url=enterurl url = self.model.validURL(); if url=="": #get wrong url url_mode = 0 url_alert = 1 else : #get correct url url_mode = 1 url_alert = 0 else: url_alert=0 if url_mode==0: return render(request, './indexpage.html',{'url_alert':url_alert,'url_output':enterurl}) else : return render(request, './resultpage.html',{ 'url':url, }) def startprocess(self,request): self.model.urlProcess(self.url); print("end process") return JsonResponse({"test":"test"}) def ajax_SC(self,request): #print("start SC") while True: SC_Result=self.model.get_result("SC") if (SC_Result!=None): break time.sleep(1) return_dict= { 'isMining': "{}".format(SC_Result.isMining), 'miningType': SC_Result.miningType, 'hasAutoDownload' : "{}".format(SC_Result.hasAutoDownload), 'hasPopUp' : "{}".format(SC_Result.hasPopUp), 'hasHiddenObject' : "{}".format(SC_Result.hasHiddenObject), 'hasNotification' : "{}".format(SC_Result.hasNotification), 'hasHardwareAccess' : SC_Result.hasHardwareAccess } #print("end SC") return JsonResponse(return_dict) def ajax_BL(self,request): #print("start BL") while True: BL_Result=self.model.get_result("BL") if (BL_Result!=None): break time.sleep(1) return_dict= { 'maliciousType': BL_Result.maliciousType, } #print("end BL") return JsonResponse(return_dict) def ajax_BS(self,request): #print("start BS") while True: BS_Result=self.model.get_result("BS") if (BS_Result!=None): break time.sleep(1) return_dict= { 'mem': BS_Result.usage.mem, 'cpu': BS_Result.usage.cpu, 'viewfilename' : BS_Result.viewfilename } #print("end BS") return JsonResponse(return_dict)
def __init__(self): self.model=Model("") self.url="" print("init Frontend")