Ejemplo n.º 1
0
class BlacklistManagerTest(TestCase):
    fixtures = ['blacklistDB.json']

    def testBlacklistManagerCheckWithMaliciousURL(self):
        self.bm = BlacklistManager("http://nigooglekbgo.xyz/uk/google22/5230/")
        self.result = self.bm.check()
        self.assertIsInstance(self.result, BlacklistResult)
        self.assertEqual(self.result.maliciousType, "SOCIAL_ENGINEERING")

    def testBlacklistManagerCheckWithSafeURL(self):
        self.bm = BlacklistManager("http://google.com")
        self.result = self.bm.check()
        self.assertIsInstance(self.result, BlacklistResult)
        self.assertEqual(self.result.maliciousType, "safe URL")

    def testCacheCheck(self):
        self.bm = BlacklistManager("http://google.com")
        self.bm.check()
        self.result = self.bm.checkCache()
        self.assertEqual(self.result, "safe URL")

    def testDBCheckWithExistedURL(self):
        self.bm = BlacklistManager("http://nigooglekbgo.xyz/uk/google22/5230/")
        self.result = self.bm.checkDB()
        self.assertEqual(self.result, "SOCIAL_ENGINEERING")

    def testDBCheckWithUnexistedURL(self):
        self.bm = BlacklistManager("http://google.com")
        self.result = self.bm.checkDB()
        self.assertEqual(self.result, "")

    def testThirdPartyCheck(self):
        self.bm = BlacklistManager("http://nigooglekbgo.xyz/uk/google22/5230/")
        self.result = self.bm.checkThirdParty()
        self.assertEqual(self.result, "SOCIAL_ENGINEERING")

    def testThirdPartyCheckError(self):
        self.bm = BlacklistManager("http://google.com")
        self.result = self.bm.checkThirdParty()
        self.assertEqual(self.result, "")
Ejemplo n.º 2
0
    def urlProcess(self, url):

        bs = BrowserSimulator(url)
        sc = SourceCodeHandler(url)
        bl = BlacklistManager(url)
        bsResult = MyThread(target=bs.simulateManager)
        scResult = MyThread(target=sc.call)
        blResult = MyThread(target=bl.check)
        bsResult.start()
        scResult.start()
        blResult.start()
        #print(bsResult.get_result())
        #print(scResult.get_result())
        self.result.SourceCodeHandler = scResult.get_result()
        self.result.BrowserSimulator = bsResult.get_result()
        self.result.BlacklistManager = blResult.get_result()
        #print(self.result.BlacklistManager.maliciousType)
        #print(self.result.SourceCodeHandler.isMining)
        #print(self.result.SourceCodeHandler.miningType)
        #print(self.result.SourceCodeHandler.hasAutoDownload)
        #print(self.result.SourceCodeHandler.hasPopUp)
        #print(self.result.BrowserSimulator.usage.mem)
        #print(self.result.BrowserSimulator.viewfilename)
        return self.result
Ejemplo n.º 3
0
 def testBlacklistManagerCheckWithMaliciousURL(self):
     self.bm = BlacklistManager("http://nigooglekbgo.xyz/uk/google22/5230/")
     self.result = self.bm.check()
     self.assertIsInstance(self.result, BlacklistResult)
     self.assertEqual(self.result.maliciousType, "SOCIAL_ENGINEERING")
Ejemplo n.º 4
0
 def testThirdPartyCheckError(self):
     self.bm = BlacklistManager("http://google.com")
     self.result = self.bm.checkThirdParty()
     self.assertEqual(self.result, "")
Ejemplo n.º 5
0
 def testThirdPartyCheck(self):
     self.bm = BlacklistManager("http://nigooglekbgo.xyz/uk/google22/5230/")
     self.result = self.bm.checkThirdParty()
     self.assertEqual(self.result, "SOCIAL_ENGINEERING")
Ejemplo n.º 6
0
 def testDBCheckWithUnexistedURL(self):
     self.bm = BlacklistManager("http://google.com")
     self.result = self.bm.checkDB()
     self.assertEqual(self.result, "")
Ejemplo n.º 7
0
 def testDBCheckWithExistedURL(self):
     self.bm = BlacklistManager("http://nigooglekbgo.xyz/uk/google22/5230/")
     self.result = self.bm.checkDB()
     self.assertEqual(self.result, "SOCIAL_ENGINEERING")
Ejemplo n.º 8
0
 def testCacheCheck(self):
     self.bm = BlacklistManager("http://google.com")
     self.bm.check()
     self.result = self.bm.checkCache()
     self.assertEqual(self.result, "safe URL")
Ejemplo n.º 9
0
 def testBlacklistManagerCheckWithSafeURL(self):
     self.bm = BlacklistManager("http://google.com")
     self.result = self.bm.check()
     self.assertIsInstance(self.result, BlacklistResult)
     self.assertEqual(self.result.maliciousType, "safe URL")